This repository has been archived on 2024-03-22. You can view files and clone it, but cannot push or open issues or pull requests.
NA-NYC-01-WIREGUARD-TUNNEL-.../mtu-finder.sh
2024-03-08 15:14:38 -05:00

35 lines
814 B
Bash

#!/bin/bash
# Define the target host to test MTU
target_host="google.com"
# Define the maximum MTU size to test
max_mtu=1500
# Define the step size for MTU testing
step=10
# Define the timeout for each ping command
timeout=1
# Define the number of packets to send for each ping
count=15
# Function to perform ping with a specific MTU size
function ping_with_mtu {
ping -M do -c $count -W $timeout -s $1 $target_host > /dev/null 2>&1
return $?
}
# Function to test MTU for a specific size
function test_mtu {
ping_with_mtu $1
return $?
}
# Iterate through MTU sizes and test them
for (( mtu=$max_mtu; mtu>=1200; mtu-=$step ))
do
test_mtu $mtu
if [ $? -eq 0 ]; then
echo "MTU $mtu works fine. (Continuous)"
else
echo "MTU $mtu does not work. (Fragmented)"
fi
done