57

I'm not sure about when to use nc, netcat or ncat. If one is the deprecated version of another? If one is only available on one distribution? If it is the same command but with different names?

In fact I'm a bit confused. My question comes from wanting to do a network speed test between two CentOS 7 servers. I came across several examples using nc and dd but not many using netcat or ncat.

Could someone clarify this for me please?

4 Answers 4

54

nc and netcat are two names for the same program (typically, one will be a symlink to the other). Though—for plenty of confusion—there are two different implementations of Netcat ("traditional" and "OpenBSD"), and they take different options and have different features.

Ncat is the same idea, but from the Nmap project. There is also socat, which is a similar idea. There is also /dev/tcp, an (optional) Bash feature.

However, if you're looking to do network speed tests then all of the above are the wrong answer. You're looking for iperf3 (site 1 or site 2 or code).

5
  • 1
    Do you mean that testing (quick test) network speed using dd and nc is not reliable? Commented May 30, 2017 at 18:20
  • 4
    @Pozinux dd/nc should give you an average bandwidth, but none of the extra useful info iperf3 gives you (was it stable, did it experience TCP slow start, were there retransmits, etc.). All of those are very useful (almost required) to troubleshoot unexpectedly low bandwidth, or even to understand what the "you got X mbps" means.
    – derobert
    Commented May 30, 2017 at 18:24
  • Ok thanks, I didn't know about this tool. Commented May 30, 2017 at 18:31
  • One difference worth noting is ncat can encrypt its traffic via --ssl option, nc does not have such option. Commented Nov 25, 2021 at 5:08
  • On RHEL/CentOS 7, there are /usr/bin/ncat (provided by the nmap-ncat RPM package) and /usr/bin/netcat (which is OpenBSD nc, provided by the netcat RPM package). And /usr/bin/nc is just a symbolic link to one of the two previous ones that can be managed on RHEL/CentOS 7 by alternatives --config nmap, and on RHEL 8 (or later) or derivatives by alternatives --config nc).
    – rsc
    Commented Mar 27, 2022 at 1:33
15

Looking at the packets in Debian, there are two different implementations of netcat (nc), I think both of them install with netcat as well as nc symlinked to the same binary (Though they use Debian's "alternatives" system to control which one of the implementation appears with the main name.) Those two are netcat-traditional ("the "classic" netcat, written by Hobbit. It lacks many features found in netcat-openbsd.") and netcat-openbsd ("the OpenBSD rewrite of netcat, including support for IPv6, proxies, and Unix sockets.").

ncat is the version of netcat from the Nmap Project claimed to be "a much-improved reimplementation of the venerable Netcat".

All three seem to have the same basic functionality, as in being able to open a socket and connect or listen, but for anything above that, you may want to check the manual of your version. (The OpenBSD one doesn't support -e for executing a command after connection, for example.)

1

ncat supports SSL which is great for testing https sessions. nc/netcat requires you to use "openssl s_client ..."

1

Netcat (often abbreviated to nc) is a computer networking utility for reading from and writing to network connections using TCP or UDP, which means that we can use it for file transfer operations.

The original Netcat was released by Hobbit in 1995, but it hasn't been maintained despite its popularity. The flexibility and usefulness of this tool prompted the Nmap Project to produce Ncat, a modern reimplementation that supports SSL, IPv6, SOCKS and HTTP proxies, connection brokering, and more.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .