zoukankan      html  css  js  c++  java
  • linux中nc详解

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

    1、TCP端口扫描

    # 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

    2、从192.168.1.2拷贝文件到192.168.1.3

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

    然后在发送端192.168.1.2上: nc 192.168.1.3 < test.txt

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

    3、传输目录

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

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

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

    4、简单聊天工具

    在192.168.1.2上: nc -l 1234

    在192.168.1.3上: nc 192.168.1.2 1234

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

  • 相关阅读:
    mkdir,rmdir
    linux目录结构
    echo
    date
    man
    cd
    ls
    线程、进程
    php类型的自动转换
    电商
  • 原文地址:https://www.cnblogs.com/hxsyl/p/6118078.html
Copyright © 2011-2022 走看看