Telnet is one of the simplest ways to check connectivity on certain ports. This article explains how to telnet to a port to check whether a port is open or closed.
Telnet is a client-server protocol. Network and system administrators use it to configure and administer network devices such as servers, routers, etc. But all information exchanged in a telnet session between a client and server is unencrypted. Currently, this application has been replaced by SSH, which provides the same type of service, but is encrypted.
Nowadays telnet is widely used to verify connectivity to services that are based on TCP protocol. Many people find the challenge of checking if a port is opened to be confusing sometimes. One of the most efficient ways is to use the network protocol Telnet.
Using Telnet to Test Open Ports
Though most users opt to work with graphical interfaces, Telnet is one of the simplest ways to check connectivity on certain ports. Let’s see how we can use the
telnet command to test the TCP port connectivity. The syntax to use it is as follows:
telnet [hostname/IP address] [port number]
Put the IP address or domain name of the server you’re trying to connect to in place of [hostname/IP address] and replace the second brackets [port number] with the port number connection to which you want to test.
As a result of the execution of the command can be:
- “Network is unreachable” if the port is closed or blocked by the firewall.
- “Connection refused” if the service is down/not listening on the specified port, but the port is reachable.
- “Connected to server_ip” if the connection is successful.
For example, to telnet to a port
192.168.0.1 to verify connection, issue the command:
telnet 192.168.0.1 80
If the connection succeeds the result of executing the command would look like this:
Trying 192.168.0.1... Connected to 192.168.0.1. Escape character is '^]'.
Example of unsuccessful connection:
Trying 192.168.0.1... telnet: Unable to connect to remote host: Network is unreachable
Trying 192.168.0.1... telnet: Unable to connect to remote host: Connection refused
Of course, with the
telnet command, you can test not only remote but also localhost services. Just replace the [hostname/IP address] part with
We hope this article was beneficial in learning about how to
telnet to a port to check whether a port is open or not. For more about the
telnet command in Linux, consult its manual page.