MTU must be set in same ifconfig command as IP
Where MTU on an interface is user-defined, the ifconfig command that assigns the IP and IPv6 addresses must include the MTU. For instance, this:
ifconfig vmx1 mtu 9000 ifconfig vmx1 inet 192.168.1.1 netmask 255.255.255.0
You'll end up with the NIC at MTU 9000, but the link route for 192.168.1.0/24 will be 1500. Doesn't matter if the MTU is set before or after the IP, this is the case.
If you instead run:
ifconfig vmx1 inet 192.168.1.1 netmask 255.255.255.0 mtu 9000
Then both the interface and the link route have the correct MTU. This affects IPv6 the same way, with the same resolution.
Fixes #4397 Make mtu configuration before the ip address assignment. This fixes the issues of link routes having the wrong mtu configured on them.
#5 Updated by Ermal Luçi about 4 years ago
This should work as is on 2.2 in FreeBSD head it has been fixed with:
Finish r274175: do control plane MTU tracking. Update route MTU in case of ifnet MTU change. Add new RTF_FIXEDMTU to track explicitly specified MTU. Old behavior: ifconfig em0 mtu 1500->9000 -> all routes traversing em0 do not change MTU. User has to manually update all routes. ifconfig em0 mtu 9000->1500 -> all routes traversing em0 do not change MTU. However, if ip_output finds route with rt_mtu > interface mtu, rt_mtu gets updated. New behavior: ifconfig em0 mtu 1500->9000 -> all interface routes in all fibs gets updated with new MTU unless RTF_FIXEDMTU flag set on them. ifconfig em0 mtu 9000->1500 -> all routes in all fibs gets updated with new MTU unless RTF_FIXEDMTU flag set on them AND rt_mtu is less than ifp mtu. route add ... -mtu XXX automatically sets RTF_FIXEDMTU flag. route change .. -mtu 0 automatically removes RTF_FIXEDMTU flag. PR: 194238 MFC after: 1 month CR: D1125