Troubleshooting - using Telnet to test transport layer ports
It is possible to use Telnet to examine the state of particular TCP ports of a remote device, or the state of connectivity in general.
Telnet into a particular destination using the following syntax on a Cisco IOS device:
Even if the connection fails, which it will if there is no Telnet server running on the particular port, the output shown shows you the state of the specific device as well as the specified port. Take a look at the following scenarios:
Router#telnet 10.55.55.55 Trying 10.55.55.55 ... % Connection timed out; remote host not responding
The initial command has no port specified, thus the default port 23 is used for Telnet. This output indicates that there is no connectivity to this device at all. At this point, try using tools such as ping or Traceroute to ensure network connectivity and further troubleshoot.
Router#telnet 172.16.22.252 21 Trying 172.16.22.252, 21 ... % Connection refused by remote host
This command is attempting to Telnet to a remote device using port 21 (FTP). The output shows that network connectivity has been established to the particular IP address. However, the specific port is not open, and that is why it has been "refused by remote host".
Router#telnet 172.16.22.252 80 Trying 172.16.22.252, 80 ... Open
This command is attempting to Telnet to a remote device using port 80 (HTTP). The output shows that network connectivity has been established, and that the port itself is indeed open. The remote host is waiting for some HTTP message to be sent so that it can respond. However, no further output will be seen, since Telnet does not send HTTP messages. This connection can be terminated using Ctrl-C or by waiting for it to time out.
Similar test cannot be run using SSH or other protocols since they don't offer the same type of prompts in response to such commands.
Note that the Telnet protocol is not designed for this, but it is simply "good luck" that engineers decided to make Telnet respond the way it does, so it can be helpful in this way.