2

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?

3
  • Have you done anything besides changing the MTU? I recently started experiencing connection problems on some of my machines with the same setup (14.04, VPC) but changing the MTU doesn't solve them.
    – makhan
    Oct 21, 2014 at 8:52
  • Nevermind, changed MTU to 1400 and it worked. After a bit of experimentation set it to 1468 (highest that works).
    – makhan
    Oct 21, 2014 at 9:25
  • I also made a solution here: askubuntu.com/questions/1245425/pptp-vpn-randomly-disconnects/… maybe help
    – SdSaati
    Aug 14, 2021 at 22:55

2 Answers 2

3

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

1
  • This works for ethernet but in my case I'm failing to connect to the network because the wifi security is failing before DHCP is available. Not quite sure why ubuntu seem to have change my default MTU between 15.04 and 15.10
    – mjaggard
    Nov 12, 2015 at 12:10
1

This discussion: http://ubuntuforums.org/showthread.php?t=1284176 implies that when you have 'auto eth0' the mtu is set by the dhcp server and cannot be overriden in eth0.cfg. They have some suggestions there, but I simply set the mtu in /etc/rc.local

Edit: This bug https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1317811 seems to cover this issue. To prevent the network errors, you need to also run the command:

sudo ethtool -K eth0 sg off

Or you will continue to have errors.

1
  • giving you an upvote as that link did resolve it for me. Setting in rc.local wouldn't work for me as I think the MTU is getting reset once the machine has been on a few hours.
    – Paul Dixon
    Jul 1, 2014 at 12:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .