Redundant Linux DHCP - VBychkov-boop/Spring-SYS265-Final-Project GitHub Wiki

Ubuntu DHCP Server Setup (Primary/Secondary Failover)

Prerequisites

Run on both servers before starting:

sudo apt-get install -y isc-dhcp-server

Primary DHCP Server (172.16.1.10)

Open the config file:

sudo nano /etc/dhcp/dhcpd.conf

Paste the following:

authoritative;
 
option domain-name "GroupB1.local";
option domain-name-servers 172.16.1.12, 172.16.1.13;
default-lease-time 600;
max-lease-time 7200;
 
failover peer "dhcp-failover" {
  primary;
  address 172.16.1.10;
  port 647;
  peer address 172.16.1.11;
  peer port 647;
  max-response-delay 30;
  max-unacked-updates 10;
  mclt 1800;
  split 128;
  load balance max seconds 3;
}
 
subnet 172.16.1.0 netmask 255.255.255.0 {
  option routers 172.16.1.2;
  option subnet-mask 255.255.255.0;
  option domain-name-servers 172.16.1.12, 172.16.1.13;
  option domain-name "GroupB1.local";
 
  pool {
    failover peer "dhcp-failover";
    range 172.16.1.100 172.16.1.150;
  }
}

Secondary DHCP Server (172.16.1.11)

Open the config file:

sudo nano /etc/dhcp/dhcpd.conf

Paste the following:

authoritative;
 
option domain-name "GroupB1.local";
option domain-name-servers 172.16.1.12, 172.16.1.13;
default-lease-time 600;
max-lease-time 7200;
 
failover peer "dhcp-failover" {
  secondary;
  address 172.16.1.11;
  port 647;
  peer address 172.16.1.10;
  peer port 647;
  max-response-delay 30;
  max-unacked-updates 10;
  load balance max seconds 3;
}
 
subnet 172.16.1.0 netmask 255.255.255.0 {
  option routers 172.16.1.2;
  option subnet-mask 255.255.255.0;
  option domain-name-servers 172.16.1.12, 172.16.1.13;
  option domain-name "GroupB1.local";
 
  pool {
    failover peer "dhcp-failover";
    range 172.16.1.100 172.16.1.150;
  }
}

On Both Servers

Set the listening interface (check your interface name with ip a):

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

Set the following line:

INTERFACESv4="ens18"

Then enable, start, and open firewall ports:

# Enable and start the service
sudo systemctl enable isc-dhcp-server
sudo systemctl start isc-dhcp-server
 
# Open firewall ports
sudo ufw allow 67/udp   # DHCP client requests
sudo ufw allow 647/tcp  # DHCP failover communication
 
# Check status
sudo systemctl status isc-dhcp-server

Notes

  • Always start the primary server first — the failover handshake requires it to be up before the secondary.
  • Lease range is 172.16.1.100 – 172.16.1.150.
  • DNS is served by the domain controllers at 172.16.1.12 and 172.16.1.13.