summaryrefslogtreecommitdiff
path: root/src/usr.bin/nc/nc.1
diff options
context:
space:
mode:
authorericj <>2001-06-26 06:55:06 +0000
committerericj <>2001-06-26 06:55:06 +0000
commit189642a183446e4622656043980cd1d6514accba (patch)
tree9d1c8b9179a8565e7f8a1ea54a2453bbbe69ef1e /src/usr.bin/nc/nc.1
parentc1a04a96f0f90d6447fb2b5ce7c4fc1d4d6deadb (diff)
downloadopenbsd-189642a183446e4622656043980cd1d6514accba.tar.gz
openbsd-189642a183446e4622656043980cd1d6514accba.tar.bz2
openbsd-189642a183446e4622656043980cd1d6514accba.zip
update this man page for the new netcat
Diffstat (limited to 'src/usr.bin/nc/nc.1')
-rw-r--r--src/usr.bin/nc/nc.1184
1 files changed, 67 insertions, 117 deletions
diff --git a/src/usr.bin/nc/nc.1 b/src/usr.bin/nc/nc.1
index b7343d5e57..c659d2b2b9 100644
--- a/src/usr.bin/nc/nc.1
+++ b/src/usr.bin/nc/nc.1
@@ -1,4 +1,4 @@
1.\" $OpenBSD: nc.1,v 1.12 2001/05/04 01:38:31 millert Exp $ 1.\" $OpenBSD: nc.1,v 1.13 2001/06/26 06:55:06 ericj Exp $
2.\" 2.\"
3.\" Copyright (c) 1996 David Sacerdote 3.\" Copyright (c) 1996 David Sacerdote
4.\" All rights reserved. 4.\" All rights reserved.
@@ -25,7 +25,7 @@
25.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 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. 26.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27.\" 27.\"
28.Dd August 1, 1996 28.Dd June 25, 2001
29.Dt NC 1 29.Dt NC 1
30.Os 30.Os
31.Sh NAME 31.Sh NAME
@@ -33,39 +33,33 @@
33.Nd "arbitrary TCP and UDP connections and listens" 33.Nd "arbitrary TCP and UDP connections and listens"
34.Sh SYNOPSIS 34.Sh SYNOPSIS
35.Nm nc 35.Nm nc
36.Op Fl lnrtuvz 36.Op Fl 46hklnrtuvz
37.Op Fl g Ar intermediates
38.Op Fl G Ar hopcount
39.Op Fl i Ar interval 37.Op Fl i Ar interval
40.Op Fl o Ar filename
41.Op Fl p Ar source port 38.Op Fl p Ar source port
42.Op Fl s Ar ip address 39.Op Fl s Ar source ip address
43.Op Fl w Ar timeout 40.Op Fl w Ar timeout
44.Op Ar hostname 41.Op Ar hostname
45.Op Ar port[s...] 42.Op Ar port[s]
46.Sh DESCRIPTION 43.Sh DESCRIPTION
47The 44The
48.Nm 45.Nm
49(or 46(or
50.Nm netcat ) 47.Nm netcat )
51utility is used for just about anything under the sun 48utility is used for just about anything under the sun involving TCP
52involving TCP or UDP. 49or UDP.
53It can open TCP connections, send UDP packets, 50It can open TCP connections, send UDP packets, listen on arbitrary
54listen on arbitrary TCP and UDP ports, do port scanning, and source 51TCP and UDP ports, do port scanning, and deal with both IPv4 and
55routing. 52IPv6.
56Unlike 53Unlike
57.Xr telnet 1 , 54.Xr telnet 1 ,
58.Nm 55.Nm
59scripts nicely, and separates error messages onto standard error instead 56scripts nicely, and separates error messages onto standard error instead
60of sending them to standard output, as 57of sending them to standard output, as
61.Xr telnet 1 58.Xr telnet 1 ,
62does with some. 59does with some.
63.Pp 60.Pp
64Destination ports can be single integers, names as listed in 61Destination ports can be single integers or ranges.
65.Xr services 5 , 62Ranges are in the form nn-mm.
66or ranges.
67Ranges are in the form nn-mm, and several separate ports and/or
68ranges may be specified on the command line.
69.Pp 63.Pp
70Common uses include: 64Common uses include:
71.Pp 65.Pp
@@ -77,153 +71,109 @@ shell\-script based HTTP clients and servers
77.It 71.It
78network daemon testing 72network daemon testing
79.It 73.It
80source routing based connectivity testing 74network daemon testing
81.It 75.It
82and much, much more 76and much, much more
83.El 77.El
84.Pp 78.Pp
85The options are as follows: 79The options are as follows:
86.Bl -tag -width Ds 80.Bl -tag -width Ds
87.It Fl g Ar intermediate-host 81.It Fl 4
88Specifies a hop along a loose source routed path. 82Forces
89Can be used more than once to build a chain of hop points. 83.Nm
90.It Fl G Ar pointer 84to use IPv4 addresses only.
91Positions the 85.It Fl 6
92.Dq hop counter 86Forces
93within the list of machines in the path of a source routed packet. 87.Nm
94Must be a multiple of 4. 88to use IPv6 addresses only.
95.It Fl i Ar seconds 89.It Fl h
90Prints out
91.Nm
92help.
93.It Fl i Ar interval
96Specifies a delay time interval between lines of text sent and received. 94Specifies a delay time interval between lines of text sent and received.
97Also causes a delay time between connections to multiple ports. 95Also causes a delay time between connections to multiple ports.
96.It Fl k
97Forces
98.Nm
99to stay listen for another connection after it's current connection
100is completed.
98.It Fl l 101.It Fl l
99Is used to specify that 102Used to specify that
100.Nm 103.Nm
101should listen for an incoming connection, rather than initiate a 104should listen for an incoming connection rather than initiate a
102connection to a remote host. 105connection to a remote host.
103Any hostname/IP address and port arguments
104restrict the source of inbound connections to only that address and
105source port.
106.It Fl n 106.It Fl n
107Do not do DNS lookups on any of the specified addresses or hostnames, or 107Do not do any DNS or service lookups on any specified addresses or
108names of port numbers from /etc/services. 108hostnames, or ports.
109.It Fl o Ar filename
110Create a hexadecimal log of data transferred in the specified file.
111Each line begins with
112.Ql <
113or
114.Ql > .
115.Ql <
116means
117.Dq from the net
118and
119.Ql >
120means
121.Dq to the net .
122.It Fl p Ar port 109.It Fl p Ar port
123Specifies the source port 110Specifies the source port
124.Nm 111.Nm
125should use, subject to privilege restrictions and availability. 112should use, subject to privilege restrictions and availability.
126.It Fl r 113.It Fl r
127Specifies that source and/or destination ports should be chosen semi-randomly 114Specifies that source and/or destination ports should be chosen randomly
128instead of sequentially within a range or in the order that the 115instead of sequentially within a range or in the order that the system
129system assigns. 116assigns.
130.It Fl s Ar hostname/ip-address 117.It Fl s Ar hostname/ip address
131Specifies the IP of the interface which is used to send the packets. 118Specifies the IP of the interface which is used to send the packets.
132On some platforms, this can be used for UDP spoofing by using
133.Xr ifconfig 8
134to bring up a dummy interface with the desired source IP address.
135.It Fl t 119.It Fl t
136Causes 120Causes
137.Nm 121.Nm
138to send RFC854 DON'T and WON'T responses to RFC854 DO 122to send RFC854 DON'T and WON'T responses to RFC854 DO and WILL requests.
139and WILL requests.
140This makes it possible to use 123This makes it possible to use
141.Nm 124.Nm
142to script telnet sessions. 125to script telnet sessions.
143The presence of this option can be
144enabled or disabled as a compile-time option.
145.It Fl u 126.It Fl u
146Use UDP instead of TCP. 127Use UDP instead of the default option of TCP.
147On most platforms,
148.Nm
149will behave as if a connection is established until it receives an
150ICMP packet indicating that there is no program listening to what it
151sends.
152.It Fl v 128.It Fl v
153Verbose. 129Have
154Cause
155.Nm
156to display connection information.
157Using
158.Fl v
159more than once will cause
160.Nm 130.Nm
161to become even more verbose. 131give more verbose output.
162.It Fl w Ar timeout
163Specifies the number of seconds
164.Nm
165should wait before deciding that
166an attempt to establish a connection is hopeless.
167Also used to specify how long to wait for more network data after standard
168input closes.
169.It Fl z 132.It Fl z
170Specifies that 133Specifies that
171.Nm 134.Nm
172should just scan for listening 135should just scan for listening daemons, without sending any data to them.
173daemons, without sending any data to them.
174Diagnostic messages about refused connections will not be displayed unless
175.Fl v
176is specified twice.
177.El 136.El
178.Sh EXAMPLES 137.Sh EXAMPLES
179.Bl -tag -width x 138.Bl -tag -width x
180.It Li "nc" 139.It Li "nc hostname 42"
181Wait for the user to type what would normally be command-line 140Open a TCP connection to port 42 of hostname.
182arguments on stdin. 141.It Li "nc -p 31337 hostname 42"
183.It Li "nc example.host 42" 142Open a TCP connection to port 42 of hostname, and use port 31337 as
184Open a TCP connection to port 42 of example.host. 143the source port.
185If the connection 144.It Li "nc -w 5 hostname 42"
186fails, do not display any error messages, but simply exit. 145Open a TCP connection to port 42 of hostname, and timeout after
187.It Li "nc -p 31337 example.host 42"
188Open a TCP connection to port 42 of example.host, and use port 31337
189as the source port.
190.It Li "nc -w 5 example.host 42"
191Open a TCP connection to port 42 of example.host, and time out after
192five seconds while attempting to connect. 146five seconds while attempting to connect.
193.It Li "nc -u example.host 53" 147.It Li "nc -u hostname 53"
194Send any data from stdin 148Open a UDP connection to port 53 of hostname.
195to UDP port 53 of example.host, and display any data returned.
196.It Li "nc -s 10.1.2.3 example.host 42" 149.It Li "nc -s 10.1.2.3 example.host 42"
197Open a TCP connection to port 42 of example.host using 10.1.2.3 as the 150Open a TCP connection to port 42 of example.host using 10.1.2.3 as the
198IP for the local end of the connection. 151IP for the local end of the connection.
199.It Li "nc -v example.host 42" 152.It Li "nc -v hostname 42"
200Open a TCP connection to port 42 of example.host, displaying some 153Open a TCP connection to port 42 of hostname, displaying some
201diagnostic messages on stderr. 154diagnostic messages on stderr.
202.It Li "nc -v -v example.host 42" 155.It Li "nc -v -v hostname 42"
203Open a TCP connection to port 42 of example.host, displaying all 156Open a TCP connection to port 42 of hostname, displaying all
204diagnostic messages on stderr. 157diagnostic messages on stderr.
205.It Li "nc -v -z example.host 20-30" 158.It Li "nc -v -z hostname 20-30"
206Attempt to open TCP connections to ports 20 through 30 of 159Attempt to open TCP connections to ports 20 through 30 of
207example.host, and report which ones 160hostname , and report which ones
208.Nm 161.Nm
209was able to connect to. 162was able to connect to.
210.It Li "nc -v -u -z -w 3 example.host 20-30" 163.It Li "nc -v -u -z -w 3 hostname 20-30"
211Send UDP packets to ports 20-30 of example.host, and report which ones 164Send UDP packets to ports 20-30 of example.host, and report which ones
212did not respond with an ICMP packet after three seconds. 165did not respond with an ICMP packet after three seconds.
213.It Li "nc -l -p 3000" 166.It Li "nc -l -p 3000"
214Listen on TCP port 3000, and once there is a connection, send stdin to 167Listen on TCP port 3000, and once there is a connection, send stdin to
215the remote host, and send data from the remote host to stdout. 168the remote host, and send data from the remote host to stdout.
216.It Li "echo foobar | nc example.host 1000" 169.It Li "echo foobar | nc hostname 1000"
217Connect to port 1000 of example.host, send the string "foobar" 170Connect to port 1000 of hostname, send the string "foobar"
218followed by a newline, and move data from port 1000 of example.host to 171followed by a newline, and move data from port 1000 of hostname to
219stdout until example.host closes the connection. 172stdout until hostname closes the connection.
220.El 173.El
221.Sh SEE ALSO 174.Sh SEE ALSO
222.Xr cat 1 , 175.Xr cat 1 ,
223.Xr telnet 1 176.Xr telnet 1
224.Pp
225The
226.Nm netcat
227.Pa README .
228.Sh AUTHOR 177.Sh AUTHOR
229*Hobbit* [hobbit@avian.org] 178Original implementation by *Hobbit* [hobbit@avian.org].
179Rewritten with IPv6 support by Eric Jackson <ericj@monkey.org>.