Skip to content

Instantly share code, notes, and snippets.

@rs-development
Last active September 28, 2022 19:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rs-development/1d44482c019dc2a3a545c640b3bba27d to your computer and use it in GitHub Desktop.
Save rs-development/1d44482c019dc2a3a545c640b3bba27d to your computer and use it in GitHub Desktop.
Maximum MTU check script - Call with target address as first argument
#!/bin/bash
# Check your maximum MTU size with the help of ping
if [ -z "$1" ]
then
echo "Using 1.1.1.1 as default target, provide your own as argument"
HOSTNAME="1.1.1.1"
else
HOSTNAME=$1
fi
PKT_SIZE=1500
ping -M do -c 1 -W 1 -s $PKT_SIZE $HOSTNAME > /dev/null
r=$?
#echo $r
while [ $r -eq 1 ]; do
PKT_SIZE=$(($PKT_SIZE - 10))
echo "Testing MTU:" $PKT_SIZE
ping -M do -c 1 -W 1 -s $PKT_SIZE $HOSTNAME > /dev/null
r=$?
#echo $r
done
printf "Your Maximum MTU is [ $((PKT_SIZE + 28)) ] \n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment