Telnet to a Port to Test Network Connectivity

Telnet is one of the simplest ways to check port connectivity. Learn how to telnet to a port to check whether a port is open or not.

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]Code language: CSS (css)

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 80 on 192.168.0.1 to verify connection, issue the command:

telnet 192.168.0.1 80Code language: CSS (css)

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 '^]'.Code language: JavaScript (javascript)

Example of unsuccessful connection:

Trying 192.168.0.1...
telnet: Unable to <a href="https://linuxiac.com/ubuntu-remote-desktop/">connect to remote host</a>: Network is unreachableCode language: HTML, XML (xml)

or

Trying 192.168.0.1...
telnet: Unable to connect to remote host: Connection refusedCode language: CSS (css)

Of course, with the 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.

Conclusion

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.

Bobby Borisov

Bobby Borisov

Bobby, an editor-in-chief at Linuxiac, is a Linux professional with over 20 years of experience. With a strong focus on Linux and open-source software, he has worked as a Senior Linux System Administrator, Software Developer, and DevOps Engineer for small and large multinational companies.

Think You're an Ubuntu Expert? Let's Find Out!

Put your knowledge to the test in our lightning-fast Ubuntu quiz!
Ten questions to challenge yourself to see if you're a Linux legend or just a penguin in the making.

1 / 10

Ubuntu is an ancient African word that means:

2 / 10

Who is the Ubuntu's founder?

3 / 10

What year was the first official Ubuntu release?

4 / 10

What does the Ubuntu logo symbolize?

5 / 10

What package format does Ubuntu use for installing software?

6 / 10

When are Ubuntu's LTS versions released?

7 / 10

What is Unity?

8 / 10

What are Ubuntu versions named after?

9 / 10

What's Ubuntu Core?

10 / 10

Which Ubuntu version is Snap introduced?

The average score is 68%

Leave a Reply

Your email address will not be published. Required fields are marked *