LLI Wiki — My Digital Knowledge Base

MTU and IP fragmentation: check and change on Windows and Linux

Read, test and change the MTU and detect IP fragmentation with netstat, ping and Wireshark.

An MTU that is too small, or too large for a path, causes IP fragmentation or dropped packets. This note shows how to read and change the MTU on Windows and Linux, how to test a path with the "do not fragment" flag, and how to spot fragmentation.

Read the MTU

Windows:

netsh interface ipv4 show interfaces
netsh interface ipv4 show subinterfaces

The output lists, per interface, the index, metric, MTU, state and name.

Linux:

ip addr | grep mtu

Test the path MTU

Send packets that must not be fragmented. If the size exceeds the path MTU the ping fails.

Linux (8972 = 9000 minus 28 bytes of IP and ICMP headers):

ping -M do -s 8972 <destination_ip>

Windows:

ping -f -l 9000 <destination_ip>

Check whether fragmentation happens

Windows:

netstat -sp ip
netstat -s | findstr Fragm

Linux:

netstat -i
ss -s
netstat --statistics | head -10
nstat

Sample output of netstat --statistics (Ip section):

Ip:
    68728385 total packets received
    1 with invalid headers
    56871060 forwarded
    0 incoming packets discarded
    4093729 incoming packets delivered
    57898402 requests sent out
    65 outgoing packets dropped
    8 fragments dropped after timeout
    3240 reassemblies required

Useful counters are fragments dropped after timeout and reassemblies required. A reference for Linux network statistics: Linux network statistics reference.

In Wireshark, this display filter shows fragmented packets:

ip.flags.mf == 1 or ip.frag_offset gt 0

ip.fragment also matches fragments. A sample capture of fragmented traffic (teardrop.cap) is available on the Wireshark wiki.

Change the MTU

Windows (persistent; the index or interface name comes from the commands above):

netsh interface ipv4 set interface "<idx>" mtu=1500 store=persistent
netsh interface ipv4 set subinterface "Ethernet" mtu=1518 store=persistent

Linux, temporary:

ip link set dev eth0 mtu 1300

Linux, raw datagram size limit:

sudo sysctl -w net.inet.raw.maxdgram=16384

For a persistent sysctl setting, edit /etc/sysctl.conf.

Mastodon LLIMastodon SocialFosstodon