Check MTU Size in Linux: 5 Commands
To check the MTU (Maximum Transmission Unit) size of a network interface in Linux, use the ip link show command or the older ifconfig command. Both display the current MTU value for each interface, and you can change it with ip link set or ifconfig.
What Is MTU and Why Does It Matter?
MTU stands for Maximum Transmission Unit. It is the largest packet size, in bytes, that a network interface can transmit without fragmentation. The default MTU on most Ethernet interfaces is 1500 bytes. This value includes the IP header and payload but excludes the Ethernet frame header and trailer. If a packet exceeds the MTU, it is either fragmented or dropped, depending on the protocol and the “Don’t Fragment” flag. A proper MTU reduces fragmentation, lowers latency, and avoids packet loss, especially on VPNs, PPPoE connections, or jumbo frame networks.
How to Check MTU Size
Here are the most common commands to view MTU values:
ip link show– shows all interfaces with their MTU (e.g.,mtu 1500).ip addr show– same as above but also includes IP addresses.ifconfig -a– displays MTU for all interfaces (if net-tools is installed).cat /sys/class/net/<interface>/mtu– prints just the numeric MTU for a specific interface.ping -M do -s <size> <host>– tests the maximum packet size that passes without fragmentation.
For example, to check the MTU of eth0, run:
ip link show eth0
Output will include a line like mtu 1500. To see only the number, use:
cat /sys/class/net/eth0/mtu
How MTU Is Determined
MTU is usually set by the driver or by DHCP during network configuration. On a typical Ethernet LAN, it is 1500 bytes. However, some technologies require a lower MTU:
- PPPoE (common on DSL) – 1492 bytes (1500 minus 8 bytes for PPPoE header).
- VPN tunnels (IPsec, OpenVPN) – often 1400 or 1200 to accommodate encapsulation overhead.
- Jumbo frames (data centers) – 9000 bytes or more.
- Wireless (Wi-Fi) – can be 2304, but often set to 1500 for compatibility.
If the MTU is too high for a link, packets get fragmented or dropped, causing slow performance or connection failures. Too low, and you waste bandwidth on extra headers.
How to Change MTU Size
To temporarily change the MTU of an interface, use:
sudo ip link set dev eth0 mtu 1400
For a permanent change, edit the network configuration file. On Debian/Ubuntu (netplan), add mtu: 1400 under the interface in /etc/netplan/*.yaml. On RHEL/CentOS, set MTU=1400 in /etc/sysconfig/network-scripts/ifcfg-eth0. On systemd-networkd, add MTUBytes=1400 in the .network file. After changing, restart the network service or reboot.
Finding the Optimal MTU with Ping
To find the largest MTU that works without fragmentation, use the ping command with the “Don’t Fragment” flag. The idea is to send a packet of a certain size and see if it gets through.
- Start with a payload size that equals the MTU minus 28 (20 bytes IP header + 8 bytes ICMP header). For MTU 1500, that is 1472.
- Run:
ping -M do -s 1472 <gateway> - If it succeeds, increase the size (e.g., 1473, 1474) until it fails.
- The last successful payload size + 28 is your effective MTU.
For example, if ping -M do -s 1472 works but 1473 fails, the MTU is 1500. On a PPPoE link, the maximum payload might be 1464 (MTU 1492).
Common MTU Problems and Misconceptions
One common misconception is that MTU must be 1500 everywhere. In reality, the MTU along the entire path matters. If any hop has a smaller MTU, packets may be dropped unless fragmentation is allowed. This is often the cause of “black hole” issues where small packets work but large ones fail (e.g., web pages load but downloads stall). Another misconception is that increasing MTU always improves performance. On networks that don’t support jumbo frames, a higher MTU causes errors.
Another issue: changing MTU on a single interface may not affect the path MTU discovery (PMTUD) if ICMP messages are blocked. Tools like tracepath can help find the path MTU.
MTU vs. MSS
MSS (Maximum Segment Size) is often confused with MTU. MSS is the largest TCP payload size, and it is typically MTU minus 40 bytes (20 IP + 20 TCP). For MTU 1500, MSS is 1460. When you reduce MTU, you should also adjust MSS accordingly. Many firewalls and routers automatically clamp MSS to avoid fragmentation.
Frequently Asked Questions
How do I check MTU on a specific interface like wlan0?
Use ip link show wlan0 or cat /sys/class/net/wlan0/mtu. Both give the current MTU.
What is the default MTU on Linux?
For Ethernet, the default is 1500 bytes. For loopback (lo), it is 65536. Other interfaces may have different defaults depending on the driver.
Why does my VPN need a lower MTU?
VPN encapsulation adds extra headers (e.g., IPsec adds 50-60 bytes). If the underlying MTU is 1500, the total packet exceeds it, causing fragmentation. Lowering the MTU to 1400 or 1200 avoids this.
How can I test if my MTU is causing problems?
Run ping -M do -s 1472 google.com. If it fails, try smaller sizes. If you get replies at 1472 but large transfers stall, the issue might be path MTU discovery.
Does changing MTU require a reboot?
No, the ip link set command takes effect immediately. But it resets after reboot unless you make it permanent in config files.
What is the maximum MTU for jumbo frames?
Typically 9000 bytes, but some hardware supports up to 9216. Check your NIC and switch specifications.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.