Introduction:
Dynamic Host Configuration Protocol is a network protocol which is used to Distribute network configuration parameters. It involves the configuration of IP addresses, gateways, and DNS for Network interfaces. It provides the automation of IP assigning.
Install & Configure DHCP server on CentOS 7
Run the given command to Install DHCP server and client.
yum install dhcp
After the successful installation of packages, copy the sample configuration file to /etc/dhcp/directory
cp /usr/share/doc/dhcpd.conf.example /etc/dhcp/dhcpd.conf
When you have finishing copying, edit the dhcpd.conf file.
vi /etc/dhcp/dhcpd.conf
You can define the subnet, range of IP addresses, domain & domain name servers as below:
[…]
Configuring subnet and iprange
subnet 192.168.12.0 netmask 255.255.255.0 {
range 192.168.12.100 192.168.12.200;
Specify DNS server ip and additional DNS server ip
option domain-name-servers 8.8.8.8, 8.8.4.4;
Specify Domain Name
option domain-name "osradar.local";
Default Gateway
option routers 192.168.12.2;
option broadcast-address 192.168.12.255;
Specify Default and Max lease time
default-lease-time 600;
max-lease-time 7200;
}
[…]
Note: You can define according to your own requirements.
For assigning fixed IP address to your clients, you will need to enter their MAC id and the IP address in the following syntax.
[…]
host mywindows-client {
hardware ethernet 00:0C:29:05:A7:CB;
fixed-address 192.168.12.110;
}
[…]
Start and Enable dhcpd services
Type the below commands to take the effect of configurations
systemctl start dhcpd
systemctl enable dhcpd
Note: If you face any issue, you can update the SELinux or disable it permanently.
/sbin/restorecon -v /etc/dhcp/dhcpd.conf
Now, proceed towards the configuration of DHCP Client’s to attain the IP addresses automatically from the DHCP server.
Install & Configure DHCP Server on Ubuntu 18.04 / Debian 9
Type the below command to get install DHCP on Ubuntu system.
sudo apt-get install isc-dhcp-server
After installing assign the interfaces that would requests to DHCP . If you have only one interface it will assign that one.
Configure the file /etc/default/isc-dhcp-server
sudo nano /etc/default/isc-dhcp-server
Bold eth0 in the file.
Now, edit the dhcpd.conf file
sudo nano /etc/dhcp/dhcpd.conf
Make the changes as given below
[…]
Configuring subnet and iprange
subnet 192.168.12.0 netmask 255.255.255.0 {
range 192.168.12.100 192.168.12.200;
Specify DNS server ip and additional DNS server ip
option domain-name-servers 8.8.8.8, 8.8.4.4;
Specify Domain Name
option domain-name "osradar.local";
Default Gateway
option routers 192.168.12.2;
option broadcast-address 192.168.12.255;
Specify Default and Max lease time
default-lease-time 600;
max-lease-time 7200;
}
[…]
To configure fixed IP addresses follow the below pattern
host mywindows-client {
hardware ethernet 00:0C:29:05:A7:CB;
fixed-address 192.168.12.110;
}
After Installing , now start the dhcpd services and do it start automatically on system reboot
sudo service isc-dhcp-server restart
So, this is how you can Configure DHCP client server.