![为什么我的端口没有打开?Ubuntu 18.04](https://linux22.com/image/919081/%E4%B8%BA%E4%BB%80%E4%B9%88%E6%88%91%E7%9A%84%E7%AB%AF%E5%8F%A3%E6%B2%A1%E6%9C%89%E6%89%93%E5%BC%80%EF%BC%9FUbuntu%2018.04.png)
我在本地网络上运行着一个 NGINX 服务器,作为测试,它只返回单词“holding”。但是,我无法从网络上的任何其他 PC 访问它,尽管它看起来运行正常。
在我的服务器上:
$ ip -4 a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
2: enp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
inet 192.168.1.100/24 brd 192.168.1.255 scope global dynamic noprefixroute enp2s0
valid_lft 79059sec preferred_lft 79059sec
$ netstat -nr
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 enp2s0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 enp2s0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 enp2s0
$ sudo netstat -tnlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 747/systemd-resolve
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 853/cupsd
tcp 0 0 127.0.0.1:27017 0.0.0.0:* LISTEN 994/mongod
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1037/nginx: master
tcp6 0 0 ::1:631 :::* LISTEN 853/cupsd
tcp6 0 0 :::80 :::* LISTEN 1037/nginx: master
$ sudo ufw status
Status: active
To Action From
-- ------ ----
Nginx Full ALLOW Anywhere
80/tcp ALLOW Anywhere
Nginx Full (v6) ALLOW Anywhere (v6)
80/tcp (v6) ALLOW Anywhere (v6)
$ curl 192.168.1.100
holding
在我的客户上:
$ping 192.168.1.100
PING 192.168.1.100 (192.168.1.100) 56(84) bytes of data.
64 bytes from 192.168.1.100: icmp_seq=1 ttl=64 time=3.47 ms
64 bytes from 192.168.1.100: icmp_seq=2 ttl=64 time=2.33 ms
$ ip -4 a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
2: wlp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
inet 192.168.1.215/24 brd 192.168.1.255 scope global dynamic noprefixroute wlp2s0
valid_lft 86007sec preferred_lft 86007sec
$ netstat -nr
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 wlp2s0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 wlp2s0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 wlp2s0
$ sudo netstat -tnlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 13013/systemd-resol
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 31016/cupsd
tcp6 0 0 ::1:631 :::* LISTEN 31016/cupsd
$ curl 192.168.1.100
curl: (7) Failed to connect to 192.168.1.100 port 80: No route to host
$ traceroute 192.168.1.1
traceroute 192.168.1.100
traceroute to 192.168.1.100 (192.168.1.100), 30 hops max, 60 byte packets
1 192.168.1.100 (192.168.1.100) 4.125 ms !X 4.069 ms !X 4.052 ms !X
$ sudo traceroute -T -p 80 192.168.1.100
traceroute to 192.168.1.100 (192.168.1.100), 30 hops max, 60 byte packets
1 192.168.1.100 (192.168.1.100) 2.821 ms !X 3.137 ms !X 3.132 ms !X
我完全被难住了……