The lazy programmer scripts
scripts that work

Lazy set MTU on Linux GitHub

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!

Written by Malware on Tuesday September 15, 2015
Permalink - Tags: mtu, linux, networking

Leave a comment

comments powered by Disqus

« Lazy set MTU on Windows - Lazy alias to clean Python pyc's. »