Using netcat

  • June 11, 2007
  • Avatar for peter
    Peter
    Upfold

Once again, it's time to take a look at a really neat command line tool that comes with almost all Unix-like operating systems. This tool is called netcat. What it does sounds quite geeky and advanced:

use network sockets from the command line

What that means in more simple terms is that you can create a server which listens on a port, and interact with a server listening on a port from the command line or from within a shell script.

Why would you want to do this? It can have uses in security testing, diagnostics, testing new server systems and for just messing around too.

It's a fairly advanced command to get to know and to use, but thankfully there is a very useful guide over at G-Loaded that gives you some good examples:

The simplest example of its usage is to create a server-client chat system. Although this is a very primitive way to chat, it shows how netcat works. In the following examples it is assumed that the machine that creates the listening socket (server) has the 192.168.0.1 IP address. So, create the chat server on this machine and set it to listen to 3333 TCP port:

Certainly a good read. As always, you can read the official manual by using the man command:
$ man nc

nc is the actual command name for netcat, in case you didn't realise!

Avatar for peter Peter Upfold

Home » Articles »