Converting interfaces to jumbo frames

When converting to Jumbo Frames from a standard MTU the tap and tunnel devices will need to be updated to use the new larger MTU. Tap devices and tagged interfaces will have an MTU of 1450 if they were created using an L3 network before the conversion to Jumbo frames was completed.

To adjust the MTU for these devices run the following command.

for i in $(ip a l  | grep 'mtu 1450' | awk -F':' '{print $2}'); do
  ip link set dev $i mtu 8950
done

If you're working with distributed systems and have access to Ansible, this cute little one-liner can help do the MTU conversion everywhere.

ansible hosts -m shell -a "for i in \$(ip a l  | grep 'mtu 1450' | awk -F':' '{print \$2}'); do ip link set dev \$i mtu 8950; done" --forks 50

If you're running in an environment that uses containers and your not wanting to update all of the interfaces to use jumbo frames you can use this simple script to find specific interfaces and update the MTU.

#!/bin/bash

function mtu_update {
  INTERFACE="$(echo ${1} | awk -F'@' '{print $1}')"
  MTU="$2"
  echo -e "interface: ${INTERFACE} set: ${MTU}"
  ip link set dev ${INTERFACE} mtu ${MTU}
}

for i in $(ip a l | grep -e 'br-' -e 'tap' -e 'bond' | grep 'mtu 1500' | awk -F':' '{print $2}' | grep -v '_'); do
  mtu_update "${i}" "9000"
done

for i in $(ip a l | grep -e 'br-' -e 'tap' -e 'bond' | grep 'mtu 1450' | awk -F':' '{print $2}' | grep -v '_'); do
  mtu_update "${i}" "8950"
done

Running this across a cluster is simple when using a tool like Ansible. The script module is very handy for this exact purpose.

ansible -m script -a /tmp/mtu-fix all --forks 50