使用 ping 命令,参数 -f 不允许拆分数据包、参数 -l 指定包大小。

ping -f -l 1452 www.baidu.com

正在 Ping www.baidu.com [220.181.38.150] 具有 1452 字节的数据:
来自 220.181.38.150 的回复: 字节=1452 时间=34ms TTL=52
来自 220.181.38.150 的回复: 字节=1452 时间=34ms TTL=52
来自 220.181.38.150 的回复: 字节=1452 时间=34ms TTL=52

ping -f -l 1453 www.baidu.com

正在 Ping www.baidu.com [220.181.38.150] 具有 1453 字节的数据:
需要拆分数据包但是设置 DF。
需要拆分数据包但是设置 DF。
需要拆分数据包但是设置 DF。

经过测试后,取上限值 1452,然后加上 28 后最终为 1480,所以设置最佳 MTU 值为 1480。

netsh interface ipv4 show subinterfaces

MTU MediaSenseState 传入字节 传出字节 接口
------ --------------- --------- --------- -------------
4294967295 1 0 0 Loopback Pseudo-Interface 1
1500 1 220753208 12495436 本地连接

netsh interface ipv4 set subinterface "本地连接" mtu=1480 store=persistent