柚子快报邀请码778899分享:Linux学习

http://www.51969.com/

测试中,需要通过 Netcat 发送数据。

配置环境:CentOS 6.8

1、下载安装包到指定目录,例如本博主的是:/opt/software/

wget https://sourceforge.net/projects/netcat/files/netcat/0.7.1/netcat-0.7.1.tar.gz

2、解压缩文件到指定目录(注意:要先创建 /opt/module/netcat/ 目录)

tar -zxf /opt/software/netcat-0.7.1.tar.gz -C /opt/module/netcat

3、使用 root 用户,先切换至 /opt/module/netcat/netcat-0.7.1/ 该目录

[root@hadoop102 netcat-0.7.1]# pwd/opt/module/netcat/netcat-0.7.1[root@hadoop102 netcat-0.7.1]# ./configure checking build system type... x86_64-unknown-linux-gnuchecking host system type... x86_64-unknown-linux-gnuchecking target system type... x86_64-unknown-linux-gnuchecking for a BSD-compatible install... /usr/bin/install -c............[root@hadoop102 netcat-0.7.1]# make && make install  #进行编译安装

4、配置,打开 /etc/profile

[root@hadoop102 netcat-0.7.1]# vim /etc/profile添加内容如下:#NETCAT_HOMEexport NETCAT_HOME=/opt/module/netcat/netcat-0.7.1export PATH=$PATH:$NETCAT_HOME/bin[root@hadoop102 netcat-0.7.1]# source /etc/profile  #生效配置[root@hadoop102 netcat-0.7.1]# nc -help     #出现以下信息表明配置已生效GNU netcat 0.7.1, a rewrite of the famous networking tool.Basic usages:connect to somewhere:  nc [options] hostname port [port] ...listen for inbound:    nc -l -p port [options] [hostname] [port] ...tunnel to somewhere:   nc -L hostname:port -p port [options]Mandatory arguments to long options are mandatory for short options too.Options:  -c, --close                close connection on EOF from stdin  -e, --exec=PROGRAM         program to exec after connect  -g, --gateway=LIST         source-routing hop point[s], up to 8  -G, --pointer=NUM          source-routing pointer: 4, 8, 12, ...  -h, --help                 display this help and exit  -i, --interval=SECS        delay interval for lines sent, ports scanned  -l, --listen               listen mode, for inbound connects  -L, --tunnel=ADDRESS:PORT  forward local port to remote address  -n, --dont-resolve         numeric-only IP addresses, no DNS  -o, --output=FILE          output hexdump traffic to FILE (implies -x)  -p, --local-port=NUM       local port number  -r, --randomize            randomize local and remote ports  -s, --source=ADDRESS       local source address (ip or hostname)  -t, --tcp                  TCP mode (default)  -T, --telnet               answer using TELNET negotiation  -u, --udp                  UDP mode  -v, --verbose              verbose (use twice to be more verbose)  -V, --version              output version information and exit  -x, --hexdump              hexdump incoming and outgoing traffic  -w, --wait=SECS            timeout for connects and final net reads  -z, --zero                 zero-I/O mode (used for scanning)Remote port number can also be specified as range.  Example: '1-1024'

linux nc 命令使用详解

功能说明:功能强大的网络工具语  法:nc [-hlnruz][-g<网关...>][-G<指向器数目>][-i<延迟秒数>][-o<输出文件>][-p<通信端口>][-s<来源位址>][-v...][-w<超时秒数>][主机名称][通信端口...]参  数:-g<网关>        设置路由器通信网关,最大可设置8个。-G<指向器数目>  设置来源路由指向器,其数值为4的倍数。-h              在线帮助。-i<延迟秒数>    设置时间间隔,以便传送信息及扫描通信端口。-l              使用监听模式,管控传入的资料。-n              直接使用IP地址,而不通过域名服务器。不能用 hostname。-o<输出文件>    指定文件名称,把往来传输的数据以16进制字码文件保存。-p<通信端口>    设置本地主机使用的通信端口。-r              指定本地与远端主机的通信端口。-s<来源位址>    设置本地主机送出数据包的IP地址。-u              使用UDP传输协议。-v              详细输出,用两个-v可得到更详细的内容。-w<超时秒数>    设置等待连线的时间。-z              使用输入/输出模式,只在扫描通信端口时使用。

5、使用普通用户登录 Linux,启动 netcat,测试使用

[atguigu@hadoop102 ~]$ nc -l -p 9999   #监听9999端口hello world     #发送测试数据我们监听服务器端的 ip 和端口号[atguigu@hadoop102 ~]$ nc -nv 192.168.25.102 444

柚子快报邀请码778899分享:Linux学习

http://www.51969.com/

查看原文