Search code examples
sysctl

error setting net.ipv4.tcp_tw_reuse & net.ipv4.tcp_tw_recycle in sysctl.conf


I tried setting the following in my /etc/sysctl.conf file to try and help with a MySQL port exhaustion issue:

net.ipv4.tcp_tw_reuse = true
net.ipv4.tcp_tw_recycle = true

But I get an error when running sysctl -p:

sysctl: setting key "net.ipv4.tcp_tw_reuse": Invalid argument
sysctl: setting key "net.ipv4.tcp_tw_recycle": Invalid argument

I also tried setting it this way, with no arguments:

net.ipv4.tcp_tw_reuse
net.ipv4.tcp_tw_recycle

And I get this response back on executing sysctl -p:

sysctl: /etc/sysctl.conf(31): invalid syntax, continuing...
sysctl: /etc/sysctl.conf(32): invalid syntax, continuing...

Can someone please tell me how to set these values correctly?

Thanks


Solution

  • So that syntax is for the linux kernel, and you would use 1 or 0 for true/false, not the actual spelled out words. So in your example, it would be:

    net.ipv4.tcp_tw_reuse = 1
    net.ipv4.tcp_tw_recycle = 1
    

    If you're trying to adjust this setting in OSX on your Mac, then it's a different syntax. It would be:

    net.inet.tcp.msl=1000
    

    Hope that helps.