August 2004

Portqry: The Sequel

Version 2.0 adds some enticing functionality
RSS
Subscribe to Windows IT Pro | See More Administration Tools Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

You've probably heard of Portqry (portqry.exe), a useful tool for port scanning that Microsoft released a year or two ago. With the following Portqry command, you can—for example—test whether a computer named www.bigfirm.biz runs a Web server on port 80:

portqry -n www.bigfirm.biz -e 80

In that command, the -n option tells Portqry to test a machine named www.bigfirm.biz and the -e option says to test port 80. (Alternatively, you can use the -r option to specify a range of ports to test or the -o option to specify a list of ports.) If Portqry finds a Web server at port 80, you'll get a response such as TCP port 80 (http service): LISTENING. You might also get NOT LISTENING, which means nothing is running on that port, or FILTERED, which means some kind of firewall is blocking your ability to scan port 80 on that system.

In December 2003, Microsoft released Portqry 2.0, which offers some new features worth looking at. Enhancements include an interactive mode (similar to that of Nslookup), the ability to track all ports associated with a particular process, and firewall compatibility.

Let's take a look at the tool's interactive mode. Portqry is a helpful tool, but it often requires you to type long commands. My example above is just about the shortest useful command that you could use in the older version of Portqry. Many users don't enjoy memorizing a string of options and prefer to construct their query a bit at a time. Suppose I wanted to test port 25 on www.bigfirm.biz and couldn't remember the -n and -e options. With Portqry 2.0, I could simply type

portqry -i

to start Portqry in what you might call "training-wheels mode." A prompt would then let me specify the machine to query by typing

node www.bigfirm.biz

and pressing Enter. Next, I'd specify the port to query by typing

set port=25

and pressing Enter. Finally, I'd execute the query by typing q and pressing Enter. If I wanted to test port 25 on another system, I'd need only to specify a new target with the Node command and execute the query by typing q and pressing Enter.

Portqry 2.0 also has a local mode that lists all the TCP and UDP ports on which your system is listening. You might respond by saying that Netstat -a has always given you this functionality, but Portqry offers a lot more information. On a Windows Server 2003 or Windows XP system, you'll see a complete list of all the running processes, as well as any ports those processes are using. Netstat -ano offers this kind of functionality by showing each listening port and the process ID of the program that opened the port, but knowing only the process ID doesn't help much. Knowing that the process with ID 4119 is doing something mysterious on a port that you don't recognize still leaves this question unanswered: "Which process has process ID 4119?" You then have to use Task Manager or another utility to look up the process. Portqry -local saves you a step by showing not only the process ID but also the process's name.

Let me briefly discuss some other Portqry 2.0 features. The new -wpid and -wport options let you tell Portqry to continually monitor a particular port or all ports associated with a particular process, respectively. Unlike other Portqry options—which essentially take a snapshot and exit—the -wpid and -wport options let Portqry watch and report on changes in activity. Both options require Windows 2003 or XP. Finally, folks wanting to test firewalls will appreciate that Portqry 2.0 lets them specify the port from which they'll be querying. Suppose I want to query www.bigfirm.biz's port 80 from port 5000 on my system. Portqry 2.0 lets me use the -sp option to do so:

portqry -n www.bigfirm.biz -e 80 -sp 5000

I've found the original Portqry quite useful, and I'm already finding uses for Portqry 2.0. For further information about Portqry 2.0, as well as download instructions, see the Microsoft article "New features and functionality in Portqry version 2.0" (http://support.microsoft.com/?kbid=832919). I think this tool will become an important part of your toolkit.

End of Article



Windows IT Pro Community
Blogs





Top Viewed ArticlesView all articles
CES 2009: Ballmer Announces Windows 7, Windows Live, Live Search Milestones

During his first-ever Consumer Electronics Show (CES) 2009 keynote address last night in Las Vegas, Microsoft CEO Steve Ballmer announced the pending public availability of a feature-complete Windows 7, the final version of Windows Live Essentials, and ...

10 Reasons to Deploy Windows Vista

The decision to upgrade your XP systems to Vista is simple when you consider features such as easier backup, a great desktop search, and vastly improved security options. ...

10 Reasons Not to Deploy Windows Vista

The decision to upgrade to Vista has to make business sense, but many companies find the costs in training and application compatibility problems outweigh any benefits Vista brings. ...


Windows OSs Whitepapers Why SaaS is the Right Solution for Log Management

Related Events Virtualization Forum: Optimizing Storage, Networks, Desktops, and Security

Cloud Computing Forum: Integrating Software, Server and Storage as a Service into Your Enterprise IT Delivery Model

Virtualization Forum: Optimizing Storage, Networks, Desktops, and Security

Check out our list of Free Email Newsletters!

Windows OSs eBooks Understanding and Leveraging Code Signing Technologies

A Guide to Windows Certification and Public Keys

SQL Server Administration for Oracle DBAs

Related Windows OSs Resources Become a VIP member of the Windows IT Pro community!
Get it all with the VIP CD and VIP access. A $500+ value for only $279!

Subscribe to Windows IT Pro!
Solve your toughest technical problems with our experts and access 10,000 + articles online. 30% off

Monthly Online Pass - Only $5.95!
Get instant access to 10,000+ articles from Windows IT Pro Magazine!

TechNet Virtual Labs
Evaluate and test Microsoft's newest products.


SQL Server Magazine Office & SharePoint Pro Windows Dev Pro ITTV
IT Library Technology Resource Directory Connected Home Windows Excavator Windows SuperSite
 
 Windows IT Pro is a Division of Penton Media Inc.
 Copyright © 2009 Penton Media, Inc., All rights reserved. Terms and Use | Privacy Statement | Reprints and Licensing