centos安装netcat工具及测试
netcat是网络工具中的瑞士军刀,它能通过TCP和UDP在网卡中读写数据。通过与其他工具结合和重定向,你可以在脚本中以多种方式使用它。使用natcat命令所能完成的事情令人惊讶。 netcat所做的就是在两台电脑之间简历连接并返回两个数据流,在这之后所能作的事就看你的想法了。你能建立一个服务器,传输文件,与朋友聊天,传输流媒体或者用它作为其他协议的独立客户端。 1.下载 $wgethttps://sourceforge.net/projects/netcat/files/netcat/0.7.1/netcat-0.7.1.tar.gz<spanstyle="font-family:Arial,Helvetica,sans-serif;padding:0px;color:rgb(63,63,63);font-size:14px;text-align:left;background-color:rgb(255,255,255);"></span> 如果下载不成功,请自行前往此地址下载:http://netcat.sourceforge.net/download.php 2.解压 $sudotar-zxvfnetcat-0.7.1.tar.gz-C/usr/local 查看解压后的文件 $cd/user/local/study $ls netcat-0.7.1php $sudomvnetcat-0.7.1netcat $ls netcatphp netcat-0.7.1就是解压后的目录 将其重命名为netcat 3.切换到解压后的目录,查看编译配置文件 $cd/use/local/netcat $./configure 4.编译安装 $make&&makeinstall 5.配置 切换到/etc目录 编辑etc/profile;加入 export NETCAT_HOME=/usr/local/netcat-0.7.1 export PATH=$PATH:$NETCAT_HOME/bin 6.测试 nc-help或者netcat-help GNUnetcat0.7.1,arewriteofthefamousnetworkingtool. Basicusages: connecttosomewhere:nc[options]hostnameport[port]... listenforinbound:nc-l-pport[options][hostname][port]... tunneltosomewhere:nc-Lhostname:port-pport[options] Mandatoryargumentstolongoptionsaremandatoryforshortoptionstoo. Options: -c,--closecloseconnectiononEOFfromstdin -e,--exec=PROGRAMprogramtoexecafterconnect -g,--gateway=LISTsource-routinghoppoint[s],upto8 -G,--pointer=NUMsource-routingpointer:4,8,12,... -h,--helpdisplaythishelpandexit -i,--interval=SECSdelayintervalforlinessent,portsscanned -l,--listenlistenmode,forinboundconnects -L,--tunnel=ADDRESS:PORTforwardlocalporttoremoteaddress -n,--dont-resolvenumeric-onlyIPaddresses,noDNS -o,--output=FILEoutputhexdumptraffictoFILE(implies-x) -p,--local-port=NUMlocalportnumber -r,--randomizerandomizelocalandremoteports -s,--source=ADDRESSlocalsourceaddress(iporhostname) -t,--tcpTCPmode(default) -T,--telnetanswerusingTELNETnegotiation -u,--udpUDPmode -v,--verboseverbose(usetwicetobemoreverbose) -V,--versionoutputversioninformationandexit -x,--hexdumphexdumpincomingandoutgoingtraffic -w,--wait=SECStimeoutforconnectsandfinalnetreads -z,--zerozero-I/Omode(usedforscanning) Remoteportnumbercanalsobespecifiedasrange.Example:'1-1024' 如上即安装成功; 使用swoole写了一个udp的连接,测试 $netcat-u127.0.0.15999 hello Serverhello $nc-u127.0.0.15999 hello Serverhello