The MTU (Maximum Transmission Unit) determines the packet size sent to the client machine or network. The size of the packet decides the data which the packet can carry to the client machine or the network. By default, this value is 1500, but it can be increased to improve data transmission efficiency.
This blog will explain the different methods of changing the MTU size in Linux-based distributions.
Method 1: How to Change the MTU Size in Linux With the ifconfig Command?
We can check and change the MTU size in Linux with the ifconfig command. First, we will display the size of the MTU with the ifconfig command by following the general syntax:
$ ifconfig [interface] | grep mtu
Check the MTU Size in Linux
To check out the information of the “enp0s3” interface, then we will run the below command:
$ ifconfig enp0s3 | grep mtu
The MTU size is 1500 which can be changed by following the general syntax:
Change the MTU Size in Linux
To change the MTU size in Linux system, the basic syntax is provided as below:
$ ifconfig [interface] mtu [size]
For instance, we want to change the MTU size of “enp0s3” from “1500” to “2000”, then we will run the command:
$ sudo ifconfig enp0s3 mtu 2000
Verify the MTU Size in Linux
Verify the changes in the size of MTU in the following screenshot:
$ ifconfig enp0s3 | grep mtu
The MTU size has been changed from “1500” to ‘2000” using the “ifconfig” command.
Method 2: How to Change the MTU Size in Linux With the ip Command?
The ip command is used to manage the information of the network interfaces. The ip command can also be used to change the MTU size.
Check the MTU Size in Linux
To display the MTU size, utilize the “ip” command as seen in the following syntax:
$ ip link show dev [interface]
For example, we display the MTU size of the “enp0s3” network interface with the ip command:
$ ip link show dev enp0s3
Change MTU Size in Linux
This size can be changed with the ip command by following the general syntax:
$ ip link set dev [interface] mtu [size]
For example, we will change back the MTU size to the default using the ip command:
$ sudo ip link set dev enp0s3 mtu 1500
Verify the MTU Size in Linux
To confirm the changes, we will run again the command:
$ ip link show dev enp0s3
The MTU size has been changed to 1500 successfully.
How to Change the MTU Size Permanently in Linux?
The methods mentioned above change the size of the MTU instantly. To permanently change the MTU size, open the /etc/dhcp/dhclient.conf with the nano text editor:
$ nano /etc/dhcp/dhclient.conf
Find the line “send host-name = gethostname();“ and after this line, add the lines mentioned below:
default interface-mtu 1700;
supersede interface-mtu 1700;
Change 1700 with the MTU size you want to set permanently for the Linux and then restart the NetworkManager to save the changes:
$ sudo systemctl restart NetworkManager
After this, the MTU size has been changed to 1700 permanently.
Conclusion
To change the MTU size instantly in Linux distributions, the ip and ifconfig commands can be used. The users must manipulate the network configuration file to make the changes permanently. This blog has demonstrated all the methods for changing the MTU size. Different examples are used to demonstrate the changing size of the MTU.