CentOS / RHEL : How to adjust the telnet timeout (and how to disable it)
The problem
1. How to modify the telnet timeout period?2. Telnet connection is disconnected after some idle time. How to disable the timeout in telnet?
The Solution
Using the tcp_keepalive_time parameter
To modify the telnet timeout you need to change the value of the parameter tcp_keepalive_time. Below is the details of the parameter from the man page of tcp.# man tcp tcp_keepalive_time (integer; default: 7200; since Linux 2.2) The number of seconds a connection needs to be idle before TCP begins sending out keep-alive probes. Keep-alives are sent only when the SO_KEEPALIVE socket option is enabled. The default value is 7200 seconds (2 hours). An idle connection is terminated after approximately an additional 11 minutes (9 probes an interval of 75 seconds apart) when keep-alive is enabled.
# sysctl -a | grep tcp_keepalive_time
net.ipv4.tcp_keepalive_time = 7200
2. To set a new value of the tcp_keepalive_time parameter, use the below command.
# echo 3600 > /proc/sys/net/ipv4/tcp_keepalive_time
# vi /etc/sysctl.conf net.ipv4.tcp_keepalive_time = 3600
# sysctl -p net.ipv4.tcp_keepalive_time = 3600
Using the TMOUT environment variable
You can also adjust timeout by using ‘TMOUT=’ environment variable. If you don’t want to use auto logging out, please put the below in ~/.bashrc file of the respective user.# export TMOUT=0