This document explains how to use service tcp-keepalives to clear hung
Before You Begin
There are no specific prerequisites for this document.
This document is not restricted to specific software and hardware
The information presented in this document was created from devices in
a specific lab environment. All of the devices used in this document started
with a cleared (default) configuration. If you are working in a live network,
ensure that you understand the potential impact of any command before using
This topology allows for a remote terminal user to gain access to a
server across a network using an autocommand telnet in the configuration of
If, however, Router 2 is reloaded for any reason, the terminal will not
be able to get back into the server. Upon attempting to activate the
connection, the user will see a "Connection refused by remote host" message.
This message appears because the server believes that the previous telnet
session is still connected, thus blocking a new session.
This situation could be remedied by a network administrator by issuing
the clear line command on Router 1, but this
approach has two major shortcomings:
Network administrators may be unavailable to clear the line when
For security reasons, the enable password
command is not likely to be given out to users.
One solution is for Router 1 to clear the TTY line when the connection
to Router 2 is lost for any reason. TCP keepalives can resolve this problem.
Turn on TCP keepalives on both routers so that one router will notice when the
connection to the other router goes away; otherwise, the far end has no way to
know that a reboot or other connection loss has happened. TCP keepalives are
non-configurable on the CLI and the keepalives can be changed through
To enable TCP keepalives on the routers, use the following
Router1# config term
Router1(config)# service tcp-keepalives-in
Router1(config)# service tcp-keepalives-out