Fixing DHCP Client Static IP Request Issues: Why dhclient Ignores fixed-address Configuration


10 views

When configuring dhclient to request a specific static IP address (192.168.1.222 in your case), the DHCP client still requests a different address (192.168.1.27) from the server. The configuration appears in /etc/dhcp3/dhclient.conf but isn't being honored during the lease acquisition process.

# Current dhclient.conf snippet showing the problematic configuration
alias {
  interface "eth0";
  fixed-address 192.168.1.222;
}
lease {
  interface "eth0";
  fixed-address 192.168.1.222;
  option subnet-mask 255.255.255.0;
  option broadcast-address 255.255.255.255;
  option routers 192.168.1.254;
  option domain-name-servers 192.168.1.254;
}

The fixed-address directive in dhclient.conf serves a different purpose than what you're trying to achieve:

  • The alias block is for defining a backup/secondary IP
  • The lease block defines parameters for existing leases, not new requests
  • DHCP protocol fundamentally requires the server to assign the IP address

Method 1: DHCP Reservation (Recommended)

Configure your DHCP server to always assign 192.168.1.222 to your MAC address:

# Example ISC DHCP server configuration (dhcpd.conf)
host specific-host {
  hardware ethernet 00:1c:25:97:82:20;
  fixed-address 192.168.1.222;
}

Method 2: Static IP Configuration

If you need guaranteed static addressing, bypass DHCP entirely:

# /etc/network/interfaces example for Debian-based systems
auto eth0
iface eth0 inet static
    address 192.168.1.222
    netmask 255.255.255.0
    gateway 192.168.1.254
    dns-nameservers 192.168.1.254

Method 3: dhclient Script Hook

You can use a dhclient exit hook to enforce your preferred IP:

# /etc/dhcp/dhclient-exit-hooks.d/static-ip
#!/bin/sh
if [ "$interface" = "eth0" ] && [ "$reason" = "BOUND" ]; then
    if [ "$new_ip_address" != "192.168.1.222" ]; then
        ip addr flush dev eth0
        ip addr add 192.168.1.222/24 dev eth0
        ip route add default via 192.168.1.254
    fi
fi

To verify dhclient behavior:

# Run dhclient in foreground with debug output
dhclient -d -v eth0

# Check which configuration files are being read
strace -e open dhclient eth0 2>&1 | grep dhclient

Remember that DHCP is designed as a server-controlled protocol. While clients can request specific IPs (using the 'requested address' DHCP option), the server ultimately decides which address to assign. The fixed-address parameter in dhclient.conf only affects how the client handles leases, not what it requests from the server.


When configuring dhclient to request a specific static IP address through DHCP (192.168.1.222 in this case), the DHCP client continues to request a different address (192.168.1.27) from the server. This occurs despite having properly configured the fixed-address parameter in both the alias and lease sections of /etc/dhcp3/dhclient.conf.

Many administrators assume the fixed-address parameter in dhclient.conf works similarly to a DHCP reservation on the server side. However, these are fundamentally different mechanisms:

# This is NOT how client-side static DHCP works
alias {
  interface "eth0";
  fixed-address 192.168.1.222; # This doesn't force the server to give this IP
}

The fixed-address in dhclient.conf serves these purposes:

  • For alias section: Provides a temporary IP during DHCP negotiation
  • For lease section: Specifies what IP to request when renewing an existing lease

To truly guarantee a specific IP address, you need these complementary approaches:

# Method 1: DHCP client identifier (more reliable)
send dhcp-client-identifier "myhost-eth0";

# Method 2: Combine with server-side reservation
interface "eth0" {
  send host-name "myhost";
  send dhcp-client-identifier "myhost-mac-001c25978220";
  request subnet-mask, routers, domain-name-servers;
  require subnet-mask, domain-name-servers;
}

Use these commands to understand what's happening:

# Verbose output
dhclient -v eth0

# Check lease file
cat /var/lib/dhcp/dhclient.leases

# Test config parsing
dhclient -pf /tmp/dhclient.test.pid -cf /etc/dhcp/dhclient.conf eth0

For complete control, configure your DHCP server (e.g., ISC DHCPD) with:

host myhost {
  hardware ethernet 00:1c:25:97:82:20;
  fixed-address 192.168.1.222;
  option host-name "myhost";
}

If you must have a specific IP but can't modify the DHCP server:

# First configure the IP manually
ifconfig eth0 192.168.1.222 netmask 255.255.255.0

# Then request other parameters via DHCP
dhclient -r eth0
dhclient -d -v -sf /etc/dhclient-script -cf /etc/dhclient.conf eth0