Skip to content

Instantly share code, notes, and snippets.

@mthrynn
Forked from Zillionx/OSX_TCP_options.command
Last active June 3, 2024 15:56
Show Gist options
  • Save mthrynn/98e34d4fda5a405b918a6d734ac40977 to your computer and use it in GitHub Desktop.
Save mthrynn/98e34d4fda5a405b918a6d734ac40977 to your computer and use it in GitHub Desktop.
OSX - Tuning the Network Stack TCP
## Quick fix for slow internet after update to OSX 10.11 "El Capitan"
## Changes are not permanent, just restart your mac if it doesn't work.
## write config
sudo su -
sysctl -w net.inet.tcp.doautorcvbuf=0
sysctl -w net.inet.tcp.doautosndbuf=0
sysctl -w net.inet.tcp.win_scale_factor=0
sysctl -w kern.ipc.somaxconn=2048
sysctl -w net.inet.tcp.rfc1323=1
sysctl -w net.inet.tcp.win_scale_factor=4
sysctl -w net.inet.tcp.sendspace=1042560
sysctl -w net.inet.tcp.recvspace=1042560
sysctl -w net.inet.tcp.mssdflt=1448
sysctl -w net.inet.tcp.v6mssdflt=1412
sysctl -w net.inet.tcp.msl=15000
sysctl -w net.inet.tcp.always_keepalive=0
sysctl -w net.inet.tcp.delayed_ack=3
sysctl -w net.inet.tcp.slowstart_flightsize=20
sysctl -w net.inet.tcp.local_slowstart_flightsize=9
sysctl -w net.inet.tcp.blackhole=2
sysctl -w net.inet.udp.blackhole=1
sysctl -w net.inet.icmp.icmplim=50
## read config
sysctl net.inet.tcp.doautorcvbuf
sysctl net.inet.tcp.doautosndbuf
sysctl net.inet.tcp.win_scale_factor
sysctl kern.ipc.somaxconn
sysctl net.inet.tcp.win_scale_factor
sysctl net.inet.tcp.sendspace
sysctl net.inet.tcp.recvspace
sysctl net.inet.tcp.mssdflt
sysctl net.inet.tcp.v6mssdflt
sysctl net.inet.tcp.msl
sysctl net.inet.tcp.always_keepalive
sysctl net.inet.tcp.delayed_ack
sysctl net.inet.tcp.slowstart_flightsize
sysctl net.inet.tcp.local_slowstart_flightsize
sysctl net.inet.tcp.blackhole
sysctl net.inet.udp.blackhole
sysctl net.inet.icmp.icmplim
@jjbailey
Copy link

sysctl -w net.inet.tcp.win_scale_factor=0
then
sysctl -w net.inet.tcp.win_scale_factor=4

I imagine you want the second choice.

@ns-skalagara
Copy link

how do I make these changes persistent ?

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