summaryrefslogtreecommitdiff
path: root/src/usr.bin/nc/nc.1
diff options
context:
space:
mode:
Diffstat (limited to 'src/usr.bin/nc/nc.1')
-rw-r--r--src/usr.bin/nc/nc.1215
1 files changed, 215 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..8d87051c73
--- /dev/null
+++ b/src/usr.bin/nc/nc.1
@@ -0,0 +1,215 @@
1.\" $OpenBSD: nc.1,v 1.5 1998/09/28 06:57:35 millert 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 August 1, 1996
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 e Ar command
37.Op Fl g Ar intermediates
38.Op Fl G Ar hopcount
39.Op Fl i Ar interval
40.Op Fl lnrtuvz
41.Op Fl o Ar filename
42.Op Fl p Ar source port
43.Op Fl s Ar ip address
44.Op Fl w Ar timeout
45.Op Ar hostname
46.Op Ar port[s...]
47.Sh DESCRIPTION
48The
49.Nm nc
50(or
51.Nm netcat )
52utility is used for just about anything under the sun
53involving TCP or UDP. It can open TCP connections, send UDP packets,
54listen on arbitrary TCP and UDP ports, do port scanning, and source
55routing. Unlike
56.Xr telnet 1 ,
57.Nm nc
58scripts nicely, and separates error messages onto standard error instead
59of sending them to standard output, as
60.Xr telnet 1
61does with some.
62.Pp
63Destination ports can be single integers, names as listed in
64.Xr services 5 ,
65or ranges. Ranges are in the form nn-mm, and several separate ports and/or
66ranges may be specified on the command line.
67.Pp
68Common uses include:
69.Bl -bullet
70.It
71simple TCP proxies
72.It
73shell\-script based HTTP clients and servers
74.It
75network daemon testing
76.It
77source routing based connectivity testing
78.It
79and much, much more
80.El
81.Pp
82The options are as follows:
83.Bl -tag -width Ds
84.It Fl e Ar command
85Execute the specified command, using data from the network for stdin,
86and sending stdout and stderr to the network. This option is only present if
87.Nm nc
88was compiled with the GAPING_SECURITY_HOLE compile time option, since it
89allows users to make arbitrary programs available to anyone on the network.
90.It Fl g Ar intermediate-host
91Specifies a hop along a loose source routed path. Can be used more than
92once to build a chain of hop points.
93.It Fl G Ar pointer
94Positions the "hop counter" within the list of machines in the path of
95a source routed packet. Must be a multiple of 4.
96.It Fl i Ar seconds
97Specifies a delay time interval between lines of text sent and received.
98Also causes a delay time between connections to multiple ports.
99.It Fl l
100Is used to specify that
101.Nm nc
102should listen for an incoming connection, rather than initiate a
103connection to a remote host. Any hostname/IP address and port arguments
104restrict the source of inbound connections to only that address and
105source port.
106.It Fl n
107Do not do DNS lookups on any of the specified addresses or hostnames, or
108names of port numbers from /etc/services.
109.It Fl o Ar filename
110Create a hexadecimal log of data transferred in the specified file.
111Each line begins with ``<'' or ``>''. ``<'' means "from the net" and ``>''
112means "to the net".
113.It Fl p Ar port
114Specifies the source port
115.Nm nc
116should use, subject to privilege restrictions and availability.
117.It Fl r
118Specifies that source and/or destination ports should be chosen semi-randomly
119instead of sequentially within a range or in the order that the
120system assigns.
121.It Fl s Ar hostname/ip-address
122Specifies the IP of the interface which is used to send the packets.
123On some platforms, this can be used for UDP spoofing by using
124.Xr ifconfig 8
125to bring up a dummy interface with the desired source IP address.
126.It Fl t
127Causes
128.Nm nc
129to send RFC854 DON'T and WON'T responses to RFC854 DO
130and WILL requests. This makes it possible to use
131.Nm nc
132to script telnet sessions. The presence of this option can be
133enabled or disabled as a compile-time option.
134.It Fl u
135Use UDP instead of TCP.
136On most platforms,
137.Nm nc
138will behave as if a connection is established until it receives an
139ICMP packet indicating that there is no program listening to what it
140sends.
141.It Fl v
142Verbose. Cause
143.Nm nc
144to display connection information. Using
145.Fl v
146more than once will cause
147.Nm nc
148to become even more verbose.
149.It Fl w Ar timeout
150Specifies the number of seconds
151.Nm nc
152should wait before deciding that
153an attempt to establish a connection is hopeless.
154Also used to specify how long to wait for more network data after standard
155input closes.
156.It Fl z
157Specifies that
158.Nm nc
159should just scan for listening
160daemons, without sending any data to them. Diagnostic messages about refused
161connections will not be
162displayed unless
163.Fl v
164is specified twice.
165.Sh EXAMPLES
166.Bl -tag -width x
167.It Li "nc"
168Wait for the user to type what would normally be command-line
169arguments in at stdin.
170.It Li "nc example.host 42"
171Open a TCP connection to port 42 of example.host. If the connection
172fails, do not display any error messages, but simply exit.
173.It Li "nc -p 31337 example.host 42"
174Open a TCP connection to port 42 of example.host, and use port 31337
175as the source port.
176.It Li "nc -w 5 example.host 42"
177Open a TCP connection to port 42 of example.host, and time out after
178five seconds while attempting to connect.
179.It Li "nc -u example.host 53"
180Send any data from stdin
181to UDP port 53 of example.host, and display any data returned.
182.It Li "nc -s 10.1.2.3 example.host 42"
183Open a TCP connection to port 42 of example.host using 10.1.2.3 as the
184IP for the local end of the connection.
185.It Li "nc -v example.host 42"
186Open a TCP connection to port 42 of example.host, displaying some
187diagnostic messages on stderr.
188.It Li "nc -v -v example.host 42"
189Open a TCP connection to port 42 of example.host, displaying all
190diagnostic messages on stderr.
191.It Li "nc -v -z example.host 20-30"
192Attempt to open TCP connections to ports 20 through 30 of
193example.host, and report which ones
194.Nm nc
195was able to connect to.
196.It Li "nc -v -u -z -w 3 example.host 20-30"
197Send UDP packets to ports 20-30 of example.host, and report which ones
198did not respond with an ICMP packet after three seconds.
199.It Li "nc -l -p 3000"
200Listen on TCP port 3000, and once there is a connection, send stdin to
201the remote host, and send data from the remote host to stdout.
202.It Li "echo foobar | nc example.host 1000"
203Connect to port 1000 of example.host, send the string "foobar"
204followed by a newline, and move data from port 1000 of example.host to
205stdout until example.host closes the connection.
206.El
207.Sh SEE ALSO
208.Xr cat 1 ,
209.Xr telnet 1
210.Pp
211The
212.Nm netcat
213.Pa README .
214.Sh AUTHOR
215*Hobbit* [hobbit@avian.org]