The size specified in the ping command is actually the number of data bytes to send so this needs to be 28 bytes smaller than the actual packet size to allow for size of the packet header.


To test the MTU of your network, you can use the following commands:
$ ping -s $((1500 - 28)) -D 8.8.8.8 -c 1


The result will be similar to this output:

PING 8.8.8.8 (8.8.8.8) 1472(1500) bytes of data.
--- 8.8.8.8 ping statistics ---
1 packets transmitted, 0 received, 100% packet loss, time 0ms

As a first attempt I’ve (rather optimistically) chosen an MTU size of 1500 bytes, this would be normal on a LAN but if very unlikely to work on an internet connection!


In my case I already know the MTU size is 1492 bytes so I’ll try that next.
$ ping -s $((1492 - 28)) -D 8.8.8.8 -c 1


The result will be similar to this output:

PING 8.8.8.8 (8.8.8.8) 1464(1492) bytes of data.
[1551655205.799011] 1472 bytes from 8.8.8.8: icmp_seq=1 ttl=120 time=9.16 ms
--- 8.8.8.8 ping statistics ---

1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 9.160/9.160/9.160/0.000 ms


If you didn’t know the MTU size you could then just try different values until you found the largest one that worked, but there is a quicker way (depending on your version of ping).


Use the following commands to test for MTU error:

$ ping -s $((1500 - 28)) -M do 8.8.8.8 -c 1


The result will be similar to this output:

PING 8.8.8.8 (8.8.8.8) 1472(1500) bytes of data.
ping: local error: Message too long, mtu=1492
--- 8.8.8.8 ping statistics ---
1 packets transmitted, 0 received, +1 errors, 100% packet loss, time 0ms


Notice the message (ping: local error: Message too long, mtu=1492)


If the MTU is less than 1500, you will need to contact your service provider and request that they configure the MTU correctly on all networking equipment.