MTU Setting in Linux

Few months back, I did some analysis in my home Internet traffic to understand the packet size distribution. During this process, I saw many packets were fragmented. As I am working in the telecomm field, quickly understood that, this is due to the PPPoE and DSL over-head added by the modem. The solution is, I have to reduce the interface MTU (Maximum Transmission Unit) size from 1500 to (1500 – X). So that, no need to fragment the packets in the intermediate devices like ADSL modem.

Using the PING command, I generated different sizes of ICMP packets (between 1400 to 1500) and find the X value, for which I got a ICMP reply with-out DF bit.

$ ping -M do -s 1510 google.com
PING google.com (74.125.224.176) 1510(1538) bytes of data.
From 10.13.150.32 icmp_seq=1 Frag needed and DF set (mtu = 1500)
From 10.13.150.32 icmp_seq=1 Frag needed and DF set (mtu = 1500)

X is 1432 and set the new MTU value to the eth0 interface by adding the following line in /etc/rc.local file.

ifconfig eth0 mtu 1432

But it is not helped me. Because the MTU value is set to default value after the DHCP negotiation (may be due to the NM). Next I tried to set the new MTU value using pre-up option in /etc/network/interfaces file. Success! now I am able to set the new MTU size properly.

auto eth0
iface eth0 inet dhcp
    pre-up /sbin/ifconfig $IFACE mtu 1432

But, due this change in interface file, Network Manager remove this eth0 interface from automatic configuration interface list. Once the system booted, I have to manually run the dhclient to get the DHCP IP. It is painful, when my wife / son is using the system.

So I am forced to find out a work-around for this issue. After reading the network manager and interfaces documents, man and web pages, I found a solution and modified the interfaces file, like below, to cheat the Network Manager:

auto eth0=eth0BCM
iface eth0BCM inet dhcp
    pre-up /sbin/ifconfig $IFACE mtu 1432

Again I made a mistake by marking eth0 as “auto”. Due to this, during booting stage itself the dhclient will run, with-out checking the link status, and  try to get the IP from DHCP Server. If no link, the boot process will be blocked for nearly 45 to 60 sec. To avoid this issue, I marked the interface as hot-plug like below:

allow-hotplug eth0=eth0BCM
iface eth0BCM inet dhcp
    pre-up /sbin/ifconfig $IFACE mtu 1432

One thought on “MTU Setting in Linux

  1. UPDATE: Now a days, it is very simple, just Right Click on the Network Manager and Edit Connections…, modify the MTU of specific interface 🙂

Leave a comment