1、先使用arp和arp -a查看一下當前ARP緩衝列表
[root@ftp]# arp
Address HWtype HWaddress Flags Mask Iface
192.168.0.145 ether 00:13:20:E9:11:04 C eth0
192.168.0.1 ether 00:02:03:18:08:00 C eth0
說明:
Address:主機的IP地址
Hwtype:主機的硬體類型
Hwaddress:主機的硬體地址
Flags Mask:記錄標誌,"C"表示arp快取中的條目,"M"表示靜態arp條目。
[root@ftp]# arp -a
(192.168.0.145) at 00:13:20:E9:11:04 [ether] on eth0
(192.168.0.1) at 00:02:03:18:08:00 [ether] on eth0
2、建立一個靜態mac-->ip對應表檔案:ip-mac,將要綁定的IP和MAC地下寫入此檔案,格式為 ip mac
。
[root@ftp]# echo '192.168.0.1 00:02:03:18:08:00 ' > /etc/ip-mac
[root@ftp]# more /etc/ip-mac
192.168.0.1 00:02:03:18:08:00
3、設定開機自動綁定
[root@ftp]# echo 'arp -f /etc/ip-mac ' >> /etc/rc.d/rc.local
4、手動執行一下綁定
[root@ftp]# arp -f /etc/ip-mac
5、確認綁定是否成功
[root@ftp]# arp
Address HWtype HWaddress Flags Mask Iface
192.168.0.145 ether 00:13:20:E9:11:04 C eth0
192.168.0.1 ether 00:02:03:18:08:00 CM eth0
[root@ftp]# arp -a
(192.168.0.145) at 00:02:B3:A7:85:48 [ether] on eth0
(192.168.0.1) at 00:02:03:18:08:00 [ether] PERM on eth0
從綁定前後的ARP緩衝列表中,可以看到網關(192.168.0.1)的記錄標誌已經改變,說明綁定成功。