00. 目录
01. 命令概述
arping命令作用是使用arp数据包,通过ping命令检查来测试网络。arping命令能够测试一个ip地址是否是在网络上已经被使用,并能够获取更多设备信息。功能类似于ping。
由于arping命令基于ARP广播机制,所以arping命令只能测试同一网段或子网的网络主机的连通性,ping命令则是基于ICMP协议,是可以路由的,所以使用ping命令可以测试任意网段的主机网络连通性。
02. 命令格式
用法:arp [选项] [参数]
- 1
03. 常用选项
-A 更新邻近主机的ARP缓存(使用ARP应答数据包代替ARP请求数据包)
-b 仅发送MAC级广播
-c 发送指定个数ARP请求数据包后停止
-D 重复地址检测模式(DAD)
-f 在第一个回复确认目标存活后退出命令
-h 打印帮助手册并退出
-I 指定ARP请求报文的网络接口
-q 安静模式。不显示任何信息
-s 指定发送ARP请求数据包的源IP地址
-U 更新邻近主机的ARP缓存
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
04. 参考示例
4.1 测试目标主机的存活状态
[root@localhost ~]# arping -I ens33 -f 172.16.0.2
ARPING 172.16.0.2 from 172.16.0.76 ens33
Unicast reply from 172.16.0.2 [38:4C:4F:89:CB:A2] 133.008ms
Sent 1 probes (1 broadcast(s))
Received 1 response(s)
[root@localhost ~]#
- 1
- 2
- 3
- 4
- 5
- 6
当收到第一个包就自动退出
4.2 向目标主机发送3次(指定次数)ARP请求报文
[root@localhost ~]# arping -I ens33 -c 3 172.16.0.2
ARPING 172.16.0.2 from 172.16.0.76 ens33
Unicast reply from 172.16.0.2 [38:4C:4F:89:CB:A2] 4.507ms
Unicast reply from 172.16.0.2 [38:4C:4F:89:CB:A2] 3.907ms
Unicast reply from 172.16.0.2 [38:4C:4F:89:CB:A2] 3.861ms
Sent 3 probes (1 broadcast(s))
Received 3 response(s)
[root@localhost ~]#
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
4.3 向指定的IP发送ARP请求
[root@localhost ~]# arping -I ens33 172.16.0.2
ARPING 172.16.0.2 from 172.16.0.76 ens33
Unicast reply from 172.16.0.2 [38:4C:4F:89:CB:A2] 3.922ms
Unicast reply from 172.16.0.2 [38:4C:4F:89:CB:A2] 4.108ms
Unicast reply from 172.16.0.2 [38:4C:4F:89:CB:A2] 3.777ms
Unicast reply from 172.16.0.2 [38:4C:4F:89:CB:A2] 4.554ms
Unicast reply from 172.16.0.2 [38:4C:4F:89:CB:A2] 3.992ms
Unicast reply from 172.16.0.2 [38:4C:4F:89:CB:A2] 3.739ms
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
4.4 测试IP是否被占用
[root@localhost ~]# arping -I ens33 -w 3 -D 172.16.0.2
ARPING 172.16.0.2 from 0.0.0.0 ens33
Sent 4 probes (4 broadcast(s))
Received 0 response(s)
[root@localhost ~]#
- 1
- 2
- 3
- 4
- 5
4.5 指定源IP
[root@localhost ~]# arping -I ens33 -s 172.16.0.76 172.16.0.2
ARPING 172.16.0.2 from 172.16.0.76 ens33
Unicast reply from 172.16.0.2 [38:4C:4F:89:CB:A2] 3.871ms
Unicast reply from 172.16.0.2 [38:4C:4F:89:CB:A2] 3.769ms
Unicast reply from 172.16.0.2 [38:4C:4F:89:CB:A2] 4.919ms
Unicast reply from 172.16.0.2 [38:4C:4F:89:CB:A2] 4.290ms
- 1
- 2
- 3
- 4
- 5
- 6
4.6 向目标主机发送3次(指定次数)ARP请求报文,安静模式
[root@localhost ~]# arping -I ens33 -q -c 3 172.16.0.2
[root@localhost ~]#
- 1
- 2
评论记录:
回复评论: