[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.18

1.18    ! krw         1: .\"     $OpenBSD: nc.1,v 1.17 2001/08/30 13:21:50 krw 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: .\"
1.13      ericj      28: .Dd June 25, 2001
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.13      ericj      36: .Op Fl 46hklnrtuvz
1.1       deraadt    37: .Op Fl i Ar interval
1.6       aaron      38: .Op Fl p Ar source port
1.13      ericj      39: .Op Fl s Ar source ip address
1.6       aaron      40: .Op Fl w Ar timeout
1.1       deraadt    41: .Op Ar hostname
1.13      ericj      42: .Op Ar port[s]
1.1       deraadt    43: .Sh DESCRIPTION
                     44: The
1.6       aaron      45: .Nm
1.1       deraadt    46: (or
                     47: .Nm netcat )
1.13      ericj      48: utility is used for just about anything under the sun involving TCP
                     49: or UDP.
                     50: It can open TCP connections, send UDP packets, listen on arbitrary
                     51: TCP and UDP ports, do port scanning, and deal with both IPv4 and
                     52: IPv6.
1.7       aaron      53: Unlike
1.1       deraadt    54: .Xr telnet 1 ,
1.6       aaron      55: .Nm
1.1       deraadt    56: scripts nicely, and separates error messages onto standard error instead
1.6       aaron      57: of sending them to standard output, as
1.13      ericj      58: .Xr telnet 1 ,
1.6       aaron      59: does with some.
1.1       deraadt    60: .Pp
1.13      ericj      61: Destination ports can be single integers or ranges.
                     62: Ranges are in the form nn-mm.
1.1       deraadt    63: .Pp
                     64: Common uses include:
1.7       aaron      65: .Pp
                     66: .Bl -bullet -offset indent -compact
1.1       deraadt    67: .It
1.3       aaron      68: simple TCP proxies
1.1       deraadt    69: .It
1.3       aaron      70: shell\-script based HTTP clients and servers
1.1       deraadt    71: .It
1.13      ericj      72: network daemon testing
1.1       deraadt    73: .It
                     74: and much, much more
                     75: .El
                     76: .Pp
                     77: The options are as follows:
                     78: .Bl -tag -width Ds
1.13      ericj      79: .It Fl 4
                     80: Forces
                     81: .Nm
                     82: to use IPv4 addresses only.
                     83: .It Fl 6
                     84: Forces
                     85: .Nm
                     86: to use IPv6 addresses only.
                     87: .It Fl h
                     88: Prints out
                     89: .Nm
                     90: help.
                     91: .It Fl i Ar interval
1.1       deraadt    92: Specifies a delay time interval between lines of text sent and received.
                     93: Also causes a delay time between connections to multiple ports.
1.13      ericj      94: .It Fl k
                     95: Forces
                     96: .Nm
1.14      jasoni     97: to stay listening for another connection after it's current connection
1.13      ericj      98: is completed.
1.1       deraadt    99: .It Fl l
1.13      ericj     100: Used to specify that
1.6       aaron     101: .Nm
1.13      ericj     102: should listen for an incoming connection rather than initiate a
1.7       aaron     103: connection to a remote host.
1.1       deraadt   104: .It Fl n
1.13      ericj     105: Do not do any DNS or service lookups on any specified addresses or
                    106: hostnames, or ports.
1.1       deraadt   107: .It Fl p Ar port
                    108: Specifies the source port
1.6       aaron     109: .Nm
1.1       deraadt   110: should use, subject to privilege restrictions and availability.
                    111: .It Fl r
1.13      ericj     112: Specifies that source and/or destination ports should be chosen randomly
                    113: instead of sequentially within a range or in the order that the system
                    114: assigns.
                    115: .It Fl s Ar hostname/ip address
1.3       aaron     116: Specifies the IP of the interface which is used to send the packets.
1.1       deraadt   117: .It Fl t
                    118: Causes
1.6       aaron     119: .Nm
1.13      ericj     120: to send RFC854 DON'T and WON'T responses to RFC854 DO and WILL requests.
1.7       aaron     121: This makes it possible to use
1.6       aaron     122: .Nm
1.7       aaron     123: to script telnet sessions.
1.1       deraadt   124: .It Fl u
1.13      ericj     125: Use UDP instead of the default option of TCP.
1.1       deraadt   126: .It Fl v
1.13      ericj     127: Have
1.6       aaron     128: .Nm
1.13      ericj     129: give more verbose output.
1.1       deraadt   130: .It Fl z
                    131: Specifies that
1.6       aaron     132: .Nm
1.13      ericj     133: should just scan for listening daemons, without sending any data to them.
1.8       aaron     134: .El
1.1       deraadt   135: .Sh EXAMPLES
                    136: .Bl -tag -width x
1.13      ericj     137: .It Li "nc hostname 42"
                    138: Open a TCP connection to port 42 of hostname.
                    139: .It Li "nc -p 31337 hostname 42"
                    140: Open a TCP connection to port 42 of hostname, and use port 31337 as
                    141: the source port.
                    142: .It Li "nc -w 5 hostname 42"
                    143: Open a TCP connection to port 42 of hostname, and timeout after
1.1       deraadt   144: five seconds while attempting to connect.
1.13      ericj     145: .It Li "nc -u hostname 53"
                    146: Open a UDP connection to port 53 of hostname.
1.1       deraadt   147: .It Li "nc -s 10.1.2.3 example.host 42"
1.3       aaron     148: Open a TCP connection to port 42 of example.host using 10.1.2.3 as the
                    149: IP for the local end of the connection.
1.13      ericj     150: .It Li "nc -v hostname 42"
                    151: Open a TCP connection to port 42 of hostname, displaying some
1.1       deraadt   152: diagnostic messages on stderr.
1.13      ericj     153: .It Li "nc -v -v hostname 42"
                    154: Open a TCP connection to port 42 of hostname, displaying all
1.1       deraadt   155: diagnostic messages on stderr.
1.13      ericj     156: .It Li "nc -v -z hostname 20-30"
1.3       aaron     157: Attempt to open TCP connections to ports 20 through 30 of
1.17      krw       158: hostname, and report which ones
1.6       aaron     159: .Nm
1.1       deraadt   160: was able to connect to.
1.13      ericj     161: .It Li "nc -v -u -z -w 3 hostname 20-30"
1.3       aaron     162: Send UDP packets to ports 20-30 of example.host, and report which ones
1.1       deraadt   163: did not respond with an ICMP packet after three seconds.
1.16      ericj     164: .It Li "nc -l 3000"
1.1       deraadt   165: Listen on TCP port 3000, and once there is a connection, send stdin to
                    166: the remote host, and send data from the remote host to stdout.
1.13      ericj     167: .It Li "echo foobar | nc hostname 1000"
                    168: Connect to port 1000 of hostname, send the string "foobar"
                    169: followed by a newline, and move data from port 1000 of hostname to
                    170: stdout until hostname closes the connection.
1.1       deraadt   171: .El
                    172: .Sh SEE ALSO
                    173: .Xr cat 1 ,
1.3       aaron     174: .Xr telnet 1
1.15      smart     175: .Sh AUTHORS
                    176: Original implementation by *Hobbit*
                    177: .Aq hobbit@avian.org .
                    178: .Pp
                    179: Rewritten with IPv6 support by Eric Jackson
                    180: .Aq ericj@monkey.org .