Linux 中的 MTU (IPv4) 测试

Linux 中的 MTU (IPv4) 测试

我注意到我有几个网络,除了 ICMP 回显和回复之外,所有 ICMP 消息都在防火墙级别被阻止。

我知道有需要至少必须允许 IPv4 中的 ICMP 消息类型 3 才能进行 MTU 协商。

可以使用以下命令嗅探数据包:

sudo tcpdump icmp

但是,如何在一个远程点上生成 ICMP 数据包类型 3 以进行全局测试?

答案1

您需要 ICMP 类型 3“目标不可达”数据包来提供健康IP 连接。

生成用于测试的 ICMP 数据包类型 3 的最简单方法是使用该nping程序。

nping程序是软件包的一部分nmap,因此需要安装它。为此你必须这样做:

sudo apt install nmap

安装后,要测试远程 Linux 系统,开始在远程端运行,以侦听 ICMP 类型 3 和 4 数据包:

sudo tcpdump  'icmp[0] = 3'

或者

sudo tcpdump  '(icmp[0] = 3) and (host ip_or_dns_of_nping_sender)'     

然后让其他系统/端发送 ICMP 类型 3 数据包:

sudo nping --icmp-type 3 ip_or_dns_of_remote

请务必在两个方向上对其进行测试。

例如,使用loopback接口在本地机器上显示测试:

在第一个终端中 - 侦听 ICMP 类型 3 消息:

$sudo tcpdump  -i lo 'icmp[0] = 3'
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on lo, link-type EN10MB (Ethernet), capture size 262144 bytes
21:37:44.089420 IP localhost > localhost: [|icmp]
21:37:45.090092 IP localhost > localhost: [|icmp]
21:37:46.091289 IP localhost > localhost: [|icmp]
21:37:47.093095 IP localhost > localhost: [|icmp]
21:37:48.095019 IP localhost > localhost: [|icmp]
^C
5 packets captured
10 packets received by filter
0 packets dropped by kernel

在第二个终端中 - 发送 ICMP 类型 3 消息:

$sudo nping --icmp-type 3 localhost
Starting Nping 0.6.47 ( http://nmap.org/nping ) at 2017-03-06 21:37 WET
SENT (0.0221s) ICMP 127.0.0.1 > 127.0.0.1 Destination unreachable     (type=3/code=0) ttl=64 id=40477 iplen=28 
RCVD (0.2088s) ICMP 127.0.0.1 > 127.0.0.1 Destination unreachable  (type=3/code=0) ttl=64 id=40477 iplen=28 
SENT (1.0228s) ICMP 127.0.0.1 > 127.0.0.1 Destination unreachable (type=3/code=0) ttl=64 id=40477 iplen=28 
RCVD (1.2088s) ICMP 127.0.0.1 > 127.0.0.1 Destination unreachable (type=3/code=0) ttl=64 id=40477 iplen=28 
SENT (2.0240s) ICMP 127.0.0.1 > 127.0.0.1 Destination unreachable (type=3/code=0) ttl=64 id=40477 iplen=28 
RCVD (2.2088s) ICMP 127.0.0.1 > 127.0.0.1 Destination unreachable (type=3/code=0) ttl=64 id=40477 iplen=28 
SENT (3.0258s) ICMP 127.0.0.1 > 127.0.0.1 Destination unreachable (type=3/code=0) ttl=64 id=40477 iplen=28 
RCVD (3.2088s) ICMP 127.0.0.1 > 127.0.0.1 Destination unreachable (type=3/code=0) ttl=64 id=40477 iplen=28 
SENT (4.0277s) ICMP 127.0.0.1 > 127.0.0.1 Destination unreachable (type=3/code=0) ttl=64 id=40477 iplen=28 
RCVD (4.2088s) ICMP 127.0.0.1 > 127.0.0.1 Destination unreachable (type=3/code=0) ttl=64 id=40477 iplen=28 

Max rtt: 186.715ms | Min rtt: 181.081ms | Avg rtt: 184.307ms
Raw packets sent: 5 (140B) | Rcvd: 5 (140B) | Lost: 0 (0.00%)
Nping done: 1 IP address pinged in 4.24 seconds

无法到达的

相关内容