How to Check if a TCP port is open using telnet
This guide details how to check if a remote port is open using telnet.
What is telnet?
Telnet is a now-outdated protocol first developed in 1969 and often used to control computers from a remote location over a command line interface. Telnet has been superseded by ssh for this purpose due to its lack of security and authentication by default. However, as telnet has been ported to most operating systems and connects using TCP it is a useful tool for troubleshooting.
sudo apt install telnet
On Centos or AlmaLinux
yum install telnet
Testing a remote port
Telnet can be used to check if a remote port is open which is great for testing firewall rules are working as expected or if services are running. To test a host with IP 220.127.116.11 on port 80 run
telnet 18.104.22.168 80
If the port is open then you should see something like:
[root@host~]# telnet 22.214.171.124 80 Trying 126.96.36.199... Connected to 188.8.131.52. Escape character is '^]'.
If the port specified is not open then you would expect to see telnet state that it is trying to connect but then hanging or explicitly stating that the connection has been refused.
[root@host~]# telnet 184.108.40.206 80 Trying 220.127.116.11...
[root@host~]# telnet 18.104.22.168 80 Trying 22.214.171.124... telnet: connect to address 126.96.36.199: Connection refused