Bind ip and mac in linux
1. Appoint
(1). The gateway has been bound to the machine below
gateway ip:192.168.1.1 mac:00:02:B3:38:08:62
(2). Linux IP:192.168.1.2 MAC:00:04:61:9A:8D:B2
2. setps of binding
Execute “arp” or “arp -a” to check arp cache table
[root@ftpsvr ~]# arp
Address HWtype HWaddress Flags Mask Iface
192.168.6.234 ether 00:04:61:AE:11:2B C eth0
192.168.4.145 ether 00:13:20:E9:11:04 C eth0
192.168.1.1 ether 00:02:B3:38:08:62 C eth0
Introduction:
Address:host ip address
Hwtype:hardware type of host
Hwaddress:mac address
[root@ftpsvr ~]# arp -a
(192.168.1.234) at 00:04:61:AE:11:2B [ether] on eth0
(192.168.1.1) at 00:16:76:22:23:86 [ether] on eth0
3. Create a file and wirte binding information to it
[root@ftpsvr ~]# echo ‘192.168.1.1 00:02:B3:38:08:62 ‘ > /etc/ip-mac-binding
[root@ftpsvr ~]# more /etc/ip-mac
192.168.1.1 00:02:B3:38:08:62
4. Set automatic binding at startup
[root@ftpsvr ~]# echo ‘arp -f /etc/ip-mac-binding ‘ >> /etc/rc.d/rc.local
5. Execute binding by manual
[root@ftpsvr ~]# arp -f /etc/ip-mac-binding
6. Confirm whether binding was successful or not
[root@ftpsvr ~]# arp
Address HWtype HWaddress Flags Mask Iface
192.168.2.205 ether 00:02:B3:A7:85:48 C eth0
192.168.6.234 ether 00:04:61:AE:11:2B C eth0
192.168.1.1 ether 00:02:B3:38:08:62 CM eth0
[root@ftpsvr ~]# arp -a
(192.168.2.205) at 00:02:B3:A7:85:48 [ether] on eth0
(192.168.6.234) at 00:04:61:AE:11:2B [ether] on eth0
(192.168.1.1) at 00:02:B3:38:08:62 [ether] PERM on eth0