Though in general it is not necessary there are (rare) occasions when it is necessary to set the MTU size explicitly, generally caused by issues with path MTU discovery.
In general you want to avoid this as using a smaller MTU size that necessary as the overheads associated with each network packet will reduce network throughput.
RedHat/CentOS
To set the MTU size in RedHat or CentOS you need to edit the appropriate network configuration file for you network device and add an entry for the MTU size. The name of the configuration file depends on the name of the network interface so for eth0 the filename is ifcfg-eth0.
Note – On RedHat or CentOS version 7.x you will also need to comment out any IPv6 options and modify the DHCP client configuration unless you are using a static IP address.
DEVICE=eth0
#BOOTPROTO=dhcp
ONBOOT=yes
IPADDR=192.168.0.1
NETMASK=255.255.255.0
GATEWAY=192.168.0.254
#USERCTL=no
#NM_CONTROLLED=yes
MTU=1492
For this change to take effect you need to reboot or stop and restart the network.
OR
# ifup eth0
Obviously if you are using ssh you will get disconnected when you stop the network!
Debian/Ubuntu
How you achieve the same thing on a Debian based distributions depends on whether or not you are using DHCP
If you have a static address you can specify the MTU size along with the network address and subnet in /etc/network/interfaces, but this won’t work if you are using DHCP as Debian assumes that the MTU size will be supplied by the DHCP server when the client requests a DHCP lease.
iface eth0 inet static
address 192.168.0.2
netmask 255.255.255.0
MTU=1492
You can workaround this problem by specifying a command that should be run automatically after the interface comes up at the end of that interface section.
:
:
post-up /sbin/ifconfig eth0 mtu 1500
Then you need to either reboot or stop and restart the network.
If your interface has IPv6 configuration (which is enabled by default), you must also change IPV6_MTU= to new value otherwise it won’t work.
mike632t: This only applies if you don’t comment out the IPv6 options (see note in text).