How To Install DHCP Server In Linux
Apr 4, 2021
·
1 min read
In the video below, we show you how to install DHCP server in Linux using Ubuntu 20.04 LTS and ISC DHCP server
We’ll also set up a DHCP Relay Agent and firewall rules to service DHCP requests in a different subnet
Useful links:
https://ubuntu.com/download/server
Installation and configuration example:
-
Install Ubuntu and update the OS
-
Install the ISC ( Internet Systems Consortium) DHCP service
sudo apt install isc-dhcp-server
-
Bind DHCP to a specific interface
Check the interface namecd /etc/default sudo cp isc-dhcp-server isc-dhcp-server.bak
Edit the config fileip addr
sudo nano isc-dhcp-server
INTERFACESv4="ens192" INTERFACESv6="ens192"
-
Configure the DHCP service
cd /etc/dhcp sudo cp dhcpd.conf dhcpd.conf.bak sudo nano dhcpd.conf
# Global settings option domain-name "templab.lan"; option domain-name-servers 172.16.17.10; default-lease-time 600; max-lease-time 7200; # Disable DDNS ddns-update-style none; # Server is the authoritative DHCP server i.e. the only one authoritative; # Local subnet for network topology subnet 172.16.17.0 netmask 255.255.255.0 { } # Pool to lease IP addresses from subnet 172.16.19.0 netmask 255.255.255.0 { range 172.16.19.100 172.16.19.250; option routers 172.16.19.254; } # Reserved IP address for a specific host host PC2 { hardware ethernet 00:0c:29:a9:d1:4c; fixed-address 172.16.19.40; }
-
Start and check DHCP service
sudo systemctl start isc-dhcp-server sudo systemctl status isc-dhcp-server
-
DHCP Relay Agent
Configure a DHCP Relay Agent on Layer 3 gateways to point to the DHCP server -
Firewall Rules to allow DHCP traffic
Allow UDP traffic from the LAN subnet, source port 68, to the DHCP server, destination port 67 -
Check leasing
NOTE: This does not show reserved IPs. Check the config file for thatsudo dhcp-lease-list
Sharing is caring!