AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-564836

Bernd Wechner's questions

Martin Hope
Bernd Wechner
Asked: 2020-10-12 04:02:28 +0800 CST

为什么从网络访问时我的端口被关闭?

  • 11

我读了很多页,尝试了很多东西,但被困在这里。

我有一个新安装的 Ubuntu 20.04 服务器。在它上面我运行了一个 Django 测试服务器(只是为了尝试一下)。它正在运行并侦听端口 8000。

我理解了:

$ sudo netstat -tulpen
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       User       Inode      PID/Program name    
tcp        0      0 0.0.0.0:5432            0.0.0.0:*               LISTEN      112        62240      47748/postgres      
tcp        0      0 127.0.0.1:8000          0.0.0.0:*               LISTEN      1000       65495      48618/python        
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      101        23068      755/systemd-resolve 
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      0          27689      850/sshd: /usr/sbin 
tcp6       0      0 :::5432                 :::*                    LISTEN      112        62241      47748/postgres      
tcp6       0      0 :::22                   :::*                    LISTEN      0          27691      850/sshd: /usr/sbin 
udp        0      0 127.0.0.53:53           0.0.0.0:*                           101        23067      755/systemd-resolve 
udp        0      0 192.168.0.15:68         0.0.0.0:*                           100        23071      753/systemd-network 
udp6       0      0 fe80::224:e8ff:fe22:546 :::*                                100        23086      753/systemd-network 

它的反应很好。我可以在服务器上做:

wget localhost:8000

我得到了回应。

所以现在我搬到我局域网上的台式机上。我尝试 wget:

$ wget server.lan:8000
--2020-10-11 11:42:18--  http://server.lan:8000/
Resolving server.lan (server.lan)... 192.168.0.15
Connecting to server.lan (server.lan)|192.168.0.15|:8000... failed: Connection refused.

果然:

$ nmap server.lan
Starting Nmap 7.80 ( https://nmap.org ) at 2020-10-11 22:43 AEDT
Nmap scan report for server.lan (192.168.0.15)
Host is up (0.00025s latency).
Not shown: 998 closed ports
PORT     STATE SERVICE
22/tcp   open  ssh
5432/tcp open  postgresql

Nmap done: 1 IP address (1 host up) scanned in 0.04 seconds

$ nmap serverlan -p 8000
Starting Nmap 7.80 ( https://nmap.org ) at 2020-10-11 22:44 AEDT
Nmap scan report for server.lan (192.168.0.15)
Host is up (0.00068s latency).

PORT     STATE  SERVICE
8000/tcp closed http-alt

Nmap done: 1 IP address (1 host up) scanned in 0.03 seconds

好的,服务器上的标准检查:

$ sudo iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:8000

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination        

因为我启用了端口 8000:

$ sudo iptables -A INPUT -p tcp --dport 8000 -j ACCEPT

遵循此处的说明:https ://www.e2enetworks.com/help/knowledge-base/how-to-open-ports-on-iptables-in-a-linux-server/

和:

$ sudo ufw status verbose
Status: inactive

然而从桌面上的lan 端口8000 是关闭的!

我应该注意端口 22 是打开的(就像我使用 ssh 登录到服务器一样,我也可以在端口 5432 上看到数据库并使用桌面上的 pgadmin4 管理它就好了,所以端口 22 和 5432 是打开,但我看不到iptables -L它们是打开的。

Ubuntu 20.04 的神奇之处在于我在这里读过的许多页面都没有。

我什至可以很好地ping它:

$ ping arachne.lan
PING arachne.lan (192.168.0.15) 56(84) bytes of data.
64 bytes from 192.168.0.15 (192.168.0.15): icmp_seq=1 ttl=64 time=0.269 ms
64 bytes from 192.168.0.15 (192.168.0.15): icmp_seq=2 ttl=64 time=0.267 ms
64 bytes from 192.168.0.15 (192.168.0.15): icmp_seq=3 ttl=64 time=0.530 ms
64 bytes from 192.168.0.15 (192.168.0.15): icmp_seq=4 ttl=64 time=0.284 ms
64 bytes from 192.168.0.15 (192.168.0.15): icmp_seq=5 ttl=64 time=0.280 ms
64 bytes from 192.168.0.15 (192.168.0.15): icmp_seq=6 ttl=64 time=0.280 ms

所以因为我喜欢它并使用我安装cockpit它并运行端口 9090。它从桌面安装和工作。

现在:

$ netstat -tulpen
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       User       Inode      PID/Program name    
tcp        0      0 0.0.0.0:5432            0.0.0.0:*               LISTEN      112        62240      -                   
tcp        0      0 127.0.0.1:8000          0.0.0.0:*               LISTEN      1000       65495      48618/python        
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      101        23068      -                   
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      0          27689      -                   
tcp6       0      0 :::5432                 :::*                    LISTEN      112        62241      -                   
tcp6       0      0 :::9090                 :::*                    LISTEN      0          71091      -                   
tcp6       0      0 :::22                   :::*                    LISTEN      0          27691      -                   
udp        0      0 127.0.0.53:53           0.0.0.0:*                           101        23067      -                   
udp        0      0 192.168.0.15:68         0.0.0.0:*                           100        23071      -                   
udp6       0      0 fe80::224:e8ff:fe22:546 :::*                                100        23086      -  

但 iptables 无所谓:

$ sudo iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:8000

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination      

但是台式机上的 nmap 可以看到它:

$ nmap server.lan
Starting Nmap 7.80 ( https://nmap.org ) at 2020-10-11 22:55 AEDT
Nmap scan report for server.lan (192.168.0.15)
Host is up (0.00024s latency).
Not shown: 997 closed ports
PORT     STATE SERVICE
22/tcp   open  ssh
5432/tcp open  postgresql
9090/tcp open  zeus-admin

Nmap done: 1 IP address (1 host up) scanned in 0.05 seconds

所以 cockpit 和 postgresql 和 ssh 在安装时都以某种方式管理告诉 Ubuntu 20.04 打开一个端口。

因此,通过内省的 nmap 查看服务器:

$ nmap localhost
Starting Nmap 7.80 ( https://nmap.org ) at 2020-10-11 11:58 UTC
Nmap scan report for localhost (127.0.0.1)
Host is up (0.00021s latency).
Not shown: 996 closed ports
PORT     STATE SERVICE
22/tcp   open  ssh
5432/tcp open  postgresql
8000/tcp open  http-alt
9090/tcp open  zeus-admin

Nmap done: 1 IP address (1 host up) scanned in 0.09 seconds

端口 8000 看起来是打开的。

桌面和服务器之间没有防火墙,只有一个标准的 LAN 交换机。

怎么样,cockpit、postgresql 和 ssh 都可以实现某些目标,但很难弄清楚他们实现了什么以及如何实现它?iptables他们似乎不使用它。也不是ufw。我错过了什么魔法?如何打开 8000 端口?

networking iptables firewall lan 20.04
  • 1 个回答
  • 8348 Views
Martin Hope
Bernd Wechner
Asked: 2018-08-30 22:05:05 +0800 CST

LightDM:座位和会话之间有什么区别?

  • 7

我的背景愿望是配置 LightDM 以在启动后在多个虚拟终端上显示欢迎程序。

除此之外,我正在阅读 LightDM 文档,我发现其中最好的文档在许多 wiki 中重复出现,并在这里举例说明:

https://wiki.parabola.nu/LightDM

我可以很好地遵循默认配置,但让我失去的是席位和会话之间的区别。

如果我切换用户并运行“dm-tool list-seats”,我会看到一个座位有两个会话,并且我在 vt7 上有一个会话,在 vt8 上有一个会话。

然而,我在网上从有人问过同样问题的人那里找到的唯一线索似乎是重复的座位:

  • 如何在 14.04 中在 tty8 上启用第二个 x 会话
  • https://unix.stackexchange.com/questions/87169/autostart-all-lightdm-seats-and-show-one-as-default

在我看来,支持这一点的文档中缺少一个基本要素:什么是席位,什么是会议,它们有何不同?

推论是:

我们可以配置lightdm启动吗

  1. 一个席位,两个会话(在 vt7 和 vt8 上说),或
  2. 两个席位,每个席位(在 vt7 和 vt8 上)

如果有更好的文档记录会很好,如果我喜欢我会在这里提出一个问题:

https://github.com/CanonicalLtd/lightdm

login session lightdm
  • 1 个回答
  • 3296 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve