Set MTU Size from the Command Line of Mac OS X
MTU stands for Maximum Transmission Unit, and a larger MTU size generally increases efficiency of a network connection because each packet carries more data, but sometimes the default MTU sizes (often 1500) will cause issues with some networks and needs adjusting. If you need to change the MTU size on a Mac, you can do so through the command line, as well as through the System Preference panel. We’ll focus on setting MTU size from the command line in this particular walkthrough.
Changing the MTU size has been a helpful solution to some dropping wi-fi connections in OS X and Mac OS, particularly when the standard troubleshooting protocol of deleting the wireless pref files hasn’t worked to resolve stubborn wi-fi issues.
If you’re in a situation where you need to change the transmission unit size, you can do so easily through the Mac command line by way of the ever-useful networksetup utility. It’s probably important to note that most users will never need to adjust this setting, making this a more advanced tip. Let’s start with getting the current MTU size from the command line on a Mac, then move on to setting a new MTU size.
How to Get Current MTU Size on Mac via Command Line
To see the current MTU size, use the following networksetup flag, pointing it at the network interface like so:
networksetup -getMTU en1
Unless it has been changed, the default MTU size in Mac OS X is 1500 and will be reported back like so:
Active MTU: 1500 (Current Setting: 1500)
As 1500 is the default, we’re going to change the MTU size.
How to Change MTU Size on Mac by Command Line
To change and set a new MTU size, you can use the -setMTU flag with the networksetup command line, then choose the interface, and provide a new MTU size, like so:
networksetup -setMTU en0 1453
en0 in this case is the wi-fi interface of a MacBook Air without an ethernet port, and 1453 is the MTU setting chosen for the example because it’s the magic number that resolved a persistent wireless dropping problem with some Macs.
You can verify the change took place by using the -getMTU flag again to verify the number.
For the change to actually take effect, you will probably want to cycle the wi-fi connection off and on which can also be done through networksetup at the command line, or through the wi-fi dropdown menu on a Mac, though that isn’t always necessary.