2

I have been looking at tcp-keepalive as a possible solution for network inactivity. As shared in -

http://www.tldp.org/HOWTO/TCP-Keepalive-HOWTO/overview.html

specifically this part -

Preventing disconnection due to network inactivity

Mine are actually ISP issues but do want to keep it bare minimum from my side.

I have done and changed -

  # echo 600 > /proc/sys/net/ipv4/tcp_keepalive_time

  # echo 60 > /proc/sys/net/ipv4/tcp_keepalive_intvl

  # echo 20 > /proc/sys/net/ipv4/tcp_keepalive_probes

but as shared these are just for this session. Is there a persistent solution for this ?

2 Answers 2

5

You have a persistent parameters ,and you can add the following lines to your /etc/sysctl.conf :

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

Then type:

# sysctl -p
1

Modern Linux systems allow you to use configuration fragments in /etc/sysctl.d. Add a file like 50-keepalive.conf in this directory. Add the appropriate systemctl values.

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

These values will be set on the next reboot. Make sure your interval is less than the timeout period of any firewall you are passing through.

Use the command man sysctl to get information on how to use sysctl to check and modify your configuration.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.