FREE: Netcat - Swiss army knife for network troubleshooting

Netcat certainly belongs in every admin's toolbox. This tiny free command line tool has been available since 1995. It helps you troubleshoot network related problems. The best way to understand what kind of things you can do with netcat is through examples:

Profile gravatar of Michael Pietroforte

Michael Pietroforte

Michael Pietroforte is the founder and editor of 4sysops. He is a Microsoft Most Valuable Professional (MVP) with more than 30 years of experience in IT management and system administration.
Profile gravatar of Michael Pietroforte

Use netcat as a simple port scanner ^

This command checks which ports between 1 and 1024 of a computer called somehost are open. The option -v stands for verbose, -w specifies the timeout in seconds, and -z means zero-I/O to operate netcat in scanning mode. There are certainly more sophisticated port scanners such as nmap. But remember, netcat is a swiss army knife, so it keeps things simple.

Use netcat to talk to your servers ^

Sometimes you know that a backend application has opened the right port, but your client refuses to connect. To track down the problem it is useful "to talk" to the server to see if the program is actually transmitting meaningful data.

This command will open a connection to Microsoft's Web server. You'll get something like this as answer:

Now, if you want to talk with Microsoft's server you have to know a little HTTP:

This tells the Web server that you want to load the default file in the root folder using the HTTP 1.0 protocol. After hitting RETURN twice, you should get this answer from Redmond:

So, it is really true. Microsoft operates its Web servers with IIS 7.0 already.

Use netcat to test a connection ^

Sometimes one doesn't know whether a program is not working properly or if it is just a network problem. Usually, you would use ping to make sure that the connection stands. But if it is a complex network problem, for example if a firewall is involved, then you can work with netcat. With this command netcat will listen on port 6000 on the server side:

Of course, if you want to try the port your backend application uses, you have to shut it down first.

On your client computer you connect to the server with this command:

Netcat will then establish a connection between your server and your client. Now, you just type something on the client console and hit ENTER. If the connection works properly, it should show up on the server console. On the client side it looks like this:

And on the server you would see this:

1391 is the local port on the client in this example. If you think that your network connection is just a bit shaky or too slow, you could send larger amounts of texts to see how it gets through.

Use netcat to feel like a super cool hacker ^

Netcat can also be used to remotely manage a computer easily. This is why some anti-malware tools raise alarm if they detect netcat. The -e option allows you to launch a certain program whenever you connect to a certain port:

You then connect to this server with:

This will launch a command prompt on the server which you can control from the client. Type ipconfig, if you are not sure where you actually are.

These were just a few examples. This little tool can do more. Here is the list of all options that netcat 1.11 for Windows supports:

Netcat ^

Take part in our competition and win $100!

Related Posts

  1. avatar
    fuller 9 years ago

    how does it work??

  2. Profile gravatar of Michael Pietroforte
    Michael Pietroforte 9 years ago

    Could you be a bit more specific? What doesn't work?

  3. avatar
    wud 9 years ago

    I was just googling around hoping to find a netcat intro by example. Good Work.

  4. Profile gravatar of Michael Pietroforte
    Michael Pietroforte 9 years ago

    Wud, good that it worked for you 😉

  5. Netcat 9 years ago

    [...] [...]

  6. avatar
    Etienne 8 years ago

    Good article, I was just looking for an Netcat introduction.

  7. avatar
    laks 7 years ago

    Thanks Mike for an wonderful article on Netcat. Your articles was helpful in troubleshooting my issue with netcat connectivity.



Leave a reply

Your email address will not be published. Required fields are marked *



Please ask IT administration questions in the forum. Any other messages are welcome.

© 4sysops 2006 - 2017
Do NOT follow this link or you will be banned from the site!

Log in with your credentials


Forgot your details?

Create Account