×


How to change MTU size in Linux ?

MTU (Stands for Maximum Transmission Unit) is the maximum size of the packet that can be transmitted from a network interface. All the devices including servers and switches/routers involved in communication should have the same MTU size. Large MTU size has less overhead associated with it while the smaller MTU has less delay.
The default MTU size in most of the Ethernet networks is 1500 bytes. However, you can change it as per the requirements.

Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to fix Linux related queries.
In this context, we shall look into how to change MTU size in Linux.

More information about MTU in Linux ?

MTU (Maximum Transmission Unit) is related to TCP/IP networking in Linux/BSD/UNIX oses. It refers to the size (in bytes) of the largest datagram that a given layer of a communications protocol can pass at a time.
The default MTU size on Linux is 1500 bytes.

How to view the Current MTU Size ?

In order to view the current MTU size of your ethernet interface, use the ifconfig command as follows:

$ ifconfig | grep mtu

The output will show the current MTU size of the interface.

Alternatively, you can also use the “ip a” command to view the current MTU size:

$ ip a | grep mtu

How to temprarily modify the MTU Size – Using ifconfig command ?

We can use the ifconfig command to change the MTU size of a system's network interface. However, remember that this change does survive a reboot and returns to the default value i.e. 1500.
To change the MTU size of an interface, use the following syntax:

$ ifconfig <Interface_name> mtu <mtu_size> up

For instance, to change the MTU size of an interface named ens33 to 1000 bytes, the command would be:

$ ifconfig ens33 mtu 1000 up

After running the above command, the MTU size changes instantaneously. This change even does not require a service restart.


You can verify the new MTU size by running the following command in Terminal:

$ ifconfig | grep mtu


How to Permanently change the MTU Size in Linux ?

The ifconfig command instantaneously changes the MTU size but this change does not survive a system reboot. Here, we will see how to permanently change the MTU size.
In dynamic IP addressing, the MTU size is set by DHCP. So will need to configure the DHCP configuration file located at /etc/dhcp/dhclient.conf. For static IP address, we will make changes in the network interface configuration file located at /etc/network/interfaces.

How to use /etc/dhcp/dhclient.conf file?

If the DHCP server is running on your system and the network interfaces are configured to receive the IP addresses from it, then use /etc/dhcp/dhclient.conf file to change the MTU size.

i. Edit the nano /etc/dhcp/dhclient.conf using the following command:

$ sudo nano /etc/dhcp/dhclient.conf

ii. Then add the following lines below the “send host-name = gethostname(); line:

default interface-mtu <mtu_size>;
supersede interface-mtu <mtu_size>;

For instance, to set the MTU size to 1400, we will add:

default interface-mtu 1400;
supersede interface-mtu 1400;

iii. If you have multiple interfaces and you want to change the MTU size of just one interface, then enclose it in the braces as follows:

interface "interface_name" {
default interface-mtu <mtu_size>;
supersede interface-mtu <mtu_size>;
}

iv. Once you have configured the file, save, and close it.

v. Now restart the networking service using the following command in Terminal:

$ sudo service networking restart

vi. Also, bring up the interface using the following command:

$ sudo ifup <interface_name>

Make sure to replace the <interface_name> with the actual network interface on your system e.g ens33, eth0, eth1, etc.
In our case, it would be:

$ sudo ifup ens33

vii. Now issue the following command in Terminal to verify if the MTU size has changed successfully.

$ sudo ifconfig | grep mtu

How to use /etc/network/interfaces file ?

If your network interface is configured to obtain a static IP address, then you can change the MTU size by configuring the /etc/network/interfaces file.

i. Edit the /etc/network/interfaces file using the following command in Terminal:

$ sudo nano /etc/network/interfaces

ii. Append the below line in the file:

post-up /sbin/ifconfig <interface-name> mtu <mtu_size>

Make sure to replace <interface-name> with the actual interface name and <mtu_size> with the MTU size you want to set on the network interface.

For instance, to change the MTU size of an interface named ens33 to 1300 bytes, the command would be:

post-up /sbin/ifconfig ens33 mtu 1300 up

iii. Once you have configured the file, save, and close it.

iv. Now restart the networking services using the following command in Terminal:

$ sudo service networking restart

v. Also, bring up the interface using the following command:

$ sudo ifup <interface_name>

Make sure to replace the <interface_name> with the actual network interface on your system e.g. ens33, eth0, eth1, etc.
In our case, it would be:

$ sudo ifup ens33

vi. Now issue the following command in Terminal to verify if the MTU size has changed successfully.

$ ip a | grep mtu


[Need urgent assistance to fix Ubuntu related errors? We can help you. ]


Conclusion

This article will guide you on how to change the #MTU size of a #network #interface either temporarily or permanently in your #Linux system. To change the MTU size: 1. Launch a web browser from a computer or mobile device that is connected to your router's network. 2. The user name is admin. The default password is password. 3. Select ADVANCED > Setup > WAN Setup. 4. In the MTU Size field, enter a value from 64 to 1500. 5. Click the Apply button. Your settings are saved.