[colug-432] nc replacement in RHEL7?

Rick Hornsby richardjhornsby at gmail.com
Thu May 28 17:30:04 EDT 2015



> On May 28, 2015, at 15:53, Rob Funk <rfunk at funknet.net> wrote:
> 
> Rick Hornsby wrote:
>> RHEL 7 changed a bunch of stuff.  One of the more annoying things is
>> what the nmap folks did to nc.
> 
>> Other than rolling your own C app (which I did) and dropping it
>> somewhere, are there any easy/accessible replacements for nc -z?  By
>> easy, I mean not writing a mini perl script, and by accessible I mean
>> maybe something that's already part of or installable from the RHEL
>> repo.  Basically, I want the old nc (or some equivalent) back.
> 
> Is downloading and compiling source code considered accessible enough?

Fair question.

For the purposes of my question, not really.  I was hoping for an alternative solution provided somewhere within Redhat's existing ecosystem.

I wrote and compiled my own tiny C app to do the tcp half open. I guess the best thing I can do is throw that into an RPM and onto the Satellite server.  I was hoping for a more "official"/well-known solution because I want it to be able to part of a flexible provision/deployment strategy and to be able to give my co-workers a standard (ie nc) approach.

> Wikipedia says there are lots of variations of netcat:
>  http://en.wikipedia.org/wiki/Netcat#Ports_and_reimplementations
> (FWIW, Ubuntu 14.04 has both netcat-openbsd and netcat-traditional.)
> 
> I don't have a RHEL7-based system handy, but maybe it has "socat"?
> (CentOS 6.4 has socat, so maybe that was preserved in RHEL7 even if
> the old netcat wasn't.)
> 
>  socat - TCP:127.0.0.1:80 < /dev/null && echo Connection succeeded 1>&2

socat is available, though repoquery is being dumb atm and not telling me where it came from.

socat looks close - syntax is a little complicated but it does exactly the right thing. It is fast, sets an appropriate exit code, and by default times out quickly (for those DROP firewall rules)

That definitely helps, thanks. I've used socat for UNIX socket work ie controlling haproxy but never for TCP sockets.




More information about the colug-432 mailing list