Permanently set MTU on Ubuntu 14.04 machine within an Amazon VPC

amazon-vpcmtuubuntu-14.04

I have some Ubuntu 14.04 machines running in an Amazon VPC. When they start, they have an MTU of 9001, but this appears to cause some problems when communicating with other servers which have an MTU of 1500. When I use ip link set dev eth0 mtu 1500 these problems go away.

The problem is I can't seem to hit upon the correct way to make this permanent.

/etc/network/interfaces.d/eth0.cfg looks like this

auto eth0
iface eth0 inet dhcp
pre-up /sbin/ip link set dev eth0 mtu 1500

I've also tried adding mtu 1500 to bottom of that stanza too.

If I reboot, the machine comes back up with an MTU of 1500.

So what's the correct way to do this?

Best Answer

Ran Rubinstein got me on the right track with this ubuntu forum thread.

The MTU is being set by DHCP, but we can override that with some changes to /etc/dhcp/dhclient.conf - here's how mine looks

option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;

send host-name = gethostname();

#added these two lines before the request line
default interface-mtu 1500;
supersede interface-mtu 1500;

request subnet-mask, broadcast-address, time-offset, routers,
        domain-name, domain-name-servers, domain-search, host-name,
        dhcp6.name-servers, dhcp6.domain-search,
        netbios-name-servers, netbios-scope, interface-mtu,
        rfc3442-classless-static-routes, ntp-servers,
        dhcp6.fqdn, dhcp6.sntp-servers;

Having added these lines, I rebooted the machine to double check, and it came up with an MTU of 1500