Telnet to a Port to Test Network Connectivity

When it comes to checking if a network port is opened or closed, there’s no easier way than to use Telnet.

telnet to a port

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 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. Lets see how we can use 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 specified port, but port is reachable.
  • Connected to server_ip” if connection is successful.

For example, to telnet to a port 80 on 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

or

Trying 192.168.0.1...
telnet: Unable to connect to remote host: Connection refused

Of course, with telnet command you can test not only remote but also localhost services. Just replace the [hostname/IP address] part with localhost or 127.0.0.1.

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 telnet command in Linux, consult its manual page.

Leave a Reply

Your email address will not be published.

Latest from Linux Knowledge