DHCP - Dynamic host configuration protocol
We are going to configure DHCP Server in RHEL7
It’s a network protocol used to assign IP’s to the client dynamically over the network.
DHCP Workflow:
Required Package installation:
#yum install dhcp
Now we should assign a insterface in DHCPDARGS in /etc/sysconfig/dhcpd
[[email protected] ~]# vi /etc/sysconfig/dhcpd DHCPDARGS=enp0s3
After installing package it will create one empty configuration file /etc/dhcp/dhcpd.conf and we have one sample configuration file under /usr/share/doc/dhcp-4.2.15/dhcpd.conf.exmaple.
So as first, append the content from example file to original file using cat command.
[[email protected] ~]# cat /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example >> /etc/dhcp/dhcpd.conf
Open the configuration file to configure DHCP Server:
First will give basic configuration which will be common for your network.
[[email protected] ~]# vi /etc/dhcp/dhcpd.conf
Make the below entries
option domain-name "lbcdomain.com"; option domain-name-servers server.lbcdomain.com; default-lease-time 600; max-lease-time 7200; authoritative; log-facility local7;
Now make subnet details in same configuration file.
subnet 192.168.1.0 netmask 255.255.255.0 { option routers 192.168.1.254; option subnet-mask 255.255.255.0; option domain-search "lbcdomain.com"; option domain-name-servers 192.168.1.1; option time-offset -18000; # Eastern Standard Time range 192.168.1.10 192.168.1.100; }
Optional(To reserve IP for a dhcp client machine) :
If you wan to assign a static IP to a client using DHCP service, use the below command.
host station1 { option host-name "node11.lbcdomain.com"; hardware ethernet 00:12:2A:2B:3C:AB; fixed-address 192.168.1.100; }
Restart the dhcp service now to complete the DHCP server configuration.
[[email protected] ~]# systemctl restart dhcp
#vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0 BOOTPROTO=dhcp TYPE=Ethernet ONBOOT=yes
#service network restart