4

I'm trying to test if a service is up and running using nc.

echo ruok | nc 127.0.0.1 5111

But I get this response:

This is nc from the netcat-openbsd package. An alternative nc is available
in the netcat-traditional package.
usage: nc [-46DdhklnrStUuvzC] [-i interval] [-P proxy_username] [-p source_port]
      [-s source_ip_address] [-T ToS] [-w timeout] [-X proxy_protocol]
      [-x proxy_address[:port]] [hostname] [port[s]]

I'm not sure how to use this 'alternative nc', can someone please explain this to me?

I tried:

echo ruok | nc -s 127.0.0.1 -p 5111  

but I got the same message.

Avinash Raj
  • 80,446
Blankman
  • 8,605

1 Answers1

5

You have the right nc. You may verify that by entering apt-cache policy netcat which should give you the installed and candidate versions for netcat.
The response you get suggests that you haven't entered the command correctly, so please verify that you tried the command just as stated above. If no process is running on your localhost at port 5111, you will receive no output.
The version with the -s and -p parameters works differently though. These are the source address and port parameters, respectively, not the target address and port. As you haven't specified a target, nothing is sent in this case.

Jos
  • 30,529
  • 8
  • 89
  • 96