In my computer with Ubuntu 14.04 I can do things like this:
$ nc -l 5349 -vvv
Listening on [0.0.0.0] (family 0, port 5349)
or this:
$ nc -vvv -l 192.168.254.96 5349
Listening on [192.168.254.96] (family 0, port 5349)
And a socket is opened to listen entering connections on my local IP address (192.168.254.96). And obviously I can connect from the other side and transmit data.
But in a server behind a NAT with Debian 8.0 Jessie I got this strange error:
$ nc -vvv -l 5349
5349: inverse host lookup failed: Unknown host
nnetfd reuseport failed : Protocol not available
listening on [any] 38541 ... : Protocol not available
or:
$ nc -vvv -l 10.1.6.189 5349
10.1.6.189: inverse host lookup failed: Unknown host
nnetfd reuseport failed : Protocol not available
listening on [any] 52606 ... : Protocol not available
The port is not in use:
$ ss -tnl | grep 5349
(empty)
and it is the correct IP address:
$ ip addr list
...
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 1e:89:93:f1:96:a4 brd ff:ff:ff:ff:ff:ff
inet 10.1.6.189/19 brd 10.1.31.255 scope global eth0
inet6 fe80::1c89:93ff:fef1:96a4/64 scope link
valid_lft forever preferred_lft forever
What could be the issue? Could be something related with the NAT behind the server is?
Best Answer
For netcat in listen mode you should use
-p
flag to choose listening port, e.g.nc -vvv -l -p 5349
.the second error:
nnetfd reuseport failed : Protocol not available
is related to SO_REUSEPORT socket option. It was introduced in linux kernel version 3.9 and netcat version using it will not work with earlier kernel release. You can either upgrade your kernel to more recent version or use another variation of netcat. I believe netcat-openbsd should work.