Recovering From a Corrupted Lease Database

The 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.
To prevent the lease database files from becoming too large with stale data, the dhcpd service periodically regenerates the files through the following mechanism:
  1. 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~
  2. The service re-creates brand new dhcpd.leases and dhcpd6.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.
Ensure that you have the required administrative privileges and complete the following steps:
  • For DHCPv4
    1. Stop the dhcpd service:

      sudo systemctl stop dhcpd
    2. Rename the corrupt lease database:

      sudo mv /var/lib/dhcpd/dhcpd.leases /var/lib/dhcpd/dhcpd.leases.corrupt
    3. Restore the lease database from its corresponding filename.leases~ backup file.

      sudo cp -p /var/lib/dhcpd/dhcpd.leases~ /var/lib/dhcpd/dhcpd.leases
    4. Start the dhcpd service:

      sudo systemctl start dhcpd
  • For DHCPv6
    1. Stop the dhcpd service:

      sudo systemctl stop dhcpd6
    2. Rename the corrupt lease database:

      sudo mv /var/lib/dhcpd/dhcpd6.leases /var/lib/dhcpd/dhcpd6.leases.corrupt
    3. Restore the lease database from its corresponding filename.leases~ backup file.

      sudo cp -p /var/lib/dhcpd/dhcpd6.leases~ /var/lib/dhcpd/dhcpd6.leases
    4. Start the dhcpd6 service:

      sudo systemctl start dhcpd6