文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>linux nc 命令传输文件

linux nc 命令传输文件

时间:2009-06-17  来源:hairui8991

   一个更有用的轻量级工具,nc的另一个强大的功能---文件传输。
AME
     nc - arbitrary TCP and UDP connections and listens
SYNOPSIS
     nc [-46DdhklnrStUuvz] [-i interval] [-p source_port] [-s source_ip_address] [-T ToS] [-w timeout] [-X proxy_protocol] [-x proxy_address[:port]] [hostname] [port[s]]

譬如目的主机:192.168.0.1     源主机:192.168.0.2

目的主机监听
   nc -l 监听端口<未使用端口>  > 要接收的文件名
   nc -l 5000 > /tmp/test.out

   # netstat -tpln
   tcp        0      0 0.0.0.0:5000    0.0.0.0:*         LISTEN      18166/nc
 
   打开防火墙tcp 5000端口:
    iptables -I RH-Firewall-1-INPUT 8 -p tcp -m tcp --dport 500-j ACCEPT

源主机发起请求
   nc  目的主机ip     目的端口  < 要发送的文件
   nc  192.168.0.1   5000    < /root/test.in

如若使用UDP协议传输文件,则
  目的主机监听    #nc -ul 5000 > /tmp/test.out
  源主机发起请求  #nc  -u  192.168.0.1   5000    < /root/test.in
  目的主机需打开防火墙udp 5000端口:
  iptables -I RH-Firewall-1-INPUT 8 -p udp -m udp --dport 500-j ACCEPT
  经测试UDP传输文件时很不稳定。

英文描述如下
DATA TRANSFER
 
 Start by using nc to listen on a specific port, with output captured into a file:
           $ nc -l 1234 > filename.out
 Using a second machine, connect to the listening nc process, feeding it the file which is to be transferred:
           $ nc host.example.com 1234 < filename.in
 
相关阅读 更多 +
排行榜 更多 +
空中跑酷汉化版

空中跑酷汉化版

赛车竞速 下载
修仙传说

修仙传说

角色扮演 下载
魔界零之迷宫

魔界零之迷宫

冒险解谜 下载