linux中nc详解

|是管道符号,表示左边的输出做为右边的输入。nginx

 

一、TCP端口扫描bash

# nc -v -z -w2 127.0.0.1 1-100
Connection to 127.0.0.1 22 port [tcp/ssh] succeeded!
Connection to 127.0.0.1 53 port [tcp/domain] succeeded!
Connection to 127.0.0.1 80 port [tcp/http] succeeded!
...
nc: connect to 127.0.0.1 port 100 (tcp) failed: Connection refused

二、从192.168.1.2拷贝文件到192.168.1.3dom

首先在接收端192.168.1.3上: nc -l 1234 > test.txtssh

而后在发送端192.168.1.2上: nc 192.168.1.3 < test.txttcp

注意:先运行接收端,指定一个端口为1234,文件为test.txt,再执行发送端,而且发送端必须存在同名的文件test.txt工具

三、传输目录code

从server1(192.168.16.233)拷贝nginx目录内容到server2(192.168.48.47)上。须要先在server2上,用nc激活监听,server

server2上运行:# nc -l 1234 | tar xzv-io

server1上运行:# tar czv- nginx | nc 192.168.48.47 1234 class

四、简单聊天工具

在192.168.1.2上: nc -l 1234

在192.168.1.3上: nc 192.168.1.2 1234

这样,双方就能够相互交流了。使用ctrl+C(或D)退出

相关文章
相关标签/搜索