Some time it is necessary to increase or decrease timeouts on TCP sockets. You can use /proc/sys/net/ipv4/tcp_keepalive_time to setup new value.
The number of seconds a connection needs to be idle before TCP begins sending out keep-alive probes. Keep-alives are only sent when the SO_KEEPALIVE socket option is enabled. The default value is 7200 seconds (2 hours).
For example set value to 2400 seconds:
echo 2400 > /proc/sys/net/ipv4/tcp_keepalive_time
You can make changes to /proc filesystem permanently using /etc/sysctl.conf
Further reading
- See man page of ip(7) and tcp(7) for more details.
- Securing and Optimizing Linux book (by OpenNA), network optimization chapter
🐧 Please support my work on Patreon or with a donation.
🐧 Get the latest tutorials on Linux, Open Source & DevOps via:
🐧 Get the latest tutorials on Linux, Open Source & DevOps via:
- RSS feed or Weekly email newsletter
- Share on Twitter • Facebook • 2 comments... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
Thanks!
Thank you for this note.
But I still have a question
tcp_keepalive_time means that socket connection will be killed in 2 hours (by default) in any case or if socket connection is not active (messages are not sending)?