centos下的nc是“netcat”的简称,是一个网络工具,可以用于端口扫描、文件传输等,nc也可以实现任意tcp和udp端口的侦听,可以利用“yum install nc -y”命令进行安装。
本文操作环境:centos 7系统、dell g3电脑。
centos下什么是ncnc是netcat工具的简称,一个网络工具,可以用来端口扫描、文件传输等功能。
centos上面安装也很简单:
yum install nc -y
nc常用功能
实现任意tcp/udp端口的侦听,nc可以作为server以tcp或udp方式侦听指定端口
端口的扫描,nc可以作为client发起tcp或udp连接
机器之间传输文件
机器之间网络测速
一般nc只用来做tcp/udp协议的端口测试,其它功能少用!
nc帮助说明
# nc --help ncat 7.50 ( https://nmap.org/ncat )usage: ncat [options] [hostname] [port]options taking a time assume seconds. append 'ms' for milliseconds,'s' for seconds, 'm' for minutes, or 'h' for hours (e.g. 500ms). -4 use ipv4 only -6 use ipv6 only -u, --unixsock use unix domain sockets only -c, --crlf use crlf for eol sequence -c, --sh-exec <command> executes the given command via /bin/sh -e, --exec <command> executes the given command --lua-exec <filename> executes the given lua script -g hop1[,hop2,...] loose source routing hop points (8 max) -g <n> loose source routing hop pointer (4, 8, 12, ...) -m, --max-conns <n> maximum <n> simultaneous connections -h, --help display this help screen -d, --delay <time> wait between read/writes -o, --output <filename> dump session data to a file -x, --hex-dump <filename> dump session data as hex to a file -i, --idle-timeout <time> idle read/write timeout -p, --source-port port specify source port to use -s, --source addr specify source address to use (doesn't affect -l) -l, --listen bind and listen for incoming connections -k, --keep-open accept multiple connections in listen mode -n, --nodns do not resolve hostnames via dns -t, --telnet answer telnet negotiations -u, --udp use udp instead of default tcp --sctp use sctp instead of default tcp -v, --verbose set verbosity level (can be used several times) -w, --wait <time> connect timeout -z zero-i/o mode, report connection status only --append-output append rather than clobber specified output files --send-only only send data, ignoring received; quit on eof --recv-only only receive data, never send anything --allow allow only given hosts to connect to ncat --allowfile a file of hosts allowed to connect to ncat --deny deny given hosts from connecting to ncat --denyfile a file of hosts denied from connecting to ncat --broker enable ncat's connection brokering mode --chat start a simple ncat chat server --proxy <addr[:port]> specify address of host to proxy through --proxy-type <type> specify proxy type ("http" or "socks4" or "socks5") --proxy-auth <auth> authenticate with http or socks proxy server --ssl connect or listen with ssl --ssl-cert specify ssl certificate file (pem) for listening --ssl-key specify ssl private key (pem) for listening --ssl-verify verify trust and domain name of certificates --ssl-trustfile pem file containing trusted ssl certificates --ssl-ciphers cipherlist containing ssl ciphers to use --version display ncat's version information and exit
nc常用案例tcp监听测试
nc可作为server端192.168.10.11启动一个tcp的监听
nc -l 80
客户端测试方法:直接telnet该机器ip+端口
telnet 192.168.10.11 80
或:nmap 192.168.10.11 -p 80
udp监听测试
nc作为server端启动一个udp的监听
nc -lu 80
通过netstat可以看到udp协议已经监听:
> # netstat -tunlpactive internet connections (only servers)proto recv-q send-q local address foreign address state pid/program name udp 0 0 0.0.0.0:80 0.0.0.0:* 15401/nc
推荐教程:《centos教程》
以上就是centos下什么是nc的详细内容。