Setup DHCP server on Linux

Install dhcp server software

sudo apt install isc-dhcp-server

Edit the following config file and set the networking interface it should use. In this case enp60s0

sudo vi /etc/default/isc-dhcp-server

Example line to change

INTERFACESv4="enp60s0"

Now edit the dhcpd.con file

sudo vi /etc/dhcp/dhcpd.conf 

Add the following in. Change the addresses and settings as needed.

subnet 192.168.47.0 netmask 255.255.255.0 {
   range 192.168.47.26 192.168.47.30;
   option domain-name-servers ns1.internal.example.org;
   option domain-name "internal.example.org";
   option subnet-mask 255.255.255.0;
   option routers 192.168.47.1;
   option broadcast-address 192.168.47.255;
   default-lease-time 600;
   max-lease-time 7200;
 }

Set a static ip on the computer that’ll be acting as the dhcp server. You can set it as the gateway if it is the gateway.

Allow dhcp through the firewall

sudo ufw allow  67/udp
sudo ufw reload
Restart the service and connect a client.

sudo systemctl restart isc-dhcp-server

More info.

You can look at dhcp leases with the following command

tail -f /var/lib/dhcp/dhcpd.leases