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

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