1. 启动一个抓包侦听:
sudo tcpdump -n -i eth2 icmp &
[1] 1409
$ tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth2, link-type EN10MB (Ethernet), capture size 262144 bytes
2. 发送一个UDP包测试:
$ echo reply-me | nc -u 1.0.0.2 1000
3. 判断结果:如果抓包侦听打印出‘ICMP port unreachable’信息,则说明你发送往的那个UDP地址和端口不通:
20:54:15.475211 IP 1.0.0.2 > 1.0.0.1: ICMP 1.0.0.2 udp port 1000 unreachable, length 45