arp

arp 功能: 用于操作本机的arp缓存区
可以显示arp缓存区中的所有条目、删除指定的条目或者添加静态的IP地址与MAC地址的对应关系。
什么是arp?即地址解析协议(ARP,Address Resolution Protocol),其主要功能是根据IP地址获取物理地址(MAC地址)。

参数选项
-n                         显示数字IP地址
-s <主机> <MAC地址>        设置指定主机的IP地址与MAC地址的静态映射
-d <主机>                  从arp缓存区中删除指定主机的ap条目
-i <接>                    指定网络接口
-v                         显示详细的arp缓存区条目,包括缓冲区务目的统计信息


范例:显示arp缓存区的所有条目
[root@testdb62 ~]# arp -n
Address                  HWtype  HWaddress           Flags Mask            Iface
10.10.10.129             ether   00:0c:29:fe:b6:9d   C                     ens160
10.10.10.122             ether   00:50:56:84:5b:06   C                     ens160
10.10.10.76              ether   00:0c:29:2f:0c:3c   C                     ens160

命令说明具体如下。
Address:主机地址。
Hwtype:硬件类型。
Hwaddress:硬件地址。
Flags Mask:记录标志,“C”表示arp高速缓存中的条目,“M”表示静态的arp条目。
lface:网络接口。

 

范例:查询指定主机的arp条目
[root@testdb62 ~]# arp -n 10.0.0.1
Address                  HWtype  HWaddress           Flags Mask            Iface
10.0.0.1                 ether   00:50:56:c0:00:08   C                     eth0



范例:静态绑定IP地址与MAC地址
[root@testdb62 ~]# arp -s 10.0.0.99 00:0c:29:c0:5a:ef  #绑定IP地是和MAC地址
[root@testdb62 ~]# arp -n
Address                  HWtype  HWaddress           Flags Mask            Iface
10.0.0.1                 ether   00:50:56:c0:00:08   C                     eth0
10.0.0.2                 ether   00:50:56:f4:fb:52   C                     eth0
10.0.0.99                ether   00:0c:29:c0:5a:ef   CM                    eth0

 

范例:删除静态ARP绑定
[root@testdb62 ~]# arp -d 10.0.0.99
[root@testdb62 ~]# arp -n
Address                  HWtype  HWaddress           Flags Mask            Iface
10.0.0.1                         (incomplete)
10.0.0.2                 ether   00:50:56:f4:fb:52   C                     eth0
10.0.0.99                ether   00:0c:29:c0:5a:ef   C                     eth0

提示:当局域网有arp病毒时,就可以用上运方法绑定MAC地址,以防止中毒。



 

posted @ 2020-12-24 15:37  屠魔的少年  阅读(295)  评论(0)    收藏  举报