How to Install and configure DHCP Server on Ubuntu 20.04

DHCP is a service used to provide automatically IP Addresses to clients on a network.DHCP is used to provide IP configuration settings, such as IP address, net mask, default gateway, and DNS servers.

There are two allocation method for DHCP :Manual & Automatic.In manual,the P Address is assign on the basis of the MAC Address.A particular machine gets a fixed IP Address as its IP Address is then tied to its MAC Address.In auctomatic,the IP Addresses are provided automatically by the DHCP Server.

 

Install DHCP on Ubuntu

Update the system.

apt-get update

Install DHCP server.

apt-get install isc-dhcp-server

Start & Enable the DHCP service.

systemctl start isc-dhcp-server.service
systemctl enable isc-dhcp-server.service

 

Configure DHCP Server

Go to DHCP directory.

cd /etc/dhcp

Open the dhcpd.conf file using vim editor.

vim dhcpd.conf

Edit the following lines.

# a simple /etc/dhcp/dhcpd.conf
option domain-name "domain-name";
option domain-name-servers domain-server-name1, domain-server-name2;

default-lease-time 600;
max-lease-time 7200;
authoritative;
 
subnet ip-address netmask 255.255.255.0 {
 range range-ip-address1 range-ip-address2;
 option routers router-ip-address;

}

host server1 {
hardware ethernet mac-address;
fixed-address ip-address;
}

Bind the DHCP Server to an interface.

  • Open /etc/default/isc-dhcp-server file.Provide the value.
INTERFACESv4="eth0"

Allow the port number 67/UDP.

ufw allow  67/udp
ufw reload

Restart the DHCP Server

systemctl restart isc-dhcp-server.service

Check status of DHCP service

systemctl status isc-dhcp-server.service

Fig 1

 

Testing DHCP service.

  • Run the following command
ip a

Here is the command output.

  • Got the IP address.

Fig 2

 

 

Leave a Reply