Ubuntu DHCP Server Migration Steps
Migrating a DHCP server on Ubuntu involves backing up configurations and lease data from the old server, installing ISC DHCP on the new server, restoring the data, and validating the new service. Below is a structured guide to ensure a smooth transition:
Before starting, ensure you have administrative access to both the old and new Ubuntu servers, and that the new server meets hardware/network requirements (e.g., static IP, correct subnet).
Key prerequisites:
rsync, scp) installed.The DHCP server’s configuration and lease data must be preserved to avoid reconfiguring from scratch.
/etc/dhcp/dhcpd.conf) contains subnet definitions, options (e.g., DNS, gateway), and reservations.sudo cp /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.bak
/var/lib/dhcp/dhcpd.leases) tracks assigned IPs and client information.sudo cp /var/lib/dhcp/dhcpd.leases /var/lib/dhcp/dhcpd.leases.bak
sudo tar -czvf dhcp_backup.tar.gz /etc/dhcp/dhcpd.conf.bak /var/lib/dhcp/dhcpd.leases.bak
The new server needs the ISC DHCP package installed to run the DHCP service.
sudo apt update
sudo apt install isc-dhcp-server
During installation, the package will create default config files (e.g., /etc/dhcp/dhcpd.conf). You’ll replace these with the old server’s configs in later steps.
Transfer the backed-up files from the old server to the new one and place them in the correct directories.
scp (secure copy) or a USB drive to transfer the compressed backup to the new server. Extract it and move the config file to /etc/dhcp/.scp user@old_server_ip:/path/to/dhcp_backup.tar.gz /tmp/
tar -xzvf /tmp/dhcp_backup.tar.gz -C /tmp/
sudo mv /tmp/etc/dhcp/dhcpd.conf.bak /etc/dhcp/dhcpd.conf
/var/lib/dhcp/.sudo mv /tmp/var/lib/dhcp/dhcpd.leases.bak /var/lib/dhcp/dhcpd.leases
dhcpd:dhcpd) to allow the DHCP service to read/write it.sudo chown dhcpd:dhcpd /var/lib/dhcp/dhcpd.leases
Update the new server’s network interface and DHCP settings to match the old server’s configuration.
/etc/default/isc-dhcp-server and specify the network interface(s) the DHCP service should listen on (replace eth0 with your actual interface, e.g., ens33).sudo nano /etc/default/isc-dhcp-server
Modify the INTERFACESv4 line:INTERFACESv4="eth0"
/etc/dhcp/dhcpd.conf and verify key parameters (subnet, range, options, reservations) match the old server’s setup. Pay special attention to:
subnet 192.168.1.0 netmask 255.255.255.0).range 192.168.1.10 192.168.1.100).option routers 192.168.1.1).option domain-name-servers 8.8.8.8, 8.8.4.4).authoritative;
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.10 192.168.1.100;
option routers 192.168.1.1;
option domain-name-servers 8.8.8.8, 8.8.4.4;
}
Activate the DHCP service on the new server and confirm it’s running correctly.
sudo systemctl start isc-dhcp-server
sudo systemctl status isc-dhcp-server
Look for “active (running)” in the output.sudo dhclient -r eth0 # Release current lease
sudo dhclient eth0 # Request new lease
Verify the assigned IP is within the new server’s range (use ip a or ifconfig on the client).Once the new server is confirmed to be working, disable the DHCP service on the old server to prevent conflicts.
sudo systemctl stop isc-dhcp-server
sudo systemctl disable isc-dhcp-server
sudo apt remove --purge isc-dhcp-server
journalctl -u isc-dhcp-server or /var/log/syslog).By following these steps, you can migrate your Ubuntu DHCP server with minimal downtime and ensure uninterrupted IP address management for your network.