7

My server had some problem with the ssh and I couldn't upload files of size > 10 KB, as scp would hang during the copy. I found a solution for this problem here, and I was changing the MTU, when I accidentally did sudo ip link set eth0 mtu 0.

No one can ssh into the server now. What should I do?

3
  • 1
    If you have IPv6 enable, try to ssh using it.
    – Agares
    Dec 15, 2014 at 11:15
  • 1
    @Agares That's a useful suggestion for a lot of network misconfigurations. But MTU changes apply to both IPv4 and IPv6. If the MTU is decreased below the minimum required by the protocol, both IPv4 and IPv6 are disabled. Increasing the MTU again is not sufficient to get the disabled protocol re-enabled.
    – kasperd
    Dec 21, 2014 at 22:41
  • Well, then sorry for misguiding.
    – Agares
    Dec 22, 2014 at 20:05

2 Answers 2

22

Connect to the console and change the MTU back. If you've not got console access, then reboot the server.

1
  • 1
    Couldn't connect to the console. Rebooting fixed the problem... Thanks! Dec 15, 2014 at 8:25
7

It is not clear which operating system you are using. I have tested your specific command on two different versions of Linux, and each of them gave me an error message:

RTNETLINK answers: Invalid argument

If you have found a system that will actually allow you to set the MTU to 0, I would consider that a kernel bug. It is however plausible that systems exist, where setting the MTU to 0 has some other meaning such as auto detect the MTU.

IPv4 requires that all nodes have an MTU of at least 68. Linux knows this and disables IPv4 on the interface if the MTU is set to a lower value like for example 67. That way it is possible to lock yourself out of the system. That's inconvenient, and I would have considered it to have been a better design, if the kernel would reject the MTU change as long as the interface had any IP address requiring a higher MTU.

Should you accidentally disable both IPv4 and IPv6 on a network interface, it is unlikely you are going to find any way to remotely administrate the machine across that network interface. If the server has any other network interfaces, you may be able to access it that way. Even if the other network interface has not been configured it may still have an IPv6 link local address which one could ssh to from a different host on the same segment. Otherwise a serial console is still an option, as a serial console is completely independent of the network configuration of the host. Ultimately you can reboot the machine, if you have access to do so remotely. As long as you didn't write the erroneous change to any configuration files, a reboot should fix it.

7
  • 1
    I am running an Ubuntu instance on AWS. The same error came up when I did ip link set eth0 mtu 0, but once I did sudo on the same, it changed the MTU without any warning, and locked me out of the ssh. However, setting MTU this way seems to be some sort of temporary change, as a reboot fixed the problem. Dec 15, 2014 at 9:31
  • 1
    @ForbiddenOverseer The reason this is a temporary change is because you did not actually commit your settings change to your config files.
    – Reaces
    Dec 15, 2014 at 9:48
  • 2
    @ForbiddenOverseer I have a Ubuntu 12.04 system I can try to reproduce it on. But I won't test it until the next time I have physical access to the machine (for obvious reasons). My 12.04 system is running a newer kernel than yours, no idea if that makes any difference.
    – kasperd
    Dec 15, 2014 at 10:15
  • 2
    @kasperd screen then sudo -i then ip link set eth0 mtu 0 ; sleep 30 ; ip link set eth0 mtu 1500 maybe? (Or whatever MTU value you prefer.) If it breaks, it will automatically recover after half a minute. But I would still be reluctant to test it on any critical system... then again, an Ubuntu 12.04 instance seems unlikely to be critical these days.
    – user
    Dec 15, 2014 at 12:59
  • 3
    @MichaelKjörling Setting the MTU to 67 turns off IPv4 on the interface. Increasing the MTU does not automatically turn IPv4 on again. Obviously this isn't a critical system, because I wouldn't even consider testing that MTU change if it was a critical system. That said, Ubuntu 12.04 is still supported, so I wouldn't consider upgrading a critical system from 12.04 unless I needed some of the new features available in 14.04.
    – kasperd
    Dec 15, 2014 at 14:27

You must log in to answer this question.

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