NAME
nc - TCP/IP swiss army knife
nc [-options] hostname port[s] [ports] ...
nc -l -p port [-options] [hostname] [port]
DESCRIPTION
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.
netcat는 TCP 또는 UDP 프로토콜을 사용하여 네트워크 연결 전반에 걸쳐 데이터를 읽고 쓰는 단순한 Unix 유틸리티다.
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.
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.
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.
You may be asking "why not just use telnet to connect to arbitrary ports?" Valid ques‐
tion, 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 inter‐
preted 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.
OPTIONS
-l | listen mode, for inbound connects
-p port | local port number (port numbers can be individual or ranges: lo-hi [inclusive])
'기초공부 > LINUX' 카테고리의 다른 글
[Linux]명령어 ssh (0) | 2019.03.02 |
---|---|
[Linux]명령어 xxd (0) | 2019.02.23 |
[Linux]명령어 hexdump (0) | 2019.02.23 |
[Linux]명령어 cat, touch (0) | 2019.01.29 |
[Linux]명령어 mkdir, rmdir (0) | 2019.01.28 |