I was debugging an installation problem of MySQL server on my PC, and wanted to see if the server actually listens to TCP connections.
The built-in Windows
netstat
tool can display all the open ports, but doesn't actually say which programs listen on them.
nmap is a much more general and powerful tool:
Nmap ("Network Mapper") is a free open source utility for network exploration or security auditing. It was designed to rapidly scan large networks, although it works fine against single hosts. Nmap uses raw IP packets in novel ways to determine what hosts are available on the network, what services (application name and version) those hosts are offering, what operating systems (and OS versions) they are running, what type of packet filters/firewalls are in use, and dozens of other characteristics.
The only problem with
nmap
is that Windows doesn't allow to scan the machine from itself, so a workaround is needed. Basically, I wanted to find out if MySQL server was actually listening on port 3306. So I ran:
>nmap -P0 -sT -p3306 localhost
And got the response:
Interesting ports on localhost (127.0.0.1):
PORT STATE SERVICE
3306/tcp open mysql
Which is what I needed.
nmap
is capable of much more than this and has tons of options, but sometimes it is useful just for local debugging tasks.