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 188.8.131.52 on port 80 run
telnet 184.108.40.206 80
If the port is open then you should see something like:
[root@host~]# telnet 220.127.116.11 80 Trying 18.104.22.168... Connected to 22.214.171.124. 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 126.96.36.199 80 Trying 188.8.131.52...
[root@host~]# telnet 184.108.40.206 80 Trying 220.127.116.11... telnet: connect to address 18.104.22.168: Connection refused