10

Recently (I think after updating to 10.6.4) Mac OS X has insisted on changing my MTU to 1500, even though the router which my Mac connects to directly has an MTU of 1472. I've noticed that manually setting the MTU to 1472 drastically increases performance, presumably because it all but eliminates packet fragmentation, but Mac OS X periodically changes the MTU back to 1500.

Does anyone know why or how to stop it?

Chealion
  • 26,327

6 Answers6

8

You can turn off the automatic discovery of MTU size on Mac OS X with this :

  • Session only :

sudo sysctl -w net.inet.tcp.path_mtu_discovery=0

  • Permanent :

    • Edit the file /etc/sysctl.conf, for example :

      sudo nano /etc/sysctl.conf

    • Then add the following line :

      net.inet.tcp.path_mtu_discovery=0

    • Finally reboot

This will prevent Mac OS X from automatically setting the MTU size, but you'll still need to setup your size manually.

Studer
  • 3,816
4

A band-aid solution could be to run the following Terminal command (or run it via AppleScript) everytime you log in:

sudo networksetup -setMTU en1 1472

This won't fix the underlying issue of the MTU reseting. I suggest reporting the bug to Apple via BugReporter.

Chealion
  • 26,327
2

Unfortunately, you did not mention how you set the MTU. Did you already try this?

Mac OS X 10.4 or later: How to change the MTU for troubleshooting purposes

It's the official way to set a non-standard MTU persistently.

knweiss
  • 1,724
2

I set the MTU using the ifconfig command.

ifconfig en0 mtu=1492 

You have to use your own adapter id, mine is en0.

This is the only way it would stay at the set rate. I tried using the "official" method and it always immediately reverted.

I also used the command above to stop using automatic:

net.inet.tcp.path_mtu_discovery=0

I tried it both ways and I had to go to manual in order for this to work.

slhck
  • 235,242
Paul Krupa
  • 21
  • 1
1

I have been doing some network testing here on osx 10.6.7 and discovered that the mtu was always falling to 1500. The Solution here was to turn ON the auto discovery in osx and make sure the router is set to the desired mtu and not auto.

0

Using this command you can see exactly where fragmentation happens:

ping -g 1400 -G 1500 -h 1 -D  www.google.com

Each packet sent will be one byte longer, so the first packet will be 1400 bytes, then next 1401 and so on.

The ping results will show icmp_seq=X where X is the packet number. In other words you take the 1400 from the command plus the icmp_seq number and that's the packet size.

Let it run until it reaches timeout.


To answer your question about why:

I found manually setting the MTU to 1500 the ping command would start to timeout at 1472. But if I set MTU to 1472, then reran the command it would start timeing out around 1444. It feels like OSX is already adjusting packet size to account for the 28byte overhead.

Ro Yo Mi
  • 393