Lazy set MTU on Linux
This script sets the MTU size on Linux.
Tested on Ubuntu, Red Hat and SuSE.
Default values:
INTERFACE_NAME=eth0;
MTU_VALUE=65000
Execution:
bash changemtu.sh $INTERFACE_NAME $MTU_VALUE
If parameters are not given, the script is running with the default values.
#!bin/bash # Author: Malware # Date: 15.09.2015 INTERFACE_NAME="$1" MTU_VALUE="$2" if [ -z $MTU_VALUE ]; then MTU_VALUE=65000 fi if [ -z $INTERFACE_NAME ]; then echo "Change default eth0 MTU." ifconfig eth0 mtu $MTU_VALUE if [ $? -ne 0 ]; then echo "Error: MTU on eth0 failed." exit 1 fi else ifconfig $INTERFACE_NAME mtu $MTU_VALUE if [ $? -ne 0 ]; then echo "Error: MTU failed." exit 1 else echo "MTU on $INTERFACE_NAME was set." fi fi
That's all, folks!
Tweet