linux 下arp 地址绑定

 1 使用 arp -a ,arp  查看 缓存表

   [[email protected] ~]# arp -a

? (192.168.40.1) at 00:50:56:C0:00:08 [ether] on eth1

? (192.168.40.1) at 00:50:56:C0:00:08 [ether] on eth0

[[email protected] ~]# arp 

Address                  HWtype  HWaddress           Flags Mask            Iface

192.168.40.1             ether   00:50:56:C0:00:08   C                     eth1

192.168.40.1             ether   00:50:56:C0:00:08   C                     eth0

192.168.40.2             ether   00:50:56:EA:DB:BD   C                     eth0

c 代表缓存,m 是静态地址

2 建一个静态的mac–>ip对应表文件:ip_mac,

 echo 192.168.40.2   00:50:56:EA:DB:BD >/etc/ip_mac

3 arp  -f /etc/ip_mac 绑定地址

4 查看结果 arp

    [[email protected] ~]# arp

Address                  HWtype  HWaddress           Flags Mask            Iface

192.168.40.1             ether   00:50:56:C0:00:08   C                     eth1

192.168.40.254           ether   00:50:56:E6:5D:9E   C                     eth0

192.168.40.1             ether   00:50:56:C0:00:08   C                     eth0

192.168.40.2             ether   00:50:56:EA:DB:BD   CM  

————————————————————–

arp -a

 

[[email protected] ~]# arp -a

? (192.168.40.1) at 00:50:56:C0:00:08 [ether] on eth1

? (192.168.40.1) at 00:50:56:C0:00:08 [ether] on eth0

? (192.168.40.2) at 00:50:56:EA:DB:BD [ether] PERM on eth0

 

 

               

5  加入到开机启动

 echo  arp -f /etc/ip_mac >>/etc/rc.local

点赞