Live data from Hacker News

A Unix Utility You Should Know About: Netcat (2009)

catonmat.net

11–20 of 39 posts

Re: A Unix Utility You Should Know About: Netcat (2009)

#11
post #5

You should also know about the so-called "netcat mode" in OpenSSH: -W host:port Requests that standard input and output on the client be forwarded to host on port over the secure channel. Implies -N, -T, ExitOnForwardFailure and ClearAllForwardings. Works with Protocol version 2 only.

I only discovered this recently - I was using a literal "nc %h %p" rather than this shortcut.

Also worth noting this is also extremely useful when used in your ~/.ssh/config file.

Re: A Unix Utility You Should Know About: Netcat (2009)

#12
post #3

There is a better utility available for folks. Ncat - part of famous the Nmap (5) project. It has more features than netcat that people might find useful - like SCTP, SOCKS, etc.. You can find out more about it: http://nmap.org/ncat/

I second that Nmap recommendation.

Also, fping is an excellent ping sweeper if that's all you need (and it's now being updated again).

http://fping.org/

Re: A Unix Utility You Should Know About: Netcat (2009)

#15
post #4

Netcat is indeed very versatile and useful but most of the time it's used improperly when used as a server (-l mode). Unless you're doing basic network diagnostics (ex: testing if firewall ports are open) you're better off using openssl (s_server mode) or more likely good ol' SSH port forwarding.

I don't really feel like there's that many people misusing netcat out there. It's mostly useful to me as a server for hand testing client software against a known (and human-talkable) server protocol.

Is there some rash of people opening up public listening ports using netcat to... run a service of some sort? Most of the time when I need an arbitrary connection between unix machines ssh in command (not even port forward) mode is more than enough.

Re: A Unix Utility You Should Know About: Netcat (2009)

#16
Be aware that GNU netcat and BSD netcat are incompatible. Many a time have I attempted to cat a file from a Mac to a PC running Linux, only to have found that Nothing Happens (tm). I just recently realized that installing BSD netcat on Linux solves the problem. Not sure what the actual incompatibility is, just a heads up.

Re: A Unix Utility You Should Know About: Netcat (2009)

#17
post #14

Also check out socat: It's like netcat, but bidirectional. http://www.dest-unreach.org/socat/doc/socat.html#EXAMPLES

More than just bidirectional: It supports a lot of other socket types, and other shenanigans. I use socat a lot for testing network services, gluing together applications, and lots of other places where writing a little C program would otherwise be needed.

Re: A Unix Utility You Should Know About: Netcat (2009)

#18
post #3

There is a better utility available for folks. Ncat - part of famous the Nmap (5) project. It has more features than netcat that people might find useful - like SCTP, SOCKS, etc.. You can find out more about it: http://nmap.org/ncat/

There's a better utility available than ncat. It's called socat. It has more features than ncat that people might find useful.

http://www.dest-unreach.org/socat/doc/socat.html#EXAMPLES

Re: A Unix Utility You Should Know About: Netcat (2009)

#19
post #16

Be aware that GNU netcat and BSD netcat are incompatible. Many a time have I attempted to cat a file from a Mac to a PC running Linux, only to have found that Nothing Happens (tm). I just recently realized that installing BSD netcat on Linux solves the problem. Not sure what the actual incompatibility is, just a heads up.

I just confirmed this is not the case. Could you share what you were doing?

Re: A Unix Utility You Should Know About: Netcat (2009)

#20
post #13

On a related note it's always annoyed me when people use "telnet" when they mean "make a TCP connection" as in "can you telnet to the port?"

When providing support, you have to be very precise when you ask someone to perform a check. The sentence "can you telnet to the port" is unambiguous. The sentence "can you make a TCP connection" leaves the choice of the tool unspecified. Depending of their background, some people may use ping (subject to different firewall rules), or a browser (subject to proxy configuration).
Post reply on HN