11

I am using the newest version of netcat (v1.10-41.1) which does not seem to have an option for IPv6 addresses (as the -6 was in the older versions of nc).

If I type in nc -lvnp 2222 and check listening ports with netstat -punta, the server appears to be listening on port 2222 for IPv4 addresses only:

tcp        0      0 0.0.0.0:2222            0.0.0.0:*               LISTEN      2839/nc  

tcp6 is not active like, for example, my apache2 server:

tcp6       0      0 :::80                   :::*                    LISTEN      -
14

There are at least 3 or 4 different implementations of netcat as seen on Debian:

  • netcat-traditional 1.10-41 the original which doesn't support IPv6: probably what you installed.
  • netcat6 which was made to offer IPv6 (oldstable, superseded).
  • netcat-openbsd 1.130-3 . Does support IPv6.
  • ncat 7.70+dfsg1-3 probably a bit newer since not in Debian stable, provided by nmap, does support IPv6.

I'd go for the openbsd one. Each version can have subtly different syntax, so take care.

By the way: socat is a much better tool able to really do much more than netcat. You should try it!

  • 2
    Awesome. Thanks for suggesting the socat tool. It apparently has way more options, and the following: socat tcp6-listen:2222 did the job. – bashbin Jul 22 '18 at 0:36
  • 2
    @bashbin but a bit more verbose in its syntax. that would be socat tcp6-listen:2222,reuseaddr - (or probably reuseport instead) if you want to use it twice in a row when the server (the socat command) disconnects first. – A.B Jul 22 '18 at 8:35
3

I believe the functionality of ipv4 & ipv6 is in fact a result of confusion around there being multiple implementations (forks) or completely different versions. If you search you'll stumble across mentions of nc6. This implementation seems to be in the BSD based distros.

I'd try installing nc6 on your particular distro and running it instead of nc for ipv6 support.

Further research

I was able to find this commit dated 2018-01-11- add IPv6 patch which clearly is adding the IPv6 functionality back into what you're calling the newer version of netcat.

NOTE: I have only access to nc 7.50 on my systems and it, as you describe, supports both -4 and -6.

I suspect what you think is a newer version of netcat is in fact a much older version: http://nc110.sourceforge.net/.

If you'd like an exhaustive list of the various implementations this is available in the Wikipedia question about Netcat.

The original version of netcat was a Unix program. The last version (1.10) was released in March 1996.1

On most Linux distros either GNU netcat or the NMAP version appear to be what most are using:

There are several implementations on POSIX systems, including rewrites from scratch like GNU netcat[5] or OpenBSD netcat,6 the latter of which supports IPv6 and TLS. The OpenBSD version has been ported to the FreeBSD base7 and Windows/Cygwin.8 Mac OS X comes with netcat installed as of OSX 10.13 or users can use MacPorts to install a variant.[9] There is also a Microsoft Windows version of netcat available.[10]

For example, on CentOS 7.x:

$ nc --version
Ncat: Version 7.50 ( https://nmap.org/ncat )

$ rpm -qf /bin/nc
nmap-ncat-6.40-13.el7.x86_64

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.