Recovering From a Corrupted Lease Database
dhcpd
service maintains lease information, such as IP addresses, MAC
addresses, and lease expiry times, in the following flat-file databases:
- For DHCPv4:
/var/lib/dhcpd/dhcpd.leases
. - For DHCPv6:
/var/lib/dhcpd/dhcpd6.leases
.
dhcpd
service periodically regenerates the files through the following
mechanism:
- The service renames the existing lease files:
/var/lib/dhcpd/dhcpd.leases
is renamed to/var/lib/dhcpd/dhcpd.leases~
/var/lib/dhcpd/dhcpd6.leases
is renamed to/var/lib/dhcpd/dhcpd6.leases~
- The service re-creates brand new
dhcpd.leases
anddhcpd6.leases
files.
If a lease database file is corrupted, you need to restore the lease database from the last known backup of the database.
Typically, the most recent backup of a lease database is the
filename.leases~
file.
Note:
A backup instance is a snapshot taken at a particular point in time, and therefore might not reflect the latest state of the system.- For DHCPv4
-
Stop the
dhcpd
service:sudo systemctl stop dhcpd
-
Rename the corrupt lease database:
sudo mv /var/lib/dhcpd/dhcpd.leases /var/lib/dhcpd/dhcpd.leases.corrupt
-
Restore the lease database from its corresponding
filename.leases~
backup file.sudo cp -p /var/lib/dhcpd/dhcpd.leases~ /var/lib/dhcpd/dhcpd.leases
-
Start the
dhcpd
service:sudo systemctl start dhcpd
-
- For DHCPv6
-
Stop the
dhcpd
service:sudo systemctl stop dhcpd6
-
Rename the corrupt lease database:
sudo mv /var/lib/dhcpd/dhcpd6.leases /var/lib/dhcpd/dhcpd6.leases.corrupt
-
Restore the lease database from its corresponding
filename.leases~
backup file.sudo cp -p /var/lib/dhcpd/dhcpd6.leases~ /var/lib/dhcpd/dhcpd6.leases
-
Start the
dhcpd6
service:sudo systemctl start dhcpd6
-