Jump to content

Procedure for Mac Binding on DHCP Server of MDI

From TetraWiki



Adding or Binding new MAC addresses.[edit]

If we need to bind new MAC address for new batch then folow below steps:

Adding or Binding Single MAC addresses.[edit]

1. Go to directory /mac_address.

[root@mdidhcpserver ~]# cd /mac_address [Press enter Key]

2.Create a text file with batch name.

eg. [root@mdidhcpserver ~]# vim new_batch.txt

3.Now enter the MAC address in given format

host Kamal_Kishore {hardware ethernet 00:16:E6:F6:E8:B1 ;}

Adding Multiple MAC Binding[edit]

4.For multiple MAC address please add all MAC address in the file like below and save file.

host 111_Satya_Prakash-1 {hardware ethernet 00:16:E6:F6:BC:B7 ;}
host 111_Satya_Prakash-2 {hardware ethernet 14:f6:5a:ff:68:19 ;}
host 114_Ashok_Mishra-1 {hardware ethernet 00:16:E6:F6:BC:6E ;}
host 115_Tika_Bahadur-1 {hardware ethernet 00:01:6c:9d:33:d0 ;}
host 115_Tika_Bahadur-2 {hardware ethernet 78:45:C4:C3:DD:7C ;}
host 115_Tika_Bahadur-3 {hardware ethernet 9C:2A:70:C5:F2:F5 ;}
host 132_Charanjeet-4 {hardware ethernet 5C:F8:A1:97:11:D1 ;}
host 132_Charanjeet-5 {hardware ethernet 08:bd:45:66:03:3e ;}
host 135_Des_Raj-1 {hardware ethernet 8C:DC:D4:46:AF:9E ;}
host 136_Ashish_Kumar_Bose-1 {hardware ethernet 00:16:E6:21:4D:32 ;}
host 142_Lekh_Bahadur-1 {hardware ethernet 00:01:6C:9C:B1:12 ;}
host 143_R_P_Paswan-1 {hardware ethernet 00:01:6C:9C:A4:A1 ;}
 

Note: Duplicate entry will not be accepted you will get error while restarting dhcpd service.

5.Make a entry for new created file (new_batch.txt) in /etc/dhcpd/dhcpd.conf file

[root@mdidhcpserver ~]# vim /etc/dhcp/dhcpd.conf 

and make below entry.

include "/mac_address/new_batch.txt";

6.Restart dhcpd service:

[root@mdidhcpserver ~]# /etc/init.d/dhcpd restart
Shutting down dhcpd:                                       [  OK  ]
Starting dhcpd:                                            [  OK  ]


Deletion of MAC Address[edit]

To delete Single MAC address[edit]

1. Search MAC address

[root@mdidhcpserver ~]# cd /mac_address [Press Enter]
[root@mdidhcpserver mac_address]# grep '00:01:6C:9C:A4:A1' * [Press Enter]

->You will get out put like below:

Faculty_Staff_Hostel_LH_LAB.txt:host 143_R_P_Paswan-1 {hardware ethernet 00:01:6C:9C:A4:A1 ;}

2.Now open the file Faculty_Staff_Hostel_LH_LAB.txt and comment(#)the line

[root@mdidhcpserver mac_address]# vim Faculty_Staff_Hostel_LH_LAB.txt
#host 143_R_P_Paswan-1 {hardware ethernet 00:01:6C:9C:A4:A1 ;}

3.Save file and restart the dhcpd service.


To delete Multiple MAC which belongs to a batch or Faculty[edit]

1. Open configuration file.

[root@mdidhcpserver ~]# vim /etc/dhcp/dhcpd.conf 

2.Comment(#)the line as per batch name or faculty.

#include "/mac_address/PGHR_2014.txt";

3.Restart dhcpd service:

If you want to delete MAC address file permanentaly then:

1. Go to /mac_address directory

[root@mdidhcpserver ~]# cd /mac_address [Press Enter]

2. List the file by below command.

[root@mdidhcpserver mac_address]# ls -lrth
total 220K
-rw-r--r-- 1 root root 1.5K Mar  9 11:02 PGPIM_2015.txt
-rw-r--r-- 1 root root  867 Mar  9 11:08 PGPIM_2014.txt
-rw-r--r-- 1 root root  534 Mar  9 13:44 sap_2016.txt
-rw-r--r-- 1 root root 6.4K Mar  9 14:27 PGHR_2014.txt
-rw-r--r-- 1 root root 4.6K Mar 16 13:22 PTPGPM.txt
-rw-r--r-- 1 root root 2.2K Mar 17 11:33 PGP_2015_16.txt
-rw-r--r-- 1 root root  18K Mar 17 14:37 NMP28_MAC_Responses.txt
-rw-r--r-- 1 root root  794 Mar 17 16:23 PPM2015.txt
-rw-r--r-- 1 root root  33K Mar 21 10:51 PGPM_2014.txt
-rw-r--r-- 1 root root  425 Mar 22 10:04 Vendor.txt
-rw-r--r-- 1 root root 6.2K Mar 22 11:51 fpm_2015.txt
-rw-r--r-- 1 root root 5.4K Mar 23 09:48 lab1.txt
-rw-r--r-- 1 root root  50K Mar 23 16:00 PGPM_2015.txt
-rw-r--r-- 1 root root  11K Mar 23 16:07 PGHR_2015.txt
-rw-r--r-- 1 root root  42K Mar 23 16:12 Faculty_Staff_Hostel_LH_LAB.txt

3. And delete the file which you want to delete.

[root@mdidhcpserver mac_address]# rm -rf FILE_NAME.txt

Note: Delete the file when necessary, once you have delete the file you will not be able to recover file.