When Linux servers with static DHCP leases lose their IP addresses due to DHCP server unavailability, they may stop attempting to renew their leases altogether. This behavior creates operational headaches, especially in mixed CentOS/Fedora environments where network managers may handle DHCP differently.
The default DHCP client behavior follows this sequence:
1. Initial request (discover/offer/request/ack)
2. Renewal attempts at 50% of lease time (T1)
3. Rebinding attempts at 87.5% of lease time (T2)
4. Final expiration at 100% lease time
After lease expiration, most clients enter a "failed" state rather than restarting the discovery process.
The most reliable approach involves configuring the DHCP client to never give up:
For NetworkManager Systems (Fedora/RHEL8+)
Create or modify the connection profile:
nmcli connection modify "YourConnection" \
ipv4.dhcp-timeout 0 \
ipv4.may-fail no \
connection.autoconnect-retries -1
This configuration tells NetworkManager to:
- Remove DHCP timeout limits
- Never consider DHCP failed
- Retry indefinitely
For legacy dhclient Systems (CentOS 7)
Edit /etc/dhcp/dhclient.conf:
timeout 300;
retry 60;
reboot 10;
select-timeout 5;
initial-interval 2;
script "/sbin/dhclient-script";
lease {
interface "eth0";
fixed-address 192.168.1.100;
option subnet-mask 255.255.255.0;
renew 2 2024/1/1 00:00:01;
rebind 2 2024/1/1 00:00:01;
expire 2 2024/1/1 00:00:01;
}
The critical parameters are the extremely short renew/rebind/expire intervals that force constant lease verification.
For additional protection, create a systemd service to periodically check connectivity:
[Unit]
Description=DHCP Connection Watchdog
After=network.target
[Service]
ExecStart=/usr/local/bin/dhcp-watchdog
Restart=always
[Install]
WantedBy=multi-user.target
With the watchdog script:
#!/bin/bash
while true; do
if ! ip a show eth0 | grep -q "inet "; then
systemctl restart NetworkManager
fi
sleep 60
done
Check current DHCP status with:
# For NetworkManager
nmcli device show eth0 | grep DHCP
journalctl -u NetworkManager --no-pager -n 50
# For dhclient
cat /var/lib/dhclient/dhclient.leases
journalctl -u network --no-pager -n 50
When running Linux servers with static DHCP leases, network interruptions can create a frustrating scenario where systems don't automatically recover their IP assignments after DHCP service restoration. The default dhclient behavior in RHEL-based systems (CentOS/Fedora) involves giving up after several failed renewal attempts.
The key solution lies in modifying the DHCP client configuration to implement aggressive renewal attempts. Here's the standard approach:
# Edit the main dhclient configuration
vi /etc/dhcp/dhclient.conf
# Add these critical parameters:
retry 60; # Retry every 60 seconds indefinitely
backoff-cutoff 15; # Maximum backoff time of 15 seconds
initial-interval 2; # First retry after 2 seconds
reboot 10; # Wait 10 seconds after reboot
timeout 300; # Wait 5 minutes before timing out
For systems using systemd-networkd (common in newer Fedora versions), create a custom service:
# /etc/systemd/system/dhcp-renewal.service
[Unit]
Description=Persistent DHCP renewal service
After=network.target
[Service]
Type=oneshot
ExecStart=/usr/sbin/dhclient -v -r
ExecStart=/usr/sbin/dhclient -v
Restart=on-failure
RestartSec=30s
[Install]
WantedBy=multi-user.target
Then enable with:
systemctl daemon-reload
systemctl enable --now dhcp-renewal.service
For critical infrastructure, consider implementing interface monitoring through a cron job or systemd timer:
#!/bin/bash
# /usr/local/bin/network-watchdog.sh
INTERFACE="eth0"
TEST_IP="8.8.8.8"
if ! ping -c 2 -I $INTERFACE $TEST_IP > /dev/null 2>&1; then
echo "$(date) - Network connection down. Attempting renewal..."
ifdown $INTERFACE && ifup $INTERFACE
fi
After implementation, test your configuration by:
# Check current lease information
dhclient -d eth0
# Force release and renew
dhclient -r eth0 && dhclient eth0
# Monitor renewal attempts
journalctl -u systemd-networkd -f