Set MTU Size from the Command Line of Mac OS X

Jan 14, 2013 - 18 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. 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.

.

Related articles:

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

18 Comments

» Comments RSS Feed

  1. Apples says:

    I have a 2016 MacBook Pro with touchbar.

    I tried setting mine to 8000 as my internet speed is 400 Mbps and I wanted to test it. The ping tests came out fine; no errors there (ping -D -s 1500 site.com) . It would support the 8000, but when I entered “networksetup setMTU en0 8000″ I received the following terminal error:

    Error — 8000 is not in the valid MTU range of 1280-1500”

  2. Mainuddin says:

    Mac pro Sierra 10.12.2 is it Apple Update Drivers problem of Wi-fi?
    Bcoz my mac is Dropping Wi-fi connection and not connect to sophos AC100 Access Point after 10.12.2 Apple update on my mac.
    how to solve it this problem

  3. Kevin says:

    Mac OSX 10.10.5

    The GUI says Jumbo Frames is enabled but an ifconfig stills says 1500. Is anybody else getting this error?

    networksetup -setMTU en0 9000
    “Error – 9000 is not in the valid MTU range of 1280-1500”

    • ilundaie says:

      My results of network setup … en0 also gave me 9000 even though in network config I chose custom and chose 1300. In fact before this forum I thought I was at 1500 but when I did networksetup -setMTU en0 showed opposite was true. in terminal however when i execute network setup -getMTU en0 I get 1453, because i set it as per the forum above. Which one is true I don’t know but as it stands now (five minute of trying) my network doesn’t hang, woohoo!, I have no idea where iMac wifi got 9000 from, I did not set it as far as I can remember.

  4. Jason says:

    Does not work. Error: The amount of parameters was not correct.

  5. MacMar says:

    With Yosemite 10.10.2 reliable wi-fi is a big issue on my MacBook Pro. A great resolution is changing the MTU size. Well the MTU 1453 was a improvement, but I can say from some experience that using a even number like 1452 came up with even better results.

    I Hope Apple will fix the crappy Wifi driver or stack.

  6. Mirko says:

    MTU 1453 solved my VERY slow Wifi performance with the Synology DS413j. Like magic… can’t believe it…

  7. Jack Bunce says:

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

    It stands for “Maximum TransMISSION Unit”

  8. 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?

  9. Rich W. says:

    …what Sayed Ahmed said ;-)

  10. 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

  11. 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.

  12. 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…

    • Chris Quirk says:

      If you have to keep doing this regularly, there’s something very wrong. Oh, I see, you’re using Windows.

Leave a Reply

 

Shop on Amazon.com and help support OSXDaily!

Subscribe to OSXDaily

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

Tips & Tricks

News

iPhone / iPad

Mac

Troubleshooting

Shop on Amazon to help support this site