I'm trying to use netcat to catch kernel printing (netconsole) using nc -l -u -p 6666.

But when I use this utility in Ubuntu, it immediately exits.

Trying to figure out why, I see that in the manual page it is described that -l & -p can't be used together.

The next time I tried to execute it as following.

This time I started to get some reply but then it exits.

$ nc -l -u 6666
netconsole: local port 6665
netconsole: local IP
netconsole: interface 'eth0'
netconsole: remote port 6666
netconsole: remote IP
netconsole: remote ethernet address ff:ff:ff:ff:ff:ff
netconsole: local IP

Then I get back host prompt, as if netcat existed without printing anything more.

Can someone help me figure out what I'm doing wrong ?


@ransh, you're using OpenBSD Netcat, which has a different syntax. I suggest you to change to netcat-traditional:

sudo update-alternatives -config nc

Select the option /bin/nc.traditional. Verify and new version:

nc -h

You can use -l and -p yes. Try:

sudo nc -u -v -l -p 6666

Use -u if you're looking for UDP packages.

  • Hi Wiliiam, I just tried it now in ubuntu 10.04 but I get the description of nc arguments (as if it contain some error argument). I copy pase exactly what you wrote above. Note that in manual page it is said not to use -l & - together. – ransh Aug 5 '14 at 17:56
  • So strange. I tested my command before post the answer. I'm using Debian Wheezy. Can you update your nc package? Can you verify your nc version, please? – Willian Paixao Aug 5 '14 at 18:01
  • I updated it now, but still it is the same result. How can I get the version ? – ransh Aug 5 '14 at 18:05
  • from man page: -l Used to specify that nc should listen for an incoming connection rather than initiate a connection to a remote host. It is an error to use this option in conjunction with the -p, -s, or -z options. Additionally, any timeouts specified with the -w option are ignored. – ransh Aug 5 '14 at 18:05
  • The version is written in the very first line of help output: nc -h. – Willian Paixao Aug 5 '14 at 18:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.