[BACK]Return to nc.1 CVS log [TXT][DIR] Up to [local] / src / usr.bin / nc

Annotation of src/usr.bin/nc/nc.1, Revision 1.12

1.12    ! millert     1: .\"    $OpenBSD: nc.1,v 1.11 2000/09/26 01:41:44 ericj Exp $
1.1       deraadt     2: .\"
                      3: .\" Copyright (c) 1996 David Sacerdote
                      4: .\" All rights reserved.
                      5: .\"
                      6: .\" Redistribution and use in source and binary forms, with or without
                      7: .\" modification, are permitted provided that the following conditions
                      8: .\" are met:
                      9: .\" 1. Redistributions of source code must retain the above copyright
                     10: .\"    notice, this list of conditions and the following disclaimer.
                     11: .\" 2. Redistributions in binary form must reproduce the above copyright
                     12: .\"    notice, this list of conditions and the following disclaimer in the
                     13: .\"    documentation and/or other materials provided with the distribution.
                     14: .\" 3. The name of the author may not be used to endorse or promote products
                     15: .\"    derived from this software without specific prior written permission
                     16: .\"
                     17: .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
                     18: .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
                     19: .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
                     20: .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
                     21: .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
                     22: .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
                     23: .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
                     24: .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
                     25: .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
                     26: .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
                     27: .\"
                     28: .Dd August 1, 1996
1.3       aaron      29: .Dt NC 1
1.4       deraadt    30: .Os
1.1       deraadt    31: .Sh NAME
                     32: .Nm nc
1.5       millert    33: .Nd "arbitrary TCP and UDP connections and listens"
1.2       deraadt    34: .Sh SYNOPSIS
1.1       deraadt    35: .Nm nc
1.9       aaron      36: .Op Fl lnrtuvz
1.1       deraadt    37: .Op Fl g Ar intermediates
                     38: .Op Fl G Ar hopcount
                     39: .Op Fl i Ar interval
                     40: .Op Fl o Ar filename
1.6       aaron      41: .Op Fl p Ar source port
1.1       deraadt    42: .Op Fl s Ar ip address
1.6       aaron      43: .Op Fl w Ar timeout
1.1       deraadt    44: .Op Ar hostname
                     45: .Op Ar port[s...]
                     46: .Sh DESCRIPTION
                     47: The
1.6       aaron      48: .Nm
1.1       deraadt    49: (or
                     50: .Nm netcat )
                     51: utility is used for just about anything under the sun
1.7       aaron      52: involving TCP or UDP.
                     53: It can open TCP connections, send UDP packets,
1.3       aaron      54: listen on arbitrary TCP and UDP ports, do port scanning, and source
1.7       aaron      55: routing.
                     56: Unlike
1.1       deraadt    57: .Xr telnet 1 ,
1.6       aaron      58: .Nm
1.1       deraadt    59: scripts nicely, and separates error messages onto standard error instead
1.6       aaron      60: of sending them to standard output, as
                     61: .Xr telnet 1
                     62: does with some.
1.1       deraadt    63: .Pp
                     64: Destination ports can be single integers, names as listed in
1.5       millert    65: .Xr services 5 ,
1.7       aaron      66: or ranges.
                     67: Ranges are in the form nn-mm, and several separate ports and/or
1.1       deraadt    68: ranges may be specified on the command line.
                     69: .Pp
                     70: Common uses include:
1.7       aaron      71: .Pp
                     72: .Bl -bullet -offset indent -compact
1.1       deraadt    73: .It
1.3       aaron      74: simple TCP proxies
1.1       deraadt    75: .It
1.3       aaron      76: shell\-script based HTTP clients and servers
1.1       deraadt    77: .It
                     78: network daemon testing
                     79: .It
                     80: source routing based connectivity testing
                     81: .It
                     82: and much, much more
                     83: .El
                     84: .Pp
                     85: The options are as follows:
                     86: .Bl -tag -width Ds
                     87: .It Fl g Ar intermediate-host
1.7       aaron      88: Specifies a hop along a loose source routed path.
                     89: Can be used more than once to build a chain of hop points.
1.1       deraadt    90: .It Fl G Ar pointer
1.7       aaron      91: Positions the
                     92: .Dq hop counter
                     93: within the list of machines in the path of a source routed packet.
                     94: Must be a multiple of 4.
1.1       deraadt    95: .It Fl i Ar seconds
                     96: Specifies a delay time interval between lines of text sent and received.
                     97: Also causes a delay time between connections to multiple ports.
                     98: .It Fl l
                     99: Is used to specify that
1.6       aaron     100: .Nm
1.1       deraadt   101: should listen for an incoming connection, rather than initiate a
1.7       aaron     102: connection to a remote host.
                    103: Any hostname/IP address and port arguments
1.1       deraadt   104: restrict the source of inbound connections to only that address and
                    105: source port.
                    106: .It Fl n
                    107: Do not do DNS lookups on any of the specified addresses or hostnames, or
                    108: names of port numbers from /etc/services.
                    109: .It Fl o Ar filename
                    110: Create a hexadecimal log of data transferred in the specified file.
1.7       aaron     111: Each line begins with
                    112: .Ql <
                    113: or
                    114: .Ql > .
                    115: .Ql <
                    116: means
                    117: .Dq from the net
                    118: and
                    119: .Ql >
                    120: means
                    121: .Dq to the net .
1.1       deraadt   122: .It Fl p Ar port
                    123: Specifies the source port
1.6       aaron     124: .Nm
1.1       deraadt   125: should use, subject to privilege restrictions and availability.
                    126: .It Fl r
1.3       aaron     127: Specifies that source and/or destination ports should be chosen semi-randomly
1.1       deraadt   128: instead of sequentially within a range or in the order that the
                    129: system assigns.
                    130: .It Fl s Ar hostname/ip-address
1.3       aaron     131: Specifies the IP of the interface which is used to send the packets.
                    132: On some platforms, this can be used for UDP spoofing by using
                    133: .Xr ifconfig 8
                    134: to bring up a dummy interface with the desired source IP address.
1.1       deraadt   135: .It Fl t
                    136: Causes
1.6       aaron     137: .Nm
1.1       deraadt   138: to send RFC854 DON'T and WON'T responses to RFC854 DO
1.7       aaron     139: and WILL requests.
                    140: This makes it possible to use
1.6       aaron     141: .Nm
1.7       aaron     142: to script telnet sessions.
                    143: The presence of this option can be
1.1       deraadt   144: enabled or disabled as a compile-time option.
                    145: .It Fl u
1.6       aaron     146: Use UDP instead of TCP.
1.1       deraadt   147: On most platforms,
1.6       aaron     148: .Nm
1.1       deraadt   149: will behave as if a connection is established until it receives an
                    150: ICMP packet indicating that there is no program listening to what it
                    151: sends.
                    152: .It Fl v
1.7       aaron     153: Verbose.
                    154: Cause
1.6       aaron     155: .Nm
1.7       aaron     156: to display connection information.
                    157: Using
1.3       aaron     158: .Fl v
1.1       deraadt   159: more than once will cause
1.6       aaron     160: .Nm
1.1       deraadt   161: to become even more verbose.
                    162: .It Fl w Ar timeout
                    163: Specifies the number of seconds
1.6       aaron     164: .Nm
1.1       deraadt   165: should wait before deciding that
                    166: an attempt to establish a connection is hopeless.
                    167: Also used to specify how long to wait for more network data after standard
                    168: input closes.
                    169: .It Fl z
                    170: Specifies that
1.6       aaron     171: .Nm
1.1       deraadt   172: should just scan for listening
1.7       aaron     173: daemons, without sending any data to them.
1.10      ian       174: Diagnostic messages about refused connections will not be displayed unless
1.3       aaron     175: .Fl v
                    176: is specified twice.
1.8       aaron     177: .El
1.1       deraadt   178: .Sh EXAMPLES
                    179: .Bl -tag -width x
                    180: .It Li "nc"
                    181: Wait for the user to type what would normally be command-line
1.10      ian       182: arguments on stdin.
1.1       deraadt   183: .It Li "nc example.host 42"
1.7       aaron     184: Open a TCP connection to port 42 of example.host.
                    185: If the connection
1.1       deraadt   186: fails, do not display any error messages, but simply exit.
                    187: .It Li "nc -p 31337 example.host 42"
                    188: Open a TCP connection to port 42 of example.host, and use port 31337
                    189: as the source port.
                    190: .It Li "nc -w 5 example.host 42"
1.3       aaron     191: Open a TCP connection to port 42 of example.host, and time out after
1.1       deraadt   192: five seconds while attempting to connect.
                    193: .It Li "nc -u example.host 53"
                    194: Send any data from stdin
                    195: to UDP port 53 of example.host, and display any data returned.
                    196: .It Li "nc -s 10.1.2.3 example.host 42"
1.3       aaron     197: Open a TCP connection to port 42 of example.host using 10.1.2.3 as the
                    198: IP for the local end of the connection.
1.1       deraadt   199: .It Li "nc -v example.host 42"
1.3       aaron     200: Open a TCP connection to port 42 of example.host, displaying some
1.1       deraadt   201: diagnostic messages on stderr.
                    202: .It Li "nc -v -v example.host 42"
1.3       aaron     203: Open a TCP connection to port 42 of example.host, displaying all
1.1       deraadt   204: diagnostic messages on stderr.
                    205: .It Li "nc -v -z example.host 20-30"
1.3       aaron     206: Attempt to open TCP connections to ports 20 through 30 of
1.1       deraadt   207: example.host, and report which ones
1.6       aaron     208: .Nm
1.1       deraadt   209: was able to connect to.
                    210: .It Li "nc -v -u -z -w 3 example.host 20-30"
1.3       aaron     211: Send UDP packets to ports 20-30 of example.host, and report which ones
1.1       deraadt   212: did not respond with an ICMP packet after three seconds.
                    213: .It Li "nc -l -p 3000"
                    214: Listen on TCP port 3000, and once there is a connection, send stdin to
                    215: the remote host, and send data from the remote host to stdout.
                    216: .It Li "echo foobar | nc example.host 1000"
                    217: Connect to port 1000 of example.host, send the string "foobar"
                    218: followed by a newline, and move data from port 1000 of example.host to
                    219: stdout until example.host closes the connection.
                    220: .El
                    221: .Sh SEE ALSO
                    222: .Xr cat 1 ,
1.3       aaron     223: .Xr telnet 1
                    224: .Pp
                    225: The
1.1       deraadt   226: .Nm netcat
1.3       aaron     227: .Pa README .
1.1       deraadt   228: .Sh AUTHOR
                    229: *Hobbit*  [hobbit@avian.org]