我刚刚在 Raspbian 上设置了一个无头 Raspberry Pi。
它通过以太网连接到路由器,我之前尝试过wifi,也遇到同样的问题。
我可以通过以太网和 wifi 进行 SSH,我可以 ping Pi,从 Pi 我可以 ping 路由器和其他网络设备,但无法 ping 外部 IP。
如果配置:
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.22 netmask 255.255.255.0 broadcast 192.168.0.255
inet6 [ipv6 address] prefixlen 64 scopeid 0x20<link>
ether [MAC address] txqueuelen 1000 (Ethernet)
RX packets 477 bytes 39836 (38.9 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 450 bytes 59686 (58.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 12 bytes 1722 (1.6 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 12 bytes 1722 (1.6 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 [ipv6 address] prefixlen 64 scopeid 0x20<link>
ether [MAC address] txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 160 bytes 28019 (27.3 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
路由表:
route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 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:
ping 192.168.0.1
PING 192.168.0.1 (192.168.0.1) 56(84) bytes of data.
64 bytes from 192.168.0.1: icmp_seq=1 ttl=64 time=9.69 ms
64 bytes from 192.168.0.1: icmp_seq=2 ttl=64 time=1.48 ms
64 bytes from 192.168.0.1: icmp_seq=3 ttl=64 time=1.80 ms
64 bytes from 192.168.0.1: icmp_seq=4 ttl=64 time=2.12 ms
^C
--- 192.168.0.1 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3004ms
rtt min/avg/max/mdev = 1.479/3.774/9.694/3.425 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 ---
5 packets transmitted, 0 received, 100% packet loss, time 4077ms
我如何诊断问题?我该如何解决它?请帮忙
编辑: 跟踪路由:
traceroute to 8.8.8.8 (8.8.8.8), 64 hops max
1 * * *
2 * * *
[...]
58 * * *
59 * * 192.168.0.22 62.435ms !H
edit2:删除了静态IP配置,现在traceroute输出:
traceroute to 8.8.8.8 (8.8.8.8), 64 hops max
1 192.168.0.1 6.217ms 1.847ms 1.332ms
2 * * *
[...]
编辑3:tcpdump:
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes
09:28:06.646658 IP6 [ipv6 #1].ssh > [ipv6 #2].49591: Flags [P.], seq 3961577292:3961577484, ack 1645861291, win 501, length 192
09:28:06.648416 IP 192.168.0.22.47393 > [ipv4 - ISP cache #1].domain: 15925+ PTR? a.e.8.1.6.3.b.0.b.b.3.5.0.a.f.9.0.0.0.0.0.0.0.0.0.0.0.0.0.8.e.f.ip6.arpa. (90)
09:28:06.688171 IP6 [ipv6 #2].49591 > [ipv6 #1].ssh: Flags [.], ack 192, win 1025, length 0
09:28:08.046962 IP 192.168.0.22.55981 > [ipv4 - ISP cache #2].domain: 46272+ A? 2.debian.pool.ntp.org. (39)
09:28:08.047044 IP 192.168.0.22.55981 > [ipv4 - ISP cache #2].domain: 10446+ AAAA? 2.debian.pool.ntp.org. (39)
09:28:09.761724 IP 192.168.0.12.41326 > 239.255.255.250.1900: UDP, length 125
09:28:10.063180 IP 192.168.0.12.41326 > 239.255.255.250.1900: UDP, length 125
09:28:10.369344 IP 192.168.0.12.41326 > 239.255.255.250.1900: UDP, length 125
09:28:11.653845 IP 192.168.0.22.51128 > [ipv4 - ISP cache #2].domain: 15925+ PTR? a.e.8.1.6.3.b.0.b.b.3.5.0.a.f.9.0.0.0.0.0.0.0.0.0.0.0.0.0.8.e.f.ip6.arpa. (90)
09:28:13.052252 IP 192.168.0.22.49091 > [ipv4 - ISP cache #1].domain: 46272+ A? 2.debian.pool.ntp.org. (39)
09:28:13.052340 IP 192.168.0.22.49091 > [ipv4 - ISP cache #1].domain: 10446+ AAAA? 2.debian.pool.ntp.org. (39)
09:28:16.659113 IP 192.168.0.22.47393 > [ipv4 - ISP cache #1].domain: 15925+ PTR? a.e.8.1.6.3.b.0.b.b.3.5.0.a.f.9.0.0.0.0.0.0.0.0.0.0.0.0.0.8.e.f.ip6.arpa. (90)
09:28:16.709645 ARP, Request who-has 192.168.0.1 tell 192.168.0.22, length 28
09:28:16.710585 ARP, Reply 192.168.0.1 is-at [MAC #1] (oui Unknown), length 46
09:28:17.055977 ARP, Request who-has 192.168.0.1 tell 192.168.0.15, length 46
09:28:18.057531 IP 192.168.0.22.55981 > [ipv4 - ISP cache #2].domain: 46272+ A? 2.debian.pool.ntp.org. (39)
09:28:18.057633 IP 192.168.0.22.55981 > [ipv4 - ISP cache #2].domain: 10446+ AAAA? 2.debian.pool.ntp.org. (39)
09:28:18.933210 IP 192.168.0.14.57621 > 192.168.0.255.57621: UDP, length 44
09:28:19.800035 IP 192.168.0.12.41552 > 239.255.255.250.1900: UDP, length 125
09:28:20.101830 IP 192.168.0.12.41552 > 239.255.255.250.1900: UDP, length 125
09:28:20.402483 IP 192.168.0.12.41552 > 239.255.255.250.1900: UDP, length 125
09:28:21.664304 IP 192.168.0.22.51128 > [ipv4 - ISP cache #2].domain: 15925+ PTR? a.e.8.1.6.3.b.0.b.b.3.5.0.a.f.9.0.0.0.0.0.0.0.0.0.0.0.0.0.8.e.f.ip6.arpa. (90)
09:28:23.064568 IP 192.168.0.22.60984 > [ipv4 - ISP cache #1].domain: 31504+ A? 3.debian.pool.ntp.org. (39)
09:28:23.064668 IP 192.168.0.22.60984 > [ipv4 - ISP cache #1].domain: 20237+ AAAA? 3.debian.pool.ntp.org. (39)
09:28:26.670244 IP 192.168.0.22.42431 > [ipv4 - ISP cache #1].domain: 42575+ PTR? 9.1.8.c.b.f.7.b.e.1.4.0.9.3.8.b.0.0.0.0.0.0.0.0.0.0.0.0.0.8.e.f.ip6.arpa. (90)
09:28:28.070047 IP 192.168.0.22.56262 > [ipv4 - ISP cache #2].domain: 31504+ A? 3.debian.pool.ntp.org. (39)
09:28:28.070195 IP 192.168.0.22.56262 > [ipv4 - ISP cache #2].domain: 20237+ AAAA? 3.debian.pool.ntp.org. (39)
09:28:28.745503 ARP, Request who-has 192.168.0.1 tell 192.168.0.12, length 46
09:28:29.830486 IP 192.168.0.12.43134 > 239.255.255.250.1900: UDP, length 125
09:28:30.130431 IP 192.168.0.12.43134 > 239.255.255.250.1900: UDP, length 125
09:28:30.431008 IP 192.168.0.12.43134 > 239.255.255.250.1900: UDP, length 125
09:28:31.675608 IP 192.168.0.22.57569 > [ipv4 - ISP cache #2].domain: 42575+ PTR? 9.1.8.c.b.f.7.b.e.1.4.0.9.3.8.b.0.0.0.0.0.0.0.0.0.0.0.0.0.8.e.f.ip6.arpa. (90)
09:28:46.692132 IP 192.168.0.22.35774 > [ipv4 - ISP cache #1].domain: 36300+ PTR? 22.0.168.192.in-addr.arpa. (43)
09:29:26.736011 IP 192.168.0.22.60246 > [ipv4 - ISP cache #1].domain: 52343+ PTR? 100.8.168.194.in-addr.arpa. (44)
09:29:26.736108 IP6 [ipv6 #1].ssh > [ipv6 #2].49591: Flags [P.], seq 368:560, ack 1, win 501, length 192
09:29:46.758046 IP6 [ipv6 #1].ssh > [ipv6 #2].49591: Flags [P.], seq 560:688, ack 1, win 501, length 128
09:29:46.758171 IP 192.168.0.22.48623 > [ipv4 - ISP cache #1].domain: 25524+ PTR? 12.0.168.192.in-addr.arpa. (43)
09:30:26.801306 IP6 [ipv6 #1].ssh > [ipv6 #2].49591: Flags [P.], seq 688:816, ack 1, win 501, length 128
09:30:26.801792 IP6 [ipv6 #1].ssh > [ipv6 #2].49591: Flags [P.], seq 816:912, ack 1, win 501, length 96
09:30:26.802104 IP6 [ipv6 #1].ssh > [ipv6 #2].49591: Flags [P.], seq 912:992, ack 1, win 501, length 80
09:30:26.802210 IP 192.168.0.22.49293 > [ipv4 - ISP cache #1].domain: 32774+ PTR? 1.0.168.192.in-addr.arpa. (42)
09:30:26.802431 IP6 [ipv6 #2].49591 > [ipv6 #1].ssh: Flags [.], ack 912, win 1028, length 0
09:30:26.847413 IP6 [ipv6 #2].49591 > [ipv6 #1].ssh: Flags [.], ack 992, win 1028, length 0
09:30:28.207666 IP 192.168.0.22.38721 > [ipv4 - ISP cache #2].domain: 53173+ A? 1.debian.pool.ntp.org. (39)
09:30:46.824371 IP6 [ipv6 #1].ssh > [ipv6 #2].49591: Flags [P.], seq 992:1088, ack 1, win 501, length 96
09:30:46.824457 IP 192.168.0.22.60784 > [ipv4 - ISP cache #1].domain: 6213+ PTR? 15.0.168.192.in-addr.arpa. (43)
09:31:06.846322 IP6 [ipv6 #1].ssh > [ipv6 #2].49591: Flags [P.], seq 1200:1280, ack 1, win 501, length 80
09:31:06.846468 IP 192.168.0.22.53135 > [ipv4 - ISP cache #1].domain: 6352+ PTR? 14.0.168.192.in-addr.arpa. (43)
09:31:06.846724 IP6 [ipv6 #1].ssh > [ipv6 #2].49591: Flags [P.], seq 1280:1344, ack 1, win 501, length 64
09:31:46.890222 IP6 [ipv6 #1].ssh > [ipv6 #2].49591: Flags [P.], seq 1344:1440, ack 1, win 501, length 96
09:31:46.890569 IP6 [ipv6 #1].ssh > [ipv6 #2].49591: Flags [P.], seq 1440:1520, ack 1, win 501, length 80
09:31:46.890892 IP6 [ipv6 #1].ssh > [ipv6 #2].49591: Flags [P.], seq 1520:1616, ack 1, win 501, length 96
09:31:46.891137 IP6 [ipv6 #1].ssh > [ipv6 #2].49591: Flags [P.], seq 1616:1680, ack 1, win 501, length 64
09:31:46.891634 IP6 [ipv6 #1].ssh > [ipv6 #2].49591: Flags [P.], seq 1680:1808, ack 1, win 501, length 128
09:31:46.891903 IP6 [ipv6 #1].ssh > [ipv6 #2].49591: Flags [P.], seq 1808:1872, ack 1, win 501, length 64
09:31:46.892177 IP6 [ipv6 #1].ssh > [ipv6 #2].49591: Flags [P.], seq 1872:1936, ack 1, win 501, length 64
09:31:46.892439 IP6 [ipv6 #1].ssh > [ipv6 #2].49591: Flags [P.], seq 1936:2016, ack 1, win 501, length 80
09:31:46.892682 IP6 [ipv6 #1].ssh > [ipv6 #2].49591: Flags [P.], seq 2016:2080, ack 1, win 501, length 64
09:31:46.893007 IP6 [ipv6 #1].ssh > [ipv6 #2].49591: Flags [P.], seq 2080:2192, ack 1, win 501, length 112
09:31:46.901902 IP6 [ipv6 #2].49591 > [ipv6 #1].ssh: Flags [.], ack 2192, win 1029, length 0
09:31:46.902110 IP6 [ipv6 #1].ssh > [ipv6 #2].49591: Flags [.], seq 2192:3632, ack 1, win 501, length 1440
09:31:46.902152 IP6 [ipv6 #1].ssh > [ipv6 #2].49591: Flags [P.], seq 3632:3904, ack 1, win 501, length 272
09:31:46.902707 IP6 [ipv6 #1].ssh > [ipv6 #2].49591: Flags [P.], seq 3904:4000, ack 1, win 501, length 96
09:31:46.902794 IP6 [ipv6 #2].49591 > [ipv6 #1].ssh: Flags [.], ack 3904, win 1029, length 0
09:31:46.902979 IP6 [ipv6 #1].ssh > [ipv6 #2].49591: Flags [P.], seq 4000:4080, ack 1, win 501, length 80
09:31:46.903372 IP6 [ipv6 #1].ssh > [ipv6 #2].49591: Flags [P.], seq 4080:4144, ack 1, win 501, length 64