00. 目录
01. 命令概述
arp命令用于操作主机的arp缓冲区,它可以显示arp缓冲区中的所有条目、删除指定的条目或者添加静态的ip地址与MAC地址对应关系。
arp命令的英文全拼“Address Resolution Protocol” 。
02. 命令格式
格式:arp [选项] [参数]
- 1
03. 常用选项
-a 显示arp缓存的所有条目,主机位可选参数
-H 指定arp指令使用的地址类型
-d 从arp缓存中删除指定主机的arp条目
-D 使用指定接口的硬件地址
-e 以linux的显示风格显示arp缓存中的条目
-i 指定要操作arp缓存的网络接口
-n 以数字方式显示arp缓存中的条目
-v 显示详细的arp缓存条目,包括缓存条目的统计信息
-f 设置主机的IP地址与MAC地址的静态映射
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
04. 参考示例
4.1 查看arp缓存表
[deng@localhost ~]$ arp
Address HWtype HWaddress Flags Mask Iface
gateway ether 58:69:6c:28:0c:4e C ens33
172.16.0.117 ether 00:0e:c6:be:30:d1 C ens33
172.16.0.51 ether 54:e1:ad:ac:1e:7b C ens33
[deng@localhost ~]$
- 1
- 2
- 3
- 4
- 5
- 6
4.2 查看arp表,并且用ip显示而不是主机名称
[deng@localhost ~]$ arp -n
Address HWtype HWaddress Flags Mask Iface
172.16.0.1 ether 58:69:6c:28:0c:4e C ens33
172.16.0.117 ether 00:0e:c6:be:30:d1 C ens33
172.16.0.51 ether 54:e1:ad:ac:1e:7b C ens33
[deng@localhost ~]$
- 1
- 2
- 3
- 4
- 5
- 6
4.3 查看arp表,显示主机名和IP
[deng@localhost ~]$ arp -a
gateway (172.16.0.1) at 58:69:6c:28:0c:4e [ether] on ens33
? (172.16.0.117) at 00:0e:c6:be:30:d1 [ether] on ens33
? (172.16.0.51) at 54:e1:ad:ac:1e:7b [ether] on ens33
[deng@localhost ~]$
- 1
- 2
- 3
- 4
- 5
4.4 ip和MAC地址绑定
[deng@localhost ~]$ arp -s 172.16.0.76 00:50:56:26:d8:87
- 1
4.5 删除arp缓存表中指定项
[root@localhost ~]# arp -d 172.16.0.51
[root@localhost ~]#
- 1
- 2
4.6 删除指定网卡的arp表
[root@localhost ~]# arp -i ens33 -d 172.16.0.117
[root@localhost ~]# arp
Address HWtype HWaddress Flags Mask Iface
gateway ether 58:69:6c:28:0c:4e C ens33
172.16.0.51 ether 54:e1:ad:ac:1e:7b C ens33
[root@localhost ~]#
- 1
- 2
- 3
- 4
- 5
- 6
4.7 使用eth1的MAC地址回答eth0上的192.168.60.2的arp请求
[root@localhost ~]# arp -i eth0 -Ds 10.0.0.2 eth1 pub
[root@localhost ~]#
- 1
- 2
4.8 显示详细的arp缓存条目,包括缓存条目的统计信息
[root@localhost ~]# arp -v
Address HWtype HWaddress Flags Mask Iface
gateway ether 58:69:6c:28:0c:4e C ens33
172.16.0.51 ether 54:e1:ad:ac:1e:7b C ens33
Entries: 2 Skipped: 0 Found: 2
[root@localhost ~]#
- 1
- 2
- 3
- 4
- 5
- 6
评论记录:
回复评论: