X

Solaris serviceability and nifty tools

Netcat I/O enhancements

When Netcat integrated into OpenSolaris it was already clear
that there will be couple of enhancements needed. The biggest set of the changes made after Solaris 11 Express was released brings
various I/O enhancements to netcat shipped with Solaris 11. Also, since
Solaris 11, the netcat package is
installed by default in all distribution forms (live CD, text install, ...).

Now, let's take a look at the new functionality:



































/usr/bin/netcat alternative program name (symlink)
-b bufsize I/O buffer size
-E use exclusive bind for the listening socket
-e program program to execute
-F

no network close upon EOF on stdin
-i timeout extension of timeout specification
-L timeout

linger on close timeout

-l -p port addr previously not allowed usage
-m byte_count Quit after receiving byte_count bytes
-N file

pattern for UDP scanning

-I bufsize size of input socket buffer
-O bufsize size of output socket buffer
-R redir_spec port redirection
addr/port[/{tcp,udp}] syntax of redir_spec
-Z

bypass zone boundaries
-q timeout timeout after EOF on stdin

Obviously, the Swiss army knife of networking tools just got a bit thicker.

While by themselves the options are pretty self explanatory, their combination together with other options,
context of use or boundary values of option arguments make it possible to construct small but powerful tools.
For example:


  • the port redirector allows to convert TCP stream to UDP datagrams.

  • the buffer size specification makes it possible to send
    one byte TCP segments or to produce IP fragments easily.

  • the socket linger option can be used to produce TCP RST segments by setting the timeout to 0

  • execute option makes it possible to simulate TCP/UDP servers or clients with shell/python/Perl/whatever script

  • etc.

If you find some other helpful ways use please share via comments.

Manual page nc(1) contains more details, along with examples on how to use some of these new options.

Join the discussion

Comments ( 2 )
  • Chip Schweiss Friday, October 3, 2014

    Netcat is GPLv2. Where is the source to these enhancements?


  • Vlad Friday, October 3, 2014

    There are multiple different Netcat implementations out there. This one in Solaris is based on the one from OpenBSD which comes with BSD license. You can see older version of the source living in the source gates of systems forked from OpenSolaris.


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.