diff options
Diffstat (limited to 'src/usr.bin/nc/nc.1')
| -rw-r--r-- | src/usr.bin/nc/nc.1 | 212 |
1 files changed, 212 insertions, 0 deletions
diff --git a/src/usr.bin/nc/nc.1 b/src/usr.bin/nc/nc.1 new file mode 100644 index 0000000000..29f506945c --- /dev/null +++ b/src/usr.bin/nc/nc.1 | |||
| @@ -0,0 +1,212 @@ | |||
| 1 | .\" $OpenBSD: nc.1,v 1.26 2003/09/05 16:54:07 jmc Exp $ | ||
| 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 June 25, 2001 | ||
| 29 | .Dt NC 1 | ||
| 30 | .Os | ||
| 31 | .Sh NAME | ||
| 32 | .Nm nc | ||
| 33 | .Nd "arbitrary TCP and UDP connections and listens" | ||
| 34 | .Sh SYNOPSIS | ||
| 35 | .Nm nc | ||
| 36 | .Op Fl 46hklnrtuvzU | ||
| 37 | .Op Fl i Ar interval | ||
| 38 | .Op Fl p Ar source port | ||
| 39 | .Op Fl s Ar source ip address | ||
| 40 | .Op Fl x Ar proxy address Op :port | ||
| 41 | .Op Fl w Ar timeout | ||
| 42 | .Op Fl X Ar socks version | ||
| 43 | .Op Ar hostname | ||
| 44 | .Op Ar port[s] | ||
| 45 | .Sh DESCRIPTION | ||
| 46 | The | ||
| 47 | .Nm | ||
| 48 | (or | ||
| 49 | .Nm netcat ) | ||
| 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. | ||
| 55 | Unlike | ||
| 56 | .Xr telnet 1 , | ||
| 57 | .Nm | ||
| 58 | scripts nicely, and separates error messages onto standard error instead | ||
| 59 | of sending them to standard output, as | ||
| 60 | .Xr telnet 1 | ||
| 61 | does with some. | ||
| 62 | .Pp | ||
| 63 | Destination ports can be single integers or ranges. | ||
| 64 | Ranges are in the form nn-mm. | ||
| 65 | .Pp | ||
| 66 | Common uses include: | ||
| 67 | .Pp | ||
| 68 | .Bl -bullet -offset indent -compact | ||
| 69 | .It | ||
| 70 | simple TCP proxies | ||
| 71 | .It | ||
| 72 | shell\-script based HTTP clients and servers | ||
| 73 | .It | ||
| 74 | network daemon testing | ||
| 75 | .It | ||
| 76 | and much, much more | ||
| 77 | .El | ||
| 78 | .Pp | ||
| 79 | The options are as follows: | ||
| 80 | .Bl -tag -width Ds | ||
| 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 | ||
| 94 | Specifies a delay time interval between lines of text sent and received. | ||
| 95 | Also causes a delay time between connections to multiple ports. | ||
| 96 | .It Fl k | ||
| 97 | Forces | ||
| 98 | .Nm | ||
| 99 | to stay listening for another connection after its current connection | ||
| 100 | is completed. | ||
| 101 | .It Fl l | ||
| 102 | Used to specify that | ||
| 103 | .Nm | ||
| 104 | should listen for an incoming connection rather than initiate a | ||
| 105 | connection to a remote host. | ||
| 106 | .It Fl n | ||
| 107 | Do not do any DNS or service lookups on any specified addresses, | ||
| 108 | hostnames or ports. | ||
| 109 | .It Fl p Ar port | ||
| 110 | Specifies the source port | ||
| 111 | .Nm | ||
| 112 | should use, subject to privilege restrictions and availability. | ||
| 113 | .It Fl r | ||
| 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 | ||
| 116 | assigns them. | ||
| 117 | .It Fl s Ar hostname/ip address | ||
| 118 | Specifies the IP of the interface which is used to send the packets. | ||
| 119 | .It Fl t | ||
| 120 | Causes | ||
| 121 | .Nm | ||
| 122 | to send RFC 854 DON'T and WON'T responses to RFC 854 DO and WILL requests. | ||
| 123 | This makes it possible to use | ||
| 124 | .Nm | ||
| 125 | to script telnet sessions. | ||
| 126 | .It Fl u | ||
| 127 | Use UDP instead of the default option of TCP. | ||
| 128 | .It Fl v | ||
| 129 | Have | ||
| 130 | .Nm | ||
| 131 | give more verbose output. | ||
| 132 | .It Fl w Ar timeout | ||
| 133 | If a connection and stdin are idle for more than | ||
| 134 | .Ar timeout | ||
| 135 | seconds, then the connection is silently closed. | ||
| 136 | The | ||
| 137 | .Fl w | ||
| 138 | flag has no effect on the | ||
| 139 | .Fl l | ||
| 140 | option, i.e.\& | ||
| 141 | .Nm | ||
| 142 | will listen forever for a connection, with or without the | ||
| 143 | .Fl w | ||
| 144 | flag. | ||
| 145 | The default is no timeout. | ||
| 146 | .It Fl x Ar proxy address Op :port | ||
| 147 | Requests that | ||
| 148 | .Nm | ||
| 149 | should connect to | ||
| 150 | .Ar hostname | ||
| 151 | using a SOCKS proxy at address and port. | ||
| 152 | If port is not specified, port 1080 is used. | ||
| 153 | .It Fl z | ||
| 154 | Specifies that | ||
| 155 | .Nm | ||
| 156 | should just scan for listening daemons, without sending any data to them. | ||
| 157 | .It Fl U | ||
| 158 | Specifies to use Unix Domain Sockets. | ||
| 159 | .It Fl X Ar version | ||
| 160 | Requests that | ||
| 161 | .Nm | ||
| 162 | should use the specified version of the SOCKS protocol when talking to | ||
| 163 | a SOCKS proxy. | ||
| 164 | If version is not specified, SOCKS version 5 is used. | ||
| 165 | .El | ||
| 166 | .Sh EXAMPLES | ||
| 167 | .Bl -tag -width x | ||
| 168 | .It Li "$ nc hostname 42" | ||
| 169 | Open a TCP connection to port 42 of hostname. | ||
| 170 | .It Li "$ nc -p 31337 hostname 42" | ||
| 171 | Open a TCP connection to port 42 of hostname, and use port 31337 as | ||
| 172 | the source port. | ||
| 173 | .It Li "$ nc -w 5 hostname 42" | ||
| 174 | Open a TCP connection to port 42 of hostname, and timeout after | ||
| 175 | five seconds while attempting to connect. | ||
| 176 | .It Li "$ nc -u hostname 53" | ||
| 177 | Open a UDP connection to port 53 of hostname. | ||
| 178 | .It Li "$ nc -s 10.1.2.3 example.host 42" | ||
| 179 | Open a TCP connection to port 42 of example.host using 10.1.2.3 as the | ||
| 180 | IP for the local end of the connection. | ||
| 181 | .It Li "$ nc -v hostname 42" | ||
| 182 | Open a TCP connection to port 42 of hostname, displaying some | ||
| 183 | diagnostic messages on stderr. | ||
| 184 | .It Li "$ nc -v -z hostname 20-30" | ||
| 185 | Attempt to open TCP connections to ports 20 through 30 of | ||
| 186 | hostname, and report which ones | ||
| 187 | .Nm | ||
| 188 | was able to connect to. | ||
| 189 | .It Li "$ nc -v -u -z -w 3 hostname 20-30" | ||
| 190 | Send UDP packets to ports 20-30 of example.host, and report which ones | ||
| 191 | did not respond with an ICMP packet after three seconds. | ||
| 192 | .It Li "$ nc -l 3000" | ||
| 193 | Listen on TCP port 3000, and once there is a connection, send stdin to | ||
| 194 | the remote host, and send data from the remote host to stdout. | ||
| 195 | .It Li "$ echo foobar | nc hostname 1000" | ||
| 196 | Connect to port 1000 of hostname, send the string "foobar" | ||
| 197 | followed by a newline, and move data from port 1000 of hostname to | ||
| 198 | stdout until hostname closes the connection. | ||
| 199 | .It Li "$ nc -U /var/tmp/dsocket" | ||
| 200 | Connect to a Unix Domain Socket. | ||
| 201 | .It Li "$ nc -lU /var/tmp/dsocket" | ||
| 202 | Create and listen on a Unix Domain Socket. | ||
| 203 | .El | ||
| 204 | .Sh SEE ALSO | ||
| 205 | .Xr cat 1 , | ||
| 206 | .Xr telnet 1 | ||
| 207 | .Sh AUTHORS | ||
| 208 | Original implementation by *Hobbit* | ||
| 209 | .Aq hobbit@avian.org . | ||
| 210 | .Pp | ||
| 211 | Rewritten with IPv6 support by Eric Jackson | ||
| 212 | .Aq ericj@monkey.org . | ||
