Sunday, July 16, 2017

Windows: Testing if a remote port is open using Telnet

In a previous post, Opening an inbound port for an Ubuntu Virtual Machine on Azure, an inbound port was open on an Ubuntu virtual machine (port 21777) and on this host a service (tinyproxy) was installed that listens on this port via TCP/IP. Obviously, there should be a way to test that the port is actually open and if the underling service is actually listening. This can be accomplished using a telnet client on Windows. Previously it was shown how to insure the telnet client is installed on Windows (Making Telnet Client available on Windows).

Telnet is used from a console window and written as follows where telnet will establish a TCP/IP connection:

telnet <host|ip> <port>

An example of this as follows where the IP is an Ubuntu server and port 22 the port used by SSH:


When enter is is clicked on in the previous console window, the following is displayed:


Above it can be seen that the telnet connection accessed the SSH service on the Ubantu server. This means port 22 is open and SSH is listening on the port.

The exercise in testing ports relates to installing a tinyproxy proxy service on an Ubuntu service. The tinyproxy service is listening on port 21777 using TCP. To test the port port the following is entered in a Windows console window:


When the above command is invoked the following is displayed:


What appears to be blank screen actually means that telenet success accessed the tinyproxy service on port 21777.

Below is an example of telet being invoked on a port that is not open for the Ubuntu server:


Invoking the command above results in the following:


The screenshot above shows telnet waiting in vain for port 21778:


Eventually the attempted by telnet to connection to port 21778 will time out resulting in text such is displayed above.

So using telnet or bash (Testing if a remote port is open using BASH /dev/tcp/host/port) it has been shown how to determine if a port is open on  a remote server with a service listening on the port.

No comments :

Post a Comment