Linux 网络客户端工具,


ping命令

发送ICMP协议的echo request给目标主机

常用选项:

  • 从指定的本机接口发送ICMP:-I INTERFACE

    本机有多个接口(网卡),可以选择从哪个接口发:-I(大写i)

    接口enp0s3是本地内网ip;接口enp0s8是nat的ip地址,enp0s8是可以访问外网的,enp0s3不可以。下面有ping验证。

    # ifconfig enp0s3
    enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
            inet 192.168.56.107  netmask 255.255.255.0  broadcast 192.168.56.255
    # ifconfig enp0s8
    enp0s8: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
            inet 10.0.3.15  netmask 255.255.255.0  broadcast 10.0.3.255
    
    # ping -I enp0s8 tuna.tsinghua.edu.cn
    PING tuna.tsinghua.edu.cn (101.6.6.172) from 10.0.3.15 enp0s8: 56(84) bytes of data.
    64 bytes from 101.6.6.172 (101.6.6.172): icmp_seq=1 ttl=45 time=68.3 ms
    64 bytes from 101.6.6.172 (101.6.6.172): icmp_seq=2 ttl=45 time=79.2 ms
    ^C
    --- tuna.tsinghua.edu.cn ping statistics ---
    2 packets transmitted, 2 received, 0% packet loss, time 1005ms
    rtt min/avg/max/mdev = 68.379/73.811/79.244/5.439 ms
    # ping -I enp0s3 tuna.tsinghua.edu.cn
    PING tuna.tsinghua.edu.cn (101.6.6.172) from 192.168.56.107 enp0s3: 56(84) bytes of data.
    
  • 指定发送包的个数:-c #

  • 指定包的大小:-s #

    # ping -s 9999 www.baidu.com
    PING www.a.shifen.com (61.135.169.121) 9999(10027) bytes of data.
  • 指定ping运行的时长:-w

  • 指定一次ping操作,等待对方响应的最长时长:-W

    # ping -I enp0s8 -c 3 tuna.tsinghua.edu.cn
    PING tuna.tsinghua.edu.cn (101.6.6.172) from 10.0.3.15 enp0s8: 56(84) bytes of data.
    64 bytes from 101.6.6.172 (101.6.6.172): icmp_seq=1 ttl=45 time=63.0 ms
    64 bytes from 101.6.6.172 (101.6.6.172): icmp_seq=2 ttl=45 time=62.9 ms
    64 bytes from 101.6.6.172 (101.6.6.172): icmp_seq=3 ttl=45 time=60.6 ms
    
    --- tuna.tsinghua.edu.cn ping statistics ---
    3 packets transmitted, 3 received, 0% packet loss, time 2002ms
    rtt min/avg/max/mdev = 60.663/62.218/63.037/1.100 ms
    # ping -I enp0s8 -w 2 tuna.tsinghua.edu.cn
    PING tuna.tsinghua.edu.cn (101.6.6.172) from 10.0.3.15 enp0s8: 56(84) bytes of data.
    64 bytes from 101.6.6.172 (101.6.6.172): icmp_seq=1 ttl=45 time=58.0 ms
    64 bytes from 101.6.6.172 (101.6.6.172): icmp_seq=2 ttl=45 time=66.1 ms
    # ping -I enp0s8 -W 2 tuna.tsinghua.edu.cn
    

hping命令

发送TCP/IP数据包给目标主机

# yum list all | grep hping
hping3.x86_64                             0.0.20051105-24.el7          epel
pcp-pmda-shping.x86_64                    4.3.2-4.el7_7                updates
# yum install hping3
# man hping3

常用选项:

  • 快速发送:--fast

    # hping --fast www.baidu.com
    HPING www.baidu.com (enp0s8 61.135.169.125): NO FLAGS are set, 40 headers + 0 data bytes
    len=46 ip=61.135.169.125 ttl=255 id=12411 sport=0 flags=RA seq=0 win=0 rtt=0.2 ms
    len=46 ip=61.135.169.125 ttl=255 id=12412 sport=0 flags=RA seq=1 win=0 rtt=0.8 ms
    len=46 ip=61.135.169.125 ttl=255 id=12413 sport=0 flags=RA seq=2 win=0 rtt=0.4 ms
    len=46 ip=61.135.169.125 ttl=255 id=12414 sport=0 flags=RA seq=3 win=0 rtt=0.9 ms
    len=46 ip=61.135.169.125 ttl=255 id=12415 sport=0 flags=RA seq=4 win=0 rtt=0.7 ms
    len=46 ip=61.135.169.125 ttl=255 id=12416 sport=0 flags=RA seq=5 win=0 rtt=0.6 ms
    len=46 ip=61.135.169.125 ttl=255 id=12417 sport=0 flags=RA seq=6 win=0 rtt=0.8 ms
    len=46 ip=61.135.169.125 ttl=255 id=12418 sport=0 flags=RA seq=7 win=0 rtt=0.6 ms
    len=46 ip=61.135.169.125 ttl=255 id=12419 sport=0 flags=RA seq=8 win=0 rtt=0.7 ms
    ^C
    --- www.baidu.com hping statistic ---
    10 packets transmitted, 9 packets received, 10% packet loss
    round-trip min/avg/max = 0.2/0.6/0.9 ms

    发的很快,有10%的丢失

  • 更快速发送:--faster

    # hping --fast www.baidu.com
    --- www.baidu.com hping statistic ---
    21862 packets transmitted, 958 packets received, 96% packet loss
    round-trip min/avg/max = 0.1/3.9/19.9 ms

    有96%的丢失

  • 能有多快就发多块:--flood

    # hping --flood www.baidu.com
    HPING www.baidu.com (enp0s8 61.135.169.125): NO FLAGS are set, 40 headers + 0 data bytes
    hping in flood mode, no replies will be shown
    ^C
    --- www.baidu.com hping statistic ---
    11883 packets transmitted, 0 packets received, 100% packet loss
    round-trip min/avg/max = 0.0/0.0/0.0 ms

    100%丢失

由于ping命令能发大包,就浪费了目标主机的带宽;而hping命令能快速发包,占用目标主机的cpu,有的服务器就关闭了响应它们请求的功能。其实这就是攻击服务器的简单方式。

traceroute命令

探测到目标主机经过的网关,大部分路由器都关闭了这个功能,防止被攻击。

# traceroute www.baidu.com
traceroute to www.baidu.com (61.135.169.121), 30 hops max, 60 byte packets
 1  gateway (10.0.3.2)  0.249 ms  0.246 ms  0.247 ms
 2  gateway (10.0.3.2)  4.780 ms  4.627 ms  4.487 ms

ftp

古老的file transfer protocol,ftp服务器使用21号端口

# ftp 192.168.4.22
然后提示输入fpt的用户名,可以匿名访问,匿名的话输入:anonymous或者ftp
然后提示输入密码,匿名用户就随便输入一个密码
然后就进入了ftp服务器了。
在里面可以使用ls,cd等命令
输入help,获取命令帮助。
get:下载一个文件
mget:下载多个文件
put/mput:上传一个/多个文件
rm/mrm:删除一个/多个文件

lftp命令

代替ftp命令,支持命令补全。

输入help,获取命令帮助

指定用户名和密码:lftp -u USERNAME,PASSWD 192.168.45.4

不指定用户名和密码(匿名访问):lftp 192.168.45.4

匿名访问时,不需要输入anonymous或者ftp

get:下载一个文件

mget:下载多个文件

put/mput:上传一个/多个文件

rm/mrm:删除一个/多个文件

lftpget命令

不登录到ftp服务器,直接下载。但只能下载文件,不能下载目录。

使用的应用层协议是http

lftpget -c http://192.168.56.22/dir/file

断点续传:-c

wget命令

只能下载文件,不能下载目录。

  • 在后台执行下载:-b

    一般在脚本中使用此选项

  • 不显示下载进度:-q

  • 断点续传:-c

  • 指定文件下载后,存放到本地的哪里:-O file

  • 指定下载速率(不指定可能就是最大速率): --limit-rate=amount

c/c++ 学习互助QQ群:877684253

本人微信:xiaoshitou5854

相关内容

    暂无相关文章