Configuring MAC binding in DHCP server means permanently assigning static Internet protocol (IP) to the DHCP client using client MAC address.
We don’t want to give automatic IP address to servers, which are service providers. As a example if a NFS or Samba Server IP got changed automatically after a reboot are Network restart then all client who are acessing NFS and Samba shares can’t be accessible using old IP address each and every time we have to intimate to the employees if server IP address changed. Not only about accessing the NFS and Samba shares some of the shares maybe used for hosting of application. Hot coded links in HTML/PHP intranets all things get effected due an single IP address change.
Our goal is to set static IP address to DHCP client (server) using DHCP server configuration, which is called as configuring MAC binding
first step is to configure DHCP server.
DHCP server installation and configuration Step by Step Guide
Configuring MAC binding
after configuring the DHCP server restart the service and verify status
[root@mail ~]# systemctl restart dhcpd.service
[root@mail ~]# systemctl status dhcpd.service
collect client machine MAC address simple trick, ping to all the clients which you want configure MAC binding then run
# arp -a command
[root@mail ~]# ping 192.168.4.12
PING 192.168.4.12 (192.168.4.12) 56(84) bytes of data.
64 bytes from 192.168.4.12: icmp_seq=1 ttl=64 time=0.290 ms
64 bytes from 192.168.4.12: icmp_seq=2 ttl=64 time=0.356 ms
^C
--- 192.168.4.12 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 0.290/0.323/0.356/0.033 ms
[root@mail ~]# arp -a
? (192.168.4.2) at 00:50e:56:ee:4e:e2 [ether] on eno16777736
Edit the configuration and change as required
[root@mail ~]# vim /etc/dhcp/dhcpd.conf
# Fixed IP addresses can also be specified for hosts. These addresses
# should not also be listed as being available for dynamic assignment.
# Hosts for which fixed IP addresses have been specified can boot using
# BOOTP or DHCP. Hosts for which no fixed address is specified can only
# be booted with DHCP, unless there is an address range on the subnet
# to which a BOOTP client is connected which has the dynamic-bootp flag
# set.
host nfsserver {
hardware ethernet 00:50e:56:ee:4e:e2;
fixed-address 192.168.4.12;
}
as shown above we have to add host short name MAC address and host IP address.
If you want to configure MAC binding for 50 servers then copy the same line and paste below 50 times and change there MAC address, hostname and IP address accordingly.
test configuration file before restarting DHCP server
[root@mail ~]# dhcpd configtest
Internet Systems Consortium DHCP Server 4.2.5
Copyright 2004-2013 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
Not searching LDAP since ldap-server, ldap-port and ldap-base-dn were not specified in the config file
Wrote 0 class decls to leases file.
Wrote 0 deleted host decls to leases file.
Wrote 0 new dynamic host decls to leases file.
Wrote 0 leases to leases file.
restart DHCP service
[root@mail ~]# systemctl restart dhcpd.service
[root@mail ~]# systemctl status dhcpd.service
That’s it restart network services in client and verify specified IP address it will get. If you restart 100 times also you will get same IP address from DHCP lease.