我想知道如果我们通过在控制台提示符下键入“ping localhost”来 ping 环回接口,是否可以在我的 TCPDUMP 输出中观察到任何 ICMP 数据包?为什么?
答案1
关键是确保指定正确的接口,在本例中是
root@generic:~# tcpdump -n -i lo
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on lo, link-type EN10MB (Ethernet), capture size 65535 bytes
20:00:37.260209 IP 127.0.0.1 > 127.0.0.1: ICMP echo request, id 27850, seq 1, length 64
20:00:37.260228 IP 127.0.0.1 > 127.0.0.1: ICMP echo reply, id 27850, seq 1, length 64
20:00:38.260590 IP 127.0.0.1 > 127.0.0.1: ICMP echo request, id 27850, seq 2, length 64
20:00:38.260611 IP 127.0.0.1 > 127.0.0.1: ICMP echo reply, id 27850, seq 2, length 64
20:00:39.260587 IP 127.0.0.1 > 127.0.0.1: ICMP echo request, id 27850, seq 3, length 64
20:00:39.260609 IP 127.0.0.1 > 127.0.0.1: ICMP echo reply, id 27850, seq 3, length 64
20:00:40.260620 IP 127.0.0.1 > 127.0.0.1: ICMP echo request, id 27850, seq 4, length 64
20:00:40.260643 IP 127.0.0.1 > 127.0.0.1: ICMP echo reply, id 27850, seq 4, length 64
^C
8 packets captured
16 packets received by filter
0 packets dropped by kernel