version 1.2, 1998/03/11 18:42:23 |
version 1.3, 1998/09/27 16:57:47 |
|
|
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
.\" |
.\" |
.Dd August 1, 1996 |
.Dd August 1, 1996 |
.Dt nc 1 |
.Dt NC 1 |
.Sh NAME |
.Sh NAME |
.Os |
.Os |
.Nm nc |
.Nm nc |
.Nd |
.Nd arbitrary TCP and UDP connections and listens |
Arbitrary tcp and udp connections and listens. |
|
.Pp |
.Pp |
.Sh SYNOPSIS |
.Sh SYNOPSIS |
.Nm nc |
.Nm nc |
|
|
(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 |
involving TCP or UDP. It can open tcp connections, send udp packets, |
involving TCP or UDP. It can open TCP connections, send UDP packets, |
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 nc |
|
|
Common uses include: |
Common uses include: |
.Bl -bullet |
.Bl -bullet |
.It |
.It |
simple tcp proxies |
simple TCP proxies |
.It |
.It |
shell\-script based http clients and servers |
shell\-script based HTTP clients and servers |
.It |
.It |
network daemon testing |
network daemon testing |
.It |
.It |
|
|
Is used to specify that |
Is used to specify that |
.Nm nc |
.Nm nc |
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 |
source port. |
source port. |
.It Fl n |
.It Fl n |
|
|
names of port numbers from /etc/services. |
names of port numbers from /etc/services. |
.It Fl o Ar filename |
.It Fl o Ar filename |
Create a hexadecimal log of data transferred in the specified file. |
Create a hexadecimal log of data transferred in the specified file. |
Each line begins with < or >. < means "from the net" and > means |
Each line begins with ``<'' or ``>''. ``<'' means "from the net" and ``>'' |
"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 nc |
should use, subject to privilege restrictions and availability. |
should use, subject to privilege restrictions and availability. |
.It Fl r |
.It Fl r |
Specified that source and/or destination ports should be chosen semi-randomly |
Specifies that source and/or destination ports should be chosen semi-randomly |
instead of sequentially within a range or in the order that the |
instead of sequentially within a range or in the order that the |
system assigns. |
system assigns. |
.It Fl s Ar hostname/ip-address |
.It Fl s Ar hostname/ip-address |
Specifies the ip of the interface which is used to send the packets. |
Specifies the IP of the interface which is used to send the packets. |
On some platforms, this can be used for udp spoofing by using ifconfig |
On some platforms, this can be used for UDP spoofing by using |
to bring up a dummy interface with the desired source ip address. |
.Xr ifconfig 8 |
|
to bring up a dummy interface with the desired source IP address. |
.It Fl t |
.It Fl t |
Causes |
Causes |
.Nm nc |
.Nm nc |
|
|
.It Fl v |
.It Fl v |
Verbose. Cause |
Verbose. Cause |
.Nm nc |
.Nm nc |
to display connection information. Using \-v |
to display connection information. Using |
|
.Fl v |
more than once will cause |
more than once will cause |
.Nm nc |
.Nm nc |
to become even more verbose. |
to become even more verbose. |
|
|
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 |
displayed unless \-v is specified twice. |
displayed unless |
|
.Fl v |
|
is specified twice. |
.Sh EXAMPLES |
.Sh EXAMPLES |
.Pp |
|
.Bl -tag -width x |
.Bl -tag -width x |
.It Li "nc" |
.It Li "nc" |
Wait for the user to type what would normally be command-line |
Wait for the user to type what would normally be command-line |
|
|
Open a TCP connection to port 42 of example.host, and use port 31337 |
Open a TCP connection to port 42 of example.host, and use port 31337 |
as the source port. |
as the source port. |
.It Li "nc -w 5 example.host 42" |
.It Li "nc -w 5 example.host 42" |
Open a tcp connection to port 42 of example.host, and time out after |
Open a TCP connection to port 42 of example.host, and time out after |
five seconds while attempting to connect. |
five seconds while attempting to connect. |
.It Li "nc -u example.host 53" |
.It Li "nc -u example.host 53" |
Send any data from stdin |
Send any data from stdin |
to UDP port 53 of example.host, and display any data returned. |
to UDP port 53 of example.host, and display any data returned. |
.It Li "nc -s 10.1.2.3 example.host 42" |
.It Li "nc -s 10.1.2.3 example.host 42" |
Open a tcp connection to port 42 of example.host using 10.1.2.3 as the |
Open a TCP connection to port 42 of example.host using 10.1.2.3 as the |
ip for the local end of the connection. |
IP for the local end of the connection. |
.It Li "nc -v example.host 42" |
.It Li "nc -v example.host 42" |
Open a tcp connection to port 42 of example.host, displaying some |
Open a TCP connection to port 42 of example.host, displaying some |
diagnostic messages on stderr. |
diagnostic messages on stderr. |
.It Li "nc -v -v example.host 42" |
.It Li "nc -v -v example.host 42" |
Open a tcp connection to port 42 of example.host, displaying all |
Open a TCP connection to port 42 of example.host, displaying all |
diagnostic messages on stderr. |
diagnostic messages on stderr. |
.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 nc |
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 |
did not respond with an ICMP packet after three seconds. |
did not respond with an ICMP packet after three seconds. |
.It Li "nc -l -p 3000" |
.It Li "nc -l -p 3000" |
Listen on TCP port 3000, and once there is a connection, send stdin to |
Listen on TCP port 3000, and once there is a connection, send stdin to |
|
|
stdout until example.host closes the connection. |
stdout until example.host closes the connection. |
.El |
.El |
.Sh SEE ALSO |
.Sh SEE ALSO |
.Xr telnet 1 , |
|
.Xr cat 1 , |
.Xr cat 1 , |
and the |
.Xr telnet 1 |
|
.Pp |
|
The |
.Nm netcat |
.Nm netcat |
.Pa README |
.Pa README . |
.Sh AUTHOR |
.Sh AUTHOR |
*Hobbit* [hobbit@avian.org] |
*Hobbit* [hobbit@avian.org] |