Netcat - How to listen on a TCP port using IPv6 address?
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!
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