Penguin
Annotated edit history of nc(1) version 2, including all changes. View license author blame.
Rev Author # Line
1 AristotlePagaltzis 1 !!! NAME
2
3 nc - TCP/IP swiss army knife
4
5 !!! SYNOPSIS
6
2 AristotlePagaltzis 7 __nc__ ''[[-options] hostname port[[s] [[ports] ...''
8 __nc__ ''-l -p port [[-options] [[hostname] [[port]''
1 AristotlePagaltzis 9
10 !!! DESCRIPTION
11
12 __netcat__ is a simple unix utility which reads and writes data across network connections, using TCP or UDP protocol. It is designed to be a reliable "back-end" tool that can be used directly or easily driven by other programs and scripts. At the same time, it is a feature-rich network debugging and exploration tool, since it can create almost any kind of connection you would need and has several interesting built-in capabilities. Netcat, or "nc" as the actual program is named, should have been supplied long ago as another one of those cryptic but standard Unix tools.
13
14 In the simplest usage, "nc host port" creates a TCP connection to the given port on the given target host. Your standard input is then sent to the host, and anything that comes back across the connection is sent to your standard output. This continues indefinitely, until the network side of the connection shuts down. Note that this behavior is different from most other applications which shut everything down and exit after an end-of-file on the standard input.
15
16 Netcat can also function as a server, by listening for inbound connections on arbitrary ports and then doing the same reading and writing. With minor limitations, netcat doesn't really care if it runs in "client" or "server" mode -- it still shovels data back and forth until there isn't any more left. In either mode, shutdown can be forced after a configurable time of inactivity on the network side.
17
18 And it can do this via UDP too, so netcat is possibly the "udp telnet-like" application you always wanted for testing your UDP-mode servers. UDP, as the "U" implies, gives less reliable data transmission than TCP connections and some systems may have trouble sending large amounts of data that way, but it's still a useful capability to have.
19
20 You may be asking "why not just use telnet to connect to arbitrary ports?" Valid question, and here are some reasons. Telnet has the "standard input EOF" problem, so one must introduce calculated delays in driving scripts to allow network output to finish. This is the main reason netcat stays running until the *network* side closes. Telnet also will not transfer arbitrary binary data, because certain characters are interpreted as telnet options and are thus removed from the data stream. Telnet also emits some of its diagnostic messages to standard output, where netcat keeps such things religiously separated from its *output* and will never modify any of the real data in transit unless you *really* want it to. And of course telnet is incapable of listening for inbound connections, or using UDP instead. Netcat doesn't have any of these limitations, is much smaller and faster than telnet, and has many other advantages.
21
22 !!! OPTIONS
23
24 ; ''-g gateway'' : source-routing hop point[[s], up to 8
25 ; ''-G num'' : source-routing pointer: 4, 8, 12, ...
26 ; ''-h'' : display help
27 ; ''-i secs'' : delay interval for lines sent, ports scanned
28 ; ''-l'' : listen mode, for inbound connects
29 ; ''-n'' : numeric-only IP addresses, no DNS
30 ; ''-o file'' : hex dump of traffic
31 ; ''-p port'' : local port number (port numbers can be individual or ranges: lo-hi [[inclusive])
32 ; ''-q seconds'' : after EOF is detected, wait the specified number of seconds and then quit.
33 ; ''-b'' : allow UDP broadcasts
34 ; ''-r'' : randomize local and remote ports
35 ; ''-s addr'' : local source address
36 ; ''-t'' : enable telnet negotiation
37 ; ''-e prog'' : specify program to exec after connect (use with caution)
38 ; ''-u'' : UDP mode
39 ; ''-v'' : verbose [[use twice to be more verbose]
40 ; ''-w secs'' : timeout for connects and final net reads
41 ; ''-z'' : zero-I/O mode [[used for scanning]
42
43 !!! COPYRIGHT
44
45 Netcat is entirely my own creation, although plenty of other code was used as examples. It is freely given away to the Internet community in the hope that it will be useful, with no restrictions except giving credit where it is due. No GPLs, Berkeley copyrights or any of that nonsense. The author assumes NO responsibility for how anyone uses it. If netcat makes you rich somehow and you're feeling generous, mail me a check. If you are affiliated in any way with Microsoft Network, get a life. Always ski in control. Comments, questions, and patches to hobbit@avian.org.
46
47 !!! BUGS
48
49 Efforts have been made to have netcat "do the right thing" in all its various modes. If you believe that it is doing the wrong thing under whatever circumstances, please notify me and tell me how you think it should behave. If netcat is not able to do some task you think up, minor tweaks to the code will probably fix that. It provides a basic and easily-modified template for writing other network applications, and I certainly encourage people to make custom mods and send in any improvements they make to it. Continued feedback from the Internet community is always welcome!
50
51 Some port names in __/etc/services__ contain hyphens -- netcat currently will not correctly parse those, so specify ranges using numbers if you can.
52
53 !!! SEE ALSO
54
2 AristotlePagaltzis 55 __/usr/share/doc/netcat/README.gz__
1 AristotlePagaltzis 56
57 !!! AUTHOR
58
59 This manual page was written by [Joey Hess | mailto:joeyh@debian.org] and
60 [Robert Woodcock | mailto:rcw@debian.org], cribbing heavily from Netcat's README file.
61
62 Netcat was written by a guy we know as the [Hobbit | mailto:hobbit@avian.org].
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.