Set MTU Size from the Command Line of Mac OS X

Jan 14, 2013 - 10 Comments

Set the MTU size in 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. Changing the MTU size has been a solution to some dropping wi-fi connections in OS X, particularly when the standard protocol of deleting the wireless pref files hasn’t worked to resolve stubborn issues.

If you’re in a situation where you need to change the transmission unit size, you can do so easily through the 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.

To see the current MTU size, use the following networksetup flag:

networksetup -getMTU

Unless it has been changed, the default MTU size in OS X is 1500 and will be reported back like so:

Active MTU: 1500 (Current Setting: 1500)

To change that and set a new MTU size, use the -setMTU flag, choose the interface, and provide a new 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, though that isn’t always necessary.

Enjoy this tip? Subscribe to the OSXDaily newsletter to get more of our great Apple tips, tricks, and important news delivered to your inbox! Enter your email address below:

Related articles:

Posted by: William Pearson in Command Line, Mac OS X, Tips & Tricks

10 Comments

» Comments RSS Feed

  1. Dave says:

    I have to do this constantly in Windows to maintain a VPN connection with work. Good information to know, should I ever need it…

  2. Sayed Ahmed says:

    The first terminal command in the example is missing the interface name part for example en0, for example it should be (networksetup -getMTU en0) in case its a macBook Air on WiFi but this en0 might differ based what port you connected to, the best way to know the ports name is go to the network utility and hit info so you can see available interfaces names.

  3. Rich W. says:

    For me, typing “networksetup -getMTU” was not sufficient (on a MacBook Pro running OS X 10.8.2). Terminal instead returned a long list of acceptable networksetup commands.

    So I used “networksetup -listallhardwareports” to confirm that my MacBook was device “en0″.

    Then I used “networksetup -getMTU ” instead, typing:
    networksetup -getMTU en0

    Since this was an advanced tip, this may be common knowledge to advanced users, but others may want to be aware that they might need their device name.

    networksetup -getMTU

  4. Rich W. says:

    …what Sayed Ahmed said ;-)

  5. Andrew says:

    I know this is a “how to terminal”, but is it not just as simple to do this through the GUI in the Network preferences?

    At least on 10.6, 7 and 8 you go to System Preferences – Network.

    Select the device you want to change (WiFi, AirPort or Ethernet usually).

    Choose “Advanced…”

    Select “Ethernet” tab in 10.6 and “Hardware” in 10.8.

    Set “Configure:” to Manually.

    Set “MTU:” to “Custom” and pick your number (it will suggest a number range for you based on the OS you are using).

    • Dave says:

      For the average Mac user, indeed the GUI is simpler. But what’s faster for the advanced user; digging in preferences or a short command string?

  6. Jack Bunce says:

    “MTU stands for Maximum Transition Unit,” No, it doesn’t!

    It stands for “Maximum TransMISSION Unit”

Leave a Reply

 

Shop for Apple & Mac Deals on Amazon.com

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates