Nothing stupid about them...

...I just stole the name from David Letterman's "stupid pet tricks". I hope these tips help you avoid or fix mistakes along the way in your *nix administration duties.

Friday, March 26, 2010

TCP keepalive vs $TMOUT

When a TCP connection times out, it can be annoying at best...and kill applications that depend on the TCP pipe staying up when inactive.

If your shell disconnects after a while, re-log in then enter


$ env | grep TMOUT


If TMOUT is set to non-zero, the session will be disconnected after the number of seconds that TMOUT is set to. If this is an issue, increase TMOUT or set it to zero.

But sometimes you don't have this control over timeouts...idle TCP connections may be configured to drop at the router or firewall level. If you don't have control over those devices, it may be necessary to configure TCP keepalive.

This syntax is for Linux, your OS will be different. Add lines to /etc/sysctl.conf:

net.ipv4.tcp_keepalive_time = 600
net.ipv4.tcp_keepalive_intvl = 60
net.ipv4.tcp_keepalive_probes = 20

then type in

sysctl -p

to get the new values to take effect. The 600 means that keepalive will kick in when the connection has been idle for 10 minutes (600 seconds).

0 comments:

Search

Google