Debian 服务器无法连接到网络

Debian 服务器无法连接到网络

我的服务器无法连接到本地网络或互联网。

服务器无法 ping 通本地网络上的其他机器。尝试访问互联网失败。

从我的电脑上我可以 ping 本地 IP 192.168.2.1 和 8.8.8.8。

我可以使用 192.168.2.23 IP 地址的 ssh 连接到我的服务器。

ip addr show

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
   valid_lft forever preferred_lft forever
inet6 ::1/128 scope host noprefixroute
   valid_lft forever preferred_lft forever
2: enp0s31f6: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 6c:4b:90:a3:dc:d0 brd ff:ff:ff:ff:ff:ff
    inet 192.168.2.23/24 brd 192.168.2.255 scope global dynamic enp0s31f6
       valid_lft 257944sec preferred_lft 257944sec
    inet6 fe80::6e4b:90ff:fea3:dcd0/64 scope link
       valid_lft forever preferred_lft forever
3: wlp2s0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 98:2c:bc:e3:50:f8 brd ff:ff:ff:ff:ff:ff
4: br-8c5379765694: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
    link/ether 02:42:0c:8e:60:31 brd ff:ff:ff:ff:ff:ff
    inet 172.24.0.1/16 brd 172.24.255.255 scope global br-8c5379765694
       valid_lft forever preferred_lft forever
5: br-44cc32b7ce2f: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
    link/ether 02:42:5d:a8:01:63 brd ff:ff:ff:ff:ff:ff
    inet 172.19.0.1/16 brd 172.19.255.255 scope global br-44cc32b7ce2f
       valid_lft forever preferred_lft forever
    inet6 fe80::42:5dff:fea8:163/64 scope link
       valid_lft forever preferred_lft forever
6: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
    link/ether 02:42:18:1f:a5:14 brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
       valid_lft forever preferred_lft forever
7: br-5e82d16c5e19: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
    link/ether 02:42:54:02:25:66 brd ff:ff:ff:ff:ff:ff
    inet 172.23.0.1/16 brd 172.23.255.255 scope global br-5e82d16c5e19
       valid_lft forever preferred_lft forever
79: veth64b6284@if78: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-44cc32b7ce2f state UP group default
    link/ether e6:ca:08:af:bc:c9 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet6 fe80::e4ca:8ff:feaf:bcc9/64 scope link
       valid_lft forever preferred_lft forever

Trace route

    traceroute to 192.168.2.1 (192.168.2.1), 30 hops max, 60 byte packets
 1  192.168.2.23 (192.168.2.23)  741.652 ms !H  741.585 ms !H  741.546 ms !H

route n

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.2.1     0.0.0.0         UG    0      0        0 enp0s31f6
172.17.0.0      0.0.0.0         255.255.0.0     U     0      0        0 docker0
172.19.0.0      0.0.0.0         255.255.0.0     U     0      0        0 br-44cc32b7ce2f
172.23.0.0      0.0.0.0         255.255.0.0     U     0      0        0 br-5e82d16c5e19
172.24.0.0      0.0.0.0         255.255.0.0     U     0      0        0 br-8c5379765694
192.168.2.0     0.0.0.0         255.255.255.0   U     0      0        0 enp0s31f6

iptables -L

Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain FORWARD (policy DROP)
target     prot opt source               destination
DOCKER-USER  all  --  anywhere             anywhere
DOCKER-ISOLATION-STAGE-1  all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere             ctstate RELATED,ESTABLISHED
DOCKER     all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere             ctstate RELATED,ESTABLISHED
DOCKER     all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere             ctstate RELATED,ESTABLISHED
DOCKER     all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere             ctstate RELATED,ESTABLISHED
DOCKER     all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

Chain DOCKER (4 references)
target     prot opt source               destination
ACCEPT     tcp  --  anywhere             172.19.0.2           tcp dpt:9091

Chain DOCKER-ISOLATION-STAGE-1 (1 references)
target     prot opt source               destination
DOCKER-ISOLATION-STAGE-2  all  --  anywhere             anywhere
DOCKER-ISOLATION-STAGE-2  all  --  anywhere             anywhere
DOCKER-ISOLATION-STAGE-2  all  --  anywhere             anywhere
DOCKER-ISOLATION-STAGE-2  all  --  anywhere             anywhere
RETURN     all  --  anywhere             anywhere

Chain DOCKER-ISOLATION-STAGE-2 (4 references)
target     prot opt source               destination
DROP       all  --  anywhere             anywhere
DROP       all  --  anywhere             anywhere
DROP       all  --  anywhere             anywhere
DROP       all  --  anywhere             anywhere
RETURN     all  --  anywhere             anywhere

Chain DOCKER-USER (1 references)
target     prot opt source               destination
RETURN     all  --  anywhere             anywhere

我很感激有关解决此网络问题的建议。

编辑:

wget 8.8.8.8
--2024-03-08 19:52:58--  http://8.8.8.8/
Connecting to 8.8.8.8:80... failed: No route to host.
wget google.com
--2024-03-08 19:53:23--  http://google.com/
Resolving google.com (google.com)... failed: Temporary failure in name resolution.
cat /etc/resolv.conf
domain home
search home
nameserver 192.168.2.1

答案1

好吧,花了 4 个多小时解决这个问题,这真的很奇怪。

我激活了 WiFi 卡,但出现了相反的问题:我可以看到所有人,但网络内的任何人都看不到我。几分钟后,我再次失去连接。我用以太网卡重新测试,遇到了同样的问题:无法连接外部,但从内部,其他机器可以看到我。

我认为这可能是我的 ISP Bell GigaHub 路由器的问题,因为在它要求我恢复出厂设置之前,一切都正常。所以我删除了 DHCP 租约,我的 WiFi 连接获得了一个新的 IP,并且工作正常。所以,我想,好吧,很简单,我重新连接我的以太网卡,它再次获得 2.23 的 IP,但同样的问题又出现了。

因此,我强制路由器将 IP 地址设置为 2.123,然后一切又恢复正常。这或多或少与 IP 冲突的症状类似,只是我 100% 确定没有冲突。无论如何,IP 2.23 在我的网络上被禁止,我不知道为什么。

相关内容