How to set MTU size in Linux and Windows

Prev Next

WHAT TO EXPECT

In this article, users will learn how to change the MTU size of a given VM.

In some cases, the MTU Size of the multicast group may exceed the default limit of the OS. It can also happen that, in some circumstances, the user may need a small MTU size to send smaller packages. This article will explain how to increase the MTU size if this should occur.

To know if the MTU size has been exceeded, Wireshark or tcpdump can be used.  Below is an example from Wireshark.

MTU Size_discovery

NOTE

In this example, the UDP length error shows it is exceeding the Length.

Change MTU size on Linux

  1. First, check the current MTU size by running the following command:

    ip addr | grep mtu

    Example output

    $ ip addr | grep mtu
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 3900 qdisc mq state UP group default qlen 1000
    4: enP15351s2: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 3900 qdisc mq master eth1 state UP group default qlen 1000
    5: enP9096s1: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc mq master eth0 state UP group default qlen 1000
    6: swx0: <BROADCAST,NOARP,PROMISC,UP,LOWER_UP> mtu 4096 qdisc mq state UNKNOWN group default qlen 10000
    

    As can be seen, the MTU size of eth1 is 3900.

  2. To TEMPORARILY change the MTU size, use:

    sudo ip link set dev <interface_name> mtu <new_mtu_value>

    This will last until the next reboot.

    Example command

    sudo ip link set dev eth1 mtu 2000

    The command will not give any output if correctly executed. So, it is recommended to validate with the command used in step 1.

  3. Validate the change is set by running again:

    ip addr | grep mtu

    Example output

    $ ip addr | grep mtu
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 2000 qdisc mq state UP group default qlen 1000
    4: enP15351s2: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 2000 qdisc mq master eth1 state UP group default qlen 1000
    5: enP9096s1: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc mq master eth0 state UP group default qlen 1000
    6: swx0: <BROADCAST,NOARP,PROMISC,UP,LOWER_UP> mtu 4096 qdisc mq state UNKNOWN group default qlen 10000

    As can be seen, the MTU size of eth1 is now 2000.

PLEASE NOTE

For permanent changes, the procedure will vary depending on the Linux distro (roughly, RHEL-based or Debian-based), and the network manager used (like netplan on Debian-based and nmcli or ifcfg for RHEL-based). Please consult the network admin to get directives.

Change MTU size on Windows

Using PowerShell

  1. Check the current InterfaceAlias and the MTU size by running:

    Get-NetIPInterface -AddressFamily IPv4

    Example output

    PS C:\Windows\System32> Get-NetIPInterface -AddressFamily IPv4
    ifIndex InterfaceAlias                  AddressFamily NlMtu(Bytes) InterfaceMetric Dhcp     ConnectionState PolicyStore
    ------- --------------                  ------------- ------------ --------------- ----     --------------- -----------
    12      Local Area Connection* 4        IPv4                  1500              25 Disabled Disconnected    ActiveStore
    18      Local Area Connection* 3        IPv4                  1500              25 Enabled  Disconnected    ActiveStore
    1       Loopback Pseudo-Interface 1     IPv4            4294967295              75 Disabled Connected       ActiveStore

    As can be seen, the MTU size of the local adapters (Local Area Connection* X) is 1500.

  2. Set the MTU Size using the following commands:

    Set-NetIPInterface -InterfaceAlias "Interface Name" -NlMtuBytes <New MTU Value>

    Where “Interface Name” is the InterfaceAlias of the Ethernet adaptor to be set. Note that a successfully executed command won’t give any output.

  3. Validate the MTU by running the same command used in step 1.

Using Configuration

  1. Go to the Network connection → “Control Panel\Network and Internet\Network Connections”
    MTU Size_windows set 2

  2. Right-click on the Ethernet Adaptor that the traffic is expected on and select Properties.
    MTU Size_windows set 3

  3. Select “Configure”
    MTU Size_windows set 4

  4. Go to Advanced, look for and select "Jumbo Packet":
    MTU Size_windows set 5

  5. Select the desired size, for example"4088 Bytes", then select "OK".
    MTU Size_windows set 6

  6. In order to validate the changes, use PowerShell as explained above