Using Telnet and Test-NetConnection to test Windows Server 2019 connectivity

 

The ping (or Test-Connection, in PowerShell) command has always been very useful to Network Administrators. Ping uses ICMP protocol to transfer data. The problem we are here to address today is that more and more networks and routers are starting to block ICMP traffic by default.

We have a Server 2019 web server that has a website running. It is also enabled for RDP access and file sharing, but ICMP is being blocked by the local Windows Firewall. We are going to run some tests with a client machine against this server to try to determine which services are up and running.

Test Server IP Address: 192.168.229.133
Test Client IP Address: 192.168.229.128

Step 1: Test connectivity by pining Server IP Address

PS C:\Users\Ali> ping 192.168.229.133

Pinging 192.168.229.133 with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Request timed out.

Ping statistics for 192.168.229.133:
    Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),

The ping test is failed.

Step 2: Install Telnet Client at Client Machine

Got to Control Panel | Programs | Turn Windows features on or off (or Server Manager, if your testing machine is a server) and choose to Add roles or features. We want to install the feature called Telnet Client.

Alternate PowerShell command for Windows 10

dism /online /Enable-Feature /FeatureName:TelnetClient

Alternate PowerShell command for Windows Server

Install-WindowsFeature Telnet-Client

Step 3: Test Open Port 80

The general format of the command is telnet <server> <port>. Even though we cannot ping 192.168.229.133, let’s try to use telnet to open a connection to port 80, which is the website that we have running.

C:\Users\Ali>telnet 192.168.229.133 80

When we press Enter, the Command Prompt window changes to a flashing cursor. This is your confirmation that Telnet was able to open a successful connection to port 80 on the 192.168.229.133 server. Press Control + C to exit the Telnet session.

Step 4: Test Open Port 3389

Now, try using the telnet 192.168.229.133 3389 command. This also results in a flashing cursor, indicating that we successfully connected to port 3389 (RDP) on our 192.168.229.133 server.

Step 5: Test Open Port 53

And finally, how about telnet 192.168.229.133 53? This one results in a timeout, and we do not see our flashing cursor. So, it appears that port 53 is not responding on the 192.168.229.133 server, which makes sense because port 53 is commonly used by DNS, and this is a web server, not a DNS server. If we were to query one of our Domain Controllers that is also running DNS, we would be able to make a successful telnet connection to port 53 to one of those.

Telnet queries work with TCP traffic, which covers most services that you will be polling for. Telnet does not have a connector for UDP ports.

PowerShell command to test HTTP Conncetion

PS C:\Users\Ali> Test-NetConnection 192.168.229.133 -CommonTCPPort HTTP                                                                                                                                                                                                                                                                                                 ComputerName     : 192.168.229.133
RemoteAddress    : 192.168.229.133
RemotePort       : 80
InterfaceAlias   : Ethernet0
SourceAddress    : 192.168.229.128
TcpTestSucceeded : True

PowerShell command to test RDP Conncetion

PS C:\Users\Ali> Test-NetConnection 192.168.229.133 -CommonTCPPort RDP


ComputerName     : 192.168.229.133
RemoteAddress    : 192.168.229.133
RemotePort       : 3389
InterfaceAlias   : Ethernet0
SourceAddress    : 192.168.229.128
TcpTestSucceeded : True

PowerShell command to test port 53 for DNS

PS C:\Users\Ali> Test-NetConnection 192.168.229.133 -Port 53
WARNING: TCP connect to (192.168.229.133 : 53) failed
WARNING: Ping to 192.168.229.133 failed with status: TimedOut


ComputerName           : 192.168.229.133
RemoteAddress          : 192.168.229.133
RemotePort             : 53
InterfaceAlias         : Ethernet0
SourceAddress          : 192.168.229.128
PingSucceeded          : False
PingReplyDetails (RTT) : 0 ms
TcpTestSucceeded       : False

Telnet and its partner, Test-NetConnection, are simple but powerful commands that can be run to query against ports and services on your servers. When trying to determine whether a service is available, or when trying to troubleshoot some form of network connectivity problem, it is a much more reliable tool than using a simple ping request.

If you have been thinking about building a script that programmatically reaches out and checks against servers to report whether they are online or offline, consider using TestNetConnection rather than ping so that you can query the individual service that the system is providing by using its particular port number.

#buttons=(Accept !) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Accept !