ICMP p i n g程序为我们提供了查看 I P记录路由( R R)选项的机会
ping 使用ICMP协议,并只运行在IP网络层.
[16:33 t ~]$ ping -R home.test.com
PING home.test.com (172.16.2.200) 56(124) bytes of data.
64 bytes from itappdoc.inside.test.com (172.16.2.200): icmp_seq=1 ttl=127 time=1.32 ms
NOP
RR: localhost.localdomain (172.16.12.100)
172.16.2.2
home.inside.test.com (172.16.2.200)
172.16.12.3
localhost.localdomain (172.16.12.100)
64 bytes from itappdoc.inside.test.com (172.16.2.200): icmp_seq=2 ttl=127 time=1.34 ms
NOP (same route)
下面是tcpdump抓取的选项,RR选项是ping路由信息,IP是出口地址.
[16:43 t ~]$ sudo tcpdump -ev icmp
[sudo] password for t:
tcpdump: listening on enp19s0, link-type EN10MB (Ethernet), capture size 262144 bytes
16:45:09.110818 18:03:73:67:c5:75 (oui Unknown) > 00:00:5e:00:01:0c (oui Unknown), ethertype IPv4 (0x0800), length 138: (tos 0x0, ttl 64, id 54241, offset 0, flags [DF], proto ICMP (1), length 124, options (NOP,RR localhost.localdomain, 0.0.0.0 0.0.0.0 0.0.0.0 0.0.0.0 0.0.0.0 0.0.0.0 0.0.0.0 0.0.0.0))
localhost.localdomain > home.inside.sky-mobi.com: ICMP echo request, id 7140, seq 1, length 64
16:45:09.112104 68:ef:bd:08:3f:bf (oui Unknown) > 18:03:73:67:c5:75 (oui Unknown), ethertype IPv4 (0x0800), length 138: (tos 0x0, ttl 127, id 577, offset 0, flags [DF], proto ICMP (1), length 124, options (NOP,RR localhost.localdomain, 172.16.2.2, home.inside.sky-mobi.com, 172.16.12.3, 0.0.0.0 0.0.0.0 0.0.0.0 0.0.0.0 0.0.0.0))
home.inside.sky-mobi.com > localhost.localdomain: ICMP echo reply, id 7140, seq 1, length 64
16:45:10.112267 18:03:73:67:c5:75 (oui Unknown) > 00:00:5e:00:01:0c (oui Unknown), ethertype IPv4 (0x0800), length 138: (tos 0x0, ttl 64, id 55000, offset 0, flags [DF], proto ICMP (1), length 124, options (NOP,RR localhost.localdomain, 0.0.0.0 0.0.0.0 0.0.0.0 0.0.0.0 0.0.0.0 0.0.0.0 0.0.0.0 0.0.0.0))
localhost.localdomain > home.inside.sky-mobi.com: ICMP echo request, id 7140, seq 2, length 64
16:45:10.114050 68:ef:bd:08:3f:bf (oui Unknown) > 18:03:73:67:c5:75 (oui Unknown), ethertype IPv4 (0x0800), length 138: (tos 0x0, ttl 127, id 622, offset 0, flags [DF], proto ICMP (1), length 124, options (NOP,RR localhost.localdomain, 172.16.2.2, home.inside.sky-mobi.com, 172.16.12.3, 0.0.0.0 0.0.0.0 0.0.0.0 0.0.0.0 0.0.0.0))
home.inside.sky-mobi.com > localhost.localdomain: ICMP echo reply, id 7140, seq 2, length 64
16:45:11.113256 18:03:73:67:c5:75 (oui Unknown) > 00:00:5e:00:01:0c (oui Unknown), ethertype IPv4 (0x0800), length 138: (tos 0x0, ttl 64, id 55378, offset 0, flags [DF], proto ICMP (1), length 124, options (NOP,RR localhost.localdomain, 0.0.0.0 0.0.0.0 0.0.0.0 0.0.0.0 0.0.0.0 0.0.0.0 0.0.0.0 0.0.0.0))