MTU on server accidentally set to 0, can't ssh into it?

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?


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


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.