To modify the telnet timeout you need to change the value of the tcp keepalive parameters. Let us first check the default values of TCP keepalive parameter.
# cat /proc/sys/net/ipv4/tcp_keepalive_time 7200 # cat /proc/sys/net/ipv4/tcp_keepalive_intvl 75 # cat /proc/sys/net/ipv4/tcp_keepalive_probes 9
The first two parameters are expressed in seconds, and the last is the pure number. This means that the keepalive routines wait for two hours (7200 secs) before sending the first keepalive probe, and then resend it every 75 seconds. If no ACK response is received for nine consecutive times, the connection is marked as broken. So we need to change the value for the tcp_keepalive_time, to prevent the disconnection after 5 minutes, these changes has to be made in the client side.
The system need to have smaller value in the tcp_keepalive_time, if 7200 secs is two hours, 4 minutes will be 240 secs, the keepalive need to start after four minutes of channel inactivity, and then send probes in intervals of one minute e.g:
# echo 240 > /proc/sys/net/ipv4/tcp_keepalive_time ( this value is below the 5 minutes) # echo 60 > /proc/sys/net/ipv4/tcp_keepalive_intvl # echo 20 > /proc/sys/net/ipv4/tcp_keepalive_probes
Makign Changes Permanent
After getting the right values we can make the changes to be persistent after reboot by adding the parameter values in the configuration file /etc/sysctl.conf:
# vi /etc/sysctl.conf net.ipv4.tcp_keepalive_time = [value] net.ipv4.tcp_keepalive_intvl = [value] net.ipv4.tcp_keepalive_probes = [value]