version 1.5, 1998/09/28 06:57:35 |
version 1.6, 1999/06/05 01:21:34 |
|
|
.Op Fl i Ar interval |
.Op Fl i Ar interval |
.Op Fl lnrtuvz |
.Op Fl lnrtuvz |
.Op Fl o Ar filename |
.Op Fl o Ar filename |
.Op Fl p Ar source port |
.Op Fl p Ar source port |
.Op Fl s Ar ip address |
.Op Fl s Ar ip address |
.Op Fl w Ar timeout |
.Op Fl w Ar timeout |
.Op Ar hostname |
.Op Ar hostname |
.Op Ar port[s...] |
.Op Ar port[s...] |
.Sh DESCRIPTION |
.Sh DESCRIPTION |
The |
The |
.Nm nc |
.Nm |
(or |
(or |
.Nm netcat ) |
.Nm netcat ) |
utility is used for just about anything under the sun |
utility is used for just about anything under the sun |
|
|
listen on arbitrary TCP and UDP ports, do port scanning, and source |
listen on arbitrary TCP and UDP ports, do port scanning, and source |
routing. Unlike |
routing. Unlike |
.Xr telnet 1 , |
.Xr telnet 1 , |
.Nm nc |
.Nm |
scripts nicely, and separates error messages onto standard error instead |
scripts nicely, and separates error messages onto standard error instead |
of sending them to standard output, as |
of sending them to standard output, as |
.Xr telnet 1 |
.Xr telnet 1 |
does with some. |
does with some. |
.Pp |
.Pp |
Destination ports can be single integers, names as listed in |
Destination ports can be single integers, names as listed in |
.Xr services 5 , |
.Xr services 5 , |
|
|
ranges may be specified on the command line. |
ranges may be specified on the command line. |
.Pp |
.Pp |
Common uses include: |
Common uses include: |
.Bl -bullet |
.Bl -bullet |
.It |
.It |
simple TCP proxies |
simple TCP proxies |
.It |
.It |
|
|
.It Fl e Ar command |
.It Fl e Ar command |
Execute the specified command, using data from the network for stdin, |
Execute the specified command, using data from the network for stdin, |
and sending stdout and stderr to the network. This option is only present if |
and sending stdout and stderr to the network. This option is only present if |
.Nm nc |
.Nm |
was compiled with the GAPING_SECURITY_HOLE compile time option, since it |
was compiled with the GAPING_SECURITY_HOLE compile time option, since it |
allows users to make arbitrary programs available to anyone on the network. |
allows users to make arbitrary programs available to anyone on the network. |
.It Fl g Ar intermediate-host |
.It Fl g Ar intermediate-host |
|
|
Also causes a delay time between connections to multiple ports. |
Also causes a delay time between connections to multiple ports. |
.It Fl l |
.It Fl l |
Is used to specify that |
Is used to specify that |
.Nm nc |
.Nm |
should listen for an incoming connection, rather than initiate a |
should listen for an incoming connection, rather than initiate a |
connection to a remote host. Any hostname/IP address and port arguments |
connection to a remote host. Any hostname/IP address and port arguments |
restrict the source of inbound connections to only that address and |
restrict the source of inbound connections to only that address and |
|
|
means "to the net". |
means "to the net". |
.It Fl p Ar port |
.It Fl p Ar port |
Specifies the source port |
Specifies the source port |
.Nm nc |
.Nm |
should use, subject to privilege restrictions and availability. |
should use, subject to privilege restrictions and availability. |
.It Fl r |
.It Fl r |
Specifies that source and/or destination ports should be chosen semi-randomly |
Specifies that source and/or destination ports should be chosen semi-randomly |
|
|
to bring up a dummy interface with the desired source IP address. |
to bring up a dummy interface with the desired source IP address. |
.It Fl t |
.It Fl t |
Causes |
Causes |
.Nm nc |
.Nm |
to send RFC854 DON'T and WON'T responses to RFC854 DO |
to send RFC854 DON'T and WON'T responses to RFC854 DO |
and WILL requests. This makes it possible to use |
and WILL requests. This makes it possible to use |
.Nm nc |
.Nm |
to script telnet sessions. The presence of this option can be |
to script telnet sessions. The presence of this option can be |
enabled or disabled as a compile-time option. |
enabled or disabled as a compile-time option. |
.It Fl u |
.It Fl u |
Use UDP instead of TCP. |
Use UDP instead of TCP. |
On most platforms, |
On most platforms, |
.Nm nc |
.Nm |
will behave as if a connection is established until it receives an |
will behave as if a connection is established until it receives an |
ICMP packet indicating that there is no program listening to what it |
ICMP packet indicating that there is no program listening to what it |
sends. |
sends. |
.It Fl v |
.It Fl v |
Verbose. Cause |
Verbose. Cause |
.Nm nc |
.Nm |
to display connection information. Using |
to display connection information. Using |
.Fl v |
.Fl v |
more than once will cause |
more than once will cause |
.Nm nc |
.Nm |
to become even more verbose. |
to become even more verbose. |
.It Fl w Ar timeout |
.It Fl w Ar timeout |
Specifies the number of seconds |
Specifies the number of seconds |
.Nm nc |
.Nm |
should wait before deciding that |
should wait before deciding that |
an attempt to establish a connection is hopeless. |
an attempt to establish a connection is hopeless. |
Also used to specify how long to wait for more network data after standard |
Also used to specify how long to wait for more network data after standard |
input closes. |
input closes. |
.It Fl z |
.It Fl z |
Specifies that |
Specifies that |
.Nm nc |
.Nm |
should just scan for listening |
should just scan for listening |
daemons, without sending any data to them. Diagnostic messages about refused |
daemons, without sending any data to them. Diagnostic messages about refused |
connections will not be |
connections will not be |
|
|
.It Li "nc -v -z example.host 20-30" |
.It Li "nc -v -z example.host 20-30" |
Attempt to open TCP connections to ports 20 through 30 of |
Attempt to open TCP connections to ports 20 through 30 of |
example.host, and report which ones |
example.host, and report which ones |
.Nm nc |
.Nm |
was able to connect to. |
was able to connect to. |
.It Li "nc -v -u -z -w 3 example.host 20-30" |
.It Li "nc -v -u -z -w 3 example.host 20-30" |
Send UDP packets to ports 20-30 of example.host, and report which ones |
Send UDP packets to ports 20-30 of example.host, and report which ones |