Testing Service Connectivity with PortQry

If you ask a bunch of systems administrators what tools do they use when troubleshooting remote services and ports, one of the top answers would definitely be the Telnet client! Windows 7 includes a Telnet Client but it is not installed by default. However, a tool that is more flexible and powerful than Telnet Client is PortQry. This tool has been around since Windows 2000 and version 2 has more features, you can download PortqryV2.exe from Microsoft’s Download Center as it is not included with Windows 7.

PortqryV2.exe is a command-line utility that you can use to troubleshoot TCP/IP connectivity issues. The major advantage it has over Telnet Client is that it supports UDP ports as well whereas Telnet Client supports only TCP ports.  PortQry would become very useful when testing connectivity for LDAP, RPC, DNS, NetBIOS and other UDP ports. Another important advantage of PortQry is that you can specify a source port when testing. This is very useful when testing firewall rules that filter ports based on their source ports.

Testing connectivity for services running on a host requires you to specify a port number. Services distinguish their traffic from each other by using port numbers. Therefore, when you use Telnet or PortQry you need to provide a port number that the destination service is using. However, note that some services may be configured to respond on non-default ports for security reasons and therefore you need to find the listening port for that particular service before running a query.

To test connectivity using PortQry open a command prompt and type the following:

portqry – n destination -e portnumber

For example to test that the http service for www.windows7library.com is running type:

portqry -n www.windows7library.com -e 80

PortQry first attempts to resolve the name to an IP address or vice-versa and then checks the port specified after the option -e. If the tool outputs’ LISTENING then it means that the host responded on the specified port, on the other hand, if the output is NOT LISTENING or FILTERED, then the service is not available.

With PortQry you can also determine which remote management services are available on a remote host assuming they are using the default port numbers, type:

portqry -n destination -o 23,139,445,3389

This command queries the remote host to determine whether Telnet Server, NetBIOS, Common Internet File System (CIFS) and Remote Desktop services are available.

portqry -n destination -e 25 -sp 25

This command queries the remote host using an initial source port; hence, if your outgoing port 25 is blocked by the firewall then the tool would return a socket error.

For a detailed list of the command options type portqryv2 /? at the command prompt.

Finally, for the non-command line users there is a GUI version of PortQry which can be downloaded from Microsoft’s Download Center. Although, the GUI version does not add any further functionality, I find it very helpful as it displays the full command line syntax together with the results, and it has some predefined queries! I highly recommend it for basic tests!