Skip to content

Instantly share code, notes, and snippets.

@ryenus
Created July 14, 2019 17:45
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ryenus/17b251da9244848545ecd37905f1cb15 to your computer and use it in GitHub Desktop.
Save ryenus/17b251da9244848545ecd37905f1cb15 to your computer and use it in GitHub Desktop.
Increase ephemeral port range on macOS

The default ephemeral port range on macOS/OSX is 49152-65535, which is only 16,383 ports:

$ sysctl -a | grep portrange
net.inet.ip.portrange.lowfirst: 1023
net.inet.ip.portrange.lowlast: 600
net.inet.ip.portrange.first: 49152
net.inet.ip.portrange.last: 65535
net.inet.ip.portrange.hifirst: 49152
net.inet.ip.portrange.hilast: 65535

To increase the range, we can reduce the value of first and hifirst:

sudo sysctl -w net.inet.ip.portrange.first=32768
sudo sysctl -w net.inet.ip.portrange.hifirst=32768

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment