因此,由于某种原因,我的树莓派出现了连接问题。奇怪的是,我可以轻松 ping 通本地网络上的所有其他内容。我最终通过手动添加路线“解决”了它,但我想找出根本原因。
您可以看到我发出了哪些命令,以及一条路线如何突然修复了问题:
$ ping 192.168.0.109
PING 192.168.0.109 (192.168.0.109) 56(84) bytes of data.
64 bytes from 192.168.0.109: icmp_seq=1 ttl=128 time=6.45 ms
64 bytes from 192.168.0.109: icmp_seq=2 ttl=128 time=2.56 ms
64 bytes from 192.168.0.109: icmp_seq=3 ttl=128 time=5.19 ms
^C
--- 192.168.0.109 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 2.566/4.739/6.454/1.621 ms
$ ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
^C
--- 8.8.8.8 ping statistics ---
4 packets transmitted, 0 received, 100% packet loss, time 2040ms
$ sudo route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.0.1 0.0.0.0 UG 202 0 0 eth0
192.168.0.0 0.0.0.0 255.255.255.0 U 202 0 0 eth0
$ sudo route add -net default gw 192.168.0.1 netmask 0.0.0.0 dev eth0 metric 0
$ sudo route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.0.1 0.0.0.0 UG 0 0 0 eth0
default 192.168.0.1 0.0.0.0 UG 202 0 0 eth0
192.168.0.0 0.0.0.0 255.255.255.0 U 202 0 0 eth0
$ ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=55 time=32.0 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=55 time=31.5 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=55 time=30.6 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=55 time=29.2 ms
^C
--- 8.8.8.8 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3002ms
rtt min/avg/max/mdev = 29.255/30.865/32.061/1.060 ms
以防万一,这是我的路由器的路由:
ID Destination Network Subnet Mask Gateway Interface
1 192.168.0.0 255.255.255.0 0.0.0.0 LAN & WLAN
2 192.168.11.0 255.255.255.0 0.0.0.0 Internet Connection
3 0.0.0.0 0.0.0.0 192.168.11.1 Internet Connection
有任何想法吗?建议?
更新(根据要求):
$ ping 8.8.8.8
connect: Network is unreachable
$ ip route get 8.8.8.8
RTNETLINK answers: Network is unreachable
$ ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::219:bbff:fe00:0000 [censored last part of MAC] prefixlen 64 scopeid 0x20<link>
ether [censored] txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 17
$ ip route get 8.8.8.8
RTNETLINK answers: Network is unreachable
$ ip route get 8.8.8.8
RTNETLINK answers: Network is unreachable
$ ip route
169.254.0.0/16 dev virbr0 scope link metric 1000 linkdown
192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 linkdown
$ route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
link-local 0.0.0.0 255.255.0.0 U 1000 0 0 virbr0
192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0
$ ip route show table all
169.254.0.0/16 dev virbr0 scope link metric 1000 linkdown
192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 linkdown
broadcast 127.0.0.0 dev lo table local proto kernel scope link src 127.0.0.1
local 127.0.0.0/8 dev lo table local proto kernel scope host src 127.0.0.1
local 127.0.0.1 dev lo table local proto kernel scope host src 127.0.0.1
broadcast 127.255.255.255 dev lo table local proto kernel scope link src 127.0.0.1
broadcast 192.168.122.0 dev virbr0 table local proto kernel scope link src 192.168.122.1 linkdown
local 192.168.122.1 dev virbr0 table local proto kernel scope host src 192.168.122.1
broadcast 192.168.122.255 dev virbr0 table local proto kernel scope link src 192.168.122.1 linkdown
local ::1 dev lo proto kernel metric 256 pref medium
fe80::/64 dev eth0 proto kernel metric 256 pref medium
local ::1 dev lo table local proto kernel metric 0 pref medium
local fe80::219:bbff:fe00:0000 [censored last part of MAC] dev eth0 table local proto kernel metric 0 pref medium
ff00::/8 dev eth0 table local metric 256 pref medium
$ sudo ip route get 8.8.8.8
RTNETLINK answers: Network is unreachable
$ sudo ip route show table all
169.254.0.0/16 dev virbr0 scope link metric 1000 linkdown
192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 linkdown
broadcast 127.0.0.0 dev lo table local proto kernel scope link src 127.0.0.1
local 127.0.0.0/8 dev lo table local proto kernel scope host src 127.0.0.1
local 127.0.0.1 dev lo table local proto kernel scope host src 127.0.0.1
broadcast 127.255.255.255 dev lo table local proto kernel scope link src 127.0.0.1
broadcast 192.168.122.0 dev virbr0 table local proto kernel scope link src 192.168.122.1 linkdown
local 192.168.122.1 dev virbr0 table local proto kernel scope host src 192.168.122.1
broadcast 192.168.122.255 dev virbr0 table local proto kernel scope link src 192.168.122.1 linkdown
local ::1 dev lo proto kernel metric 256 pref medium
fe80::/64 dev eth0 proto kernel metric 256 pref medium
local ::1 dev lo table local proto kernel metric 0 pref medium
local fe80::219:bbff:fe00:0000 [censored last part of MAC] dev eth0 table local proto kernel metric 0 pref medium
ff00::/8 dev eth0 table local metric 256 pref medium
$ sudo ip route get 8.8.8.8
RTNETLINK answers: Network is unreachable
$ sudo ifconfig eth0 192.168.0.105 netmask 255.255.255.0
$ sudo ip route get 8.8.8.8
RTNETLINK answers: Network is unreachable
$ sudo route add default gw 192.168.0.1 eth0
$ sudo ip route get 8.8.8.8
8.8.8.8 via 192.168.0.1 dev eth0 src 192.168.0.105 uid 0
cache
$ ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=55 time=28.8 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=55 time=30.8 ms
^C
--- 8.8.8.8 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 28.813/29.841/30.870/1.042 ms