Change the size of a ping

Solution 1:

To test the maximum MTU size on a link (i.e. to test for ICMP fragmentation) you can set the ping packet size using the -s option.

For example, to find the maximum MTU you can loop over increasing packet sizes until ping returns an error code:

size=1272
while ping -s $size -c1 -M do google.com >&/dev/null; do 
  ((size+=4))
done
echo "Max MTU size: $((size-4+28))"

Solution 2:

Here's a very simple solution:

ping -s 4024 192.168.0.3

Where -s determines the size of the packet being sent

Solution 3:

Here's a very simple solution: ping -s 4024 192.168.0.3 Where -s determines the size of the packet being sent

The suggestions above won't work anymore on any modern Debian based linux systems due to iputils quietly breaking:

https://github.com/iputils/iputils/issues/320

If the ICMP echo reply gets truncated to MTU size (or anything other than what you sent in the ICMP echo request packet), ping will print nothing!