NC(1)                      OpenBSD Reference Manual                      NC(1)

NAME
     nc - arbitrary TCP and UDP connections and listens

SYNOPSIS
     nc [-46hklnrtuvz] [-i interval] [-p source port] [-s source ip address]
        [-x proxy address [:port]] [-w timeout] [hostname] [port[s]]

DESCRIPTION
     The nc (or netcat) utility is used for just about anything under the sun
     involving TCP or UDP.  It can open TCP connections, send UDP packets,
     listen on arbitrary TCP and UDP ports, do port scanning, and deal with
     both IPv4 and IPv6.  Unlike telnet(1), nc scripts nicely, and separates
     error messages onto standard error instead of sending them to standard
     output, as telnet(1), does with some.

     Destination ports can be single integers or ranges.  Ranges are in the
     form nn-mm.

     Common uses include:

           o   simple TCP proxies
           o   shell-script based HTTP clients and servers
           o   network daemon testing
           o   and much, much more

     The options are as follows:

     -4      Forces nc to use IPv4 addresses only.

     -6      Forces nc to use IPv6 addresses only.

     -h      Prints out nc help.

     -i interval
             Specifies a delay time interval between lines of text sent and
             received.  Also causes a delay time between connections to multi-
             ple ports.

     -k      Forces nc to stay listening for another connection after it's
             current connection is completed.

     -l      Used to specify that nc should listen for an incoming connection
             rather than initiate a connection to a remote host.

     -n      Do not do any DNS or service lookups on any specified addresses
             or hostnames, or ports.

     -p port
             Specifies the source port nc should use, subject to privilege re-
             strictions and availability.

     -r      Specifies that source and/or destination ports should be chosen
             randomly instead of sequentially within a range or in the order
             that the system assigns.

     -s hostname/ip address
             Specifies the IP of the interface which is used to send the pack-
             ets.

     -t      Causes nc to send RFC854 DON'T and WON'T responses to RFC854 DO
             and WILL requests.  This makes it possible to use nc to script


             telnet sessions.

     -u      Use UDP instead of the default option of TCP.

     -v      Have nc give more verbose output.

     -x proxy address [:port]
             Requests that nc should connect to hostname using a socks5 proxy
             at address and port.  If port is not specified, port 1080 is
             used.

     -z      Specifies that nc should just scan for listening daemons, without
             sending any data to them.

EXAMPLES
     nc hostname 42
       Open a TCP connection to port 42 of hostname.

     nc -p 31337 hostname 42
       Open a TCP connection to port 42 of hostname, and use port 31337 as the
       source port.

     nc -w 5 hostname 42
       Open a TCP connection to port 42 of hostname, and timeout after five
       seconds while attempting to connect.

     nc -u hostname 53
       Open a UDP connection to port 53 of hostname.

     nc -s 10.1.2.3 example.host 42
       Open a TCP connection to port 42 of example.host using 10.1.2.3 as the
       IP for the local end of the connection.

     nc -v hostname 42
       Open a TCP connection to port 42 of hostname, displaying some diagnos-
       tic messages on stderr.

     nc -v -v hostname 42
       Open a TCP connection to port 42 of hostname, displaying all diagnostic
       messages on stderr.

     nc -v -z hostname 20-30
       Attempt to open TCP connections to ports 20 through 30 of hostname, and
       report which ones nc was able to connect to.

     nc -v -u -z -w 3 hostname 20-30
       Send UDP packets to ports 20-30 of example.host, and report which ones
       did not respond with an ICMP packet after three seconds.

     nc -l 3000
       Listen on TCP port 3000, and once there is a connection, send stdin to
       the remote host, and send data from the remote host to stdout.

     echo foobar | nc hostname 1000
       Connect to port 1000 of hostname, send the string "foobar" followed by
       a newline, and move data from port 1000 of hostname to stdout until
       hostname closes the connection.

SEE ALSO
     cat(1), telnet(1)

AUTHORS
     Original implementation by *Hobbit* <hobbit@avian.org>.

     Rewritten with IPv6 support by Eric Jackson <ericj@monkey.org>.

OpenBSD 3.0                      June 25, 2001                               2
