LFCS 160 🐧 DHCP Client Configuration
The previous chapter covered the DNS client configuration, which determines how the system resolves the hostnames. This chapter covers the DHCP client, which determines how the system obtains the IP address, the default gateway, and the DNS servers automatically. The LFCS exam lists “Configure networking and hostname resolution statically or dynamically” under the Networking domain . The critical trap is the DHCP client configuration location. On the modern systems, the DHCP client is not configured in a single file. The NetworkManager, the systemd-networkd, and the legacy dhclient each have their own configuration. The exam tests the commands that apply the DHCP settings and the mechanisms that override the DHCP-provided values.
Key point: The DHCP client obtains the IP address, the gateway, and the DNS servers from the DHCP server. The NetworkManager is the default network manager on RHEL and many modern systems, and it uses its own internal DHCP client . The systemd-networkd is the alternative that uses the .network files with DHCP=yes . The legacy dhclient is configured in /etc/dhcp/dhclient.conf . The ipv4.method auto in the NetworkManager connection enables the DHCP.
Why DHCP client configuration requires a specific mental model
The DHCP client problem. The DHCP client is the process that sends the DHCPDISCOVER broadcast, receives the DHCPOFFER, sends the DHCPREQUEST, and receives the DHCPACK with the lease. The lease contains the IP address, the subnet mask, the default gateway, the DNS servers, and the lease duration. The client applies these settings to the interface. The client also renews the lease before it expires. The renewal happens in the background .
The client selection problem. On a system with NetworkManager, the DHCP client is the NetworkManager’s internal client by default. The dhclient is the alternative, but it is deprecated in RHEL 9.5 and later . The systemd-networkd has its own built-in DHCP client. The client selection determines the configuration file and the troubleshooting commands. The grep -r dhcp /etc/NetworkManager/conf.d/ command shows which client the NetworkManager uses .
The override problem. The DHCP server provides the DNS servers and the default gateway. Sometimes the administrator wants to override the provided values. The NetworkManager has the ipv4.ignore-auto-dns yes and the ipv4.ignore-auto-routes yes settings. The ipv4.dns sets the manual DNS servers that override the DHCP-provided ones. The +ipv4.dns adds the manual servers to the DHCP-provided ones . The systemd-networkd has the UseDNS=no and the UseRoutes=no in the [DHCPv4] section .
The lease renewal problem. The DHCP lease has a duration. The client renews it at the half-life. If the renewal fails, the client tries again later. The nmcli connection down followed by the nmcli connection up forces the renewal. The nmcli device disconnect and the nmcli device connect are the alternatives. The networkctl renew eth0 is the systemd-networkd command . The dhclient -r releases the lease, and the dhclient requests the new one .
The hostname problem. The DHCP client can send the hostname to the DHCP server, which uses it to create the DNS record. The NetworkManager has the ipv4.dhcp-send-hostname yes setting. The ipv4.dhcp-hostname sets a specific hostname different from the system hostname . The dhclient.conf has the send host-name statement.
The trade-off. The NetworkManager is the user-friendly and the default on the modern systems. The systemd-networkd is the lightweight and the alternative for the servers. The dhclient is the legacy and the direct control. The exam tests the commands that apply to the specific network manager.
a. The NetworkManager DHCP configuration
The NetworkManager uses the ipv4.method auto to enable the DHCP. The nmcli command creates or modifies the connection.
# Create a DHCP connection
sudo nmcli connection add \
con-name dhcp-primary \
ifname ens192 \
type ethernet \
ipv4.method auto
# Activate the connection
sudo nmcli connection up dhcp-primary
# View the DHCP lease
nmcli device show ens192 | grep -i dhcp
The ipv4.method auto tells the NetworkManager to use the DHCP. The nmcli device show shows the DHCP lease information, including the server, the lease time, and the DNS servers .
The override settings are the ipv4.ignore-auto-dns and the ipv4.ignore-auto-routes.
# Ignore the DHCP-provided DNS
sudo nmcli connection modify dhcp-primary ipv4.ignore-auto-dns yes
sudo nmcli connection modify dhcp-primary ipv4.dns "1.1.1.1 1.0.0.1"
# Apply
sudo nmcli connection up dhcp-primary
The ipv4.ignore-auto-dns yes prevents the DHCP DNS from being used. The ipv4.dns sets the manual servers. The +ipv4.dns adds to the DHCP-provided servers instead of replacing them .
b. The systemd-networkd DHCP configuration
The systemd-networkd uses the .network files in /etc/systemd/network/. The DHCP=yes enables the DHCP.
# /etc/systemd/network/20-wired.network
[Match]
Name=en*
[Network]
DHCP=yes
The DHCP=yes enables both the DHCPv4 and the DHCPv6. The DHCP=ipv4 enables only the IPv4 .
The override settings are in the [DHCPv4] section.
[DHCPv4]
UseDNS=no
UseRoutes=no
The UseDNS=no ignores the DHCP-provided DNS. The UseRoutes=no ignores the DHCP-provided routes .
The networkctl renew forces the lease renewal.
# Force the renewal
sudo networkctl renew enp0s3
# Check the lease
networkctl status enp0s3
The networkctl status shows the lease information, including the server and the lease time .
c. The legacy dhclient configuration
The dhclient is configured in /etc/dhcp/dhclient.conf. The file uses the declarations and the statements.
# /etc/dhcp/dhclient.conf
send host-name = gethostname();
request subnet-mask, broadcast-address, time-offset, routers,
domain-name, domain-name-servers, host-name;
The send host-name sends the hostname to the server. The request statement lists the DHCP options that the client requests. The default request list includes the subnet mask, the routers, and the DNS servers .
The dhclient command releases and renews the lease.
# Release the lease
sudo dhclient -r eth0
# Request a new lease
sudo dhclient eth0
# Verbose
sudo dhclient -v eth0
The -r flag releases the current lease. The -v flag shows the DHCP exchange for the troubleshooting .
Complete Example Session
# ============================================
# PART 1: CHECK THE DHCP CLIENT
# ============================================
grep -r dhcp /etc/NetworkManager/conf.d/ /etc/NetworkManager/NetworkManager.conf 2>/dev/null
# No output means the internal client is used.
# ============================================
# PART 2: CREATE A DHCP CONNECTION
# ============================================
sudo nmcli connection add con-name dhcp-primary ifname ens192 type ethernet ipv4.method auto
sudo nmcli connection up dhcp-primary
# ============================================
# PART 3: VIEW THE LEASE
# ============================================
nmcli device show ens192 | grep -i dhcp
# DHCP4.OPTION[1]: dhcp_server_identifier = 192.168.1.1
# DHCP4.OPTION[2]: ip_address = 192.168.1.100
# ============================================
# PART 4: OVERRIDE DNS
# ============================================
sudo nmcli connection modify dhcp-primary ipv4.ignore-auto-dns yes
sudo nmcli connection modify dhcp-primary ipv4.dns "1.1.1.1"
sudo nmcli connection up dhcp-primary
# ============================================
# PART 5: RENEW THE LEASE
# ============================================
sudo nmcli connection down dhcp-primary
sudo nmcli connection up dhcp-primary
# ============================================
# PART 6: systemd-networkd DHCP
# ============================================
sudo tee /etc/systemd/network/20-wired.network <<'EOF'
[Match]
Name=en*
[Network]
DHCP=yes
EOF
sudo systemctl restart systemd-networkd
# ============================================
# PART 7: RENEW WITH networkctl
# ============================================
sudo networkctl renew enp0s3
networkctl status enp0s3
# ============================================
# PART 8: dhclient RELEASE
# ============================================
sudo dhclient -r eth0
sudo dhclient eth0
# ============================================
# PART 9: VERIFY THE IP
# ============================================
ip addr show ens192
# inet 192.168.1.100/24
The nine parts trace the DHCP client config: client check, connection creation, lease view, DNS override, lease renewal, systemd-networkd config, networkctl renewal, dhclient release, and IP verification.
Quick Reference
NetworkManager
| Command | Purpose |
|---|---|
nmcli con add ipv4.method auto | Create DHCP connection |
nmcli con up <con> | Activate |
nmcli con mod ipv4.ignore-auto-dns yes | Ignore DHCP DNS |
nmcli con mod ipv4.dns "..." | Manual DNS |
nmcli device show <dev> | grep -i dhcp | View lease |
systemd-networkd
| Setting | Purpose |
|---|---|
DHCP=yes | Enable DHCP |
[DHCPv4] UseDNS=no | Ignore DHCP DNS |
[DHCPv4] UseRoutes=no | Ignore DHCP routes |
networkctl renew <dev> | Force renewal |
networkctl status <dev> | View lease |
dhclient
| Command | Purpose |
|---|---|
dhclient <dev> | Request lease |
dhclient -r <dev> | Release lease |
dhclient -v <dev> | Verbose |
Lease Files
| Path | Purpose |
|---|---|
/var/lib/dhcp/dhclient.leases | dhclient lease |
/run/systemd/netif/leases/* | systemd-networkd lease |
Best Practices
✅ Do This:
sudo nmcli connection modify dhcp-primary ipv4.ignore-auto-dns yes
<!-- Override the DHCP DNS --> # ✅
sudo networkctl renew enp0s3
<!-- Force the systemd-networkd renewal --> # ✅
sudo dhclient -v eth0
<!-- Verbose for the troubleshooting --> # ✅
❌ Don’t Do This:
# Assume the DHCP is configured in one file
<!-- The client depends on the network manager --> # ❌
# Edit the lease file to change the IP
<!-- The lease is managed by the client --> # ❌
# Use dhclient on the NetworkManager-managed interface
<!-- The two managers conflict --> # ❌
Common Pitfalls
| Pitfall | Why It Happens | Fix |
|---|---|---|
| DHCP not working | Interface not managed | nmcli device set managed yes |
| DNS from DHCP not wanted | No override | ipv4.ignore-auto-dns yes |
| Lease not renewing | Client not triggered | nmcli con down/up |
| Two DHCP clients conflict | Both dhclient and NM | Use one manager |
| No IP after renewal | DHCP server unreachable | Check the network and the server |
Real-World Examples
1. Create DHCP Connection
sudo nmcli connection add con-name dhcp ifname eth0 type ethernet ipv4.method auto
2. Activate
sudo nmcli connection up dhcp
3. View Lease
nmcli device show eth0 | grep -i dhcp
4. Override DNS
sudo nmcli connection modify dhcp ipv4.ignore-auto-dns yes
sudo nmcli connection modify dhcp ipv4.dns "8.8.8.8"
5. Renew NetworkManager
sudo nmcli connection down dhcp && sudo nmcli connection up dhcp
6. systemd-networkd Config
[Network]
DHCP=yes
7. Renew systemd-networkd
sudo networkctl renew eth0
8. Release dhclient
sudo dhclient -r eth0
9. Request dhclient
sudo dhclient eth0
10. Verbose dhclient
sudo dhclient -v eth0
Visual
DHCP Flow
┌──────────────────────────────────────────────┐
│ Client: DHCPDISCOVER (broadcast) │
└──────────────────┬───────────────────────────┘
│
▼
┌──────────────────────────────────────────────┐
│ Server: DHCPOFFER (IP, lease) │
└──────────────────┬───────────────────────────┘
│
▼
┌──────────────────────────────────────────────┐
│ Client: DHCPREQUEST (accept) │
└──────────────────┬───────────────────────────┘
│
▼
┌──────────────────────────────────────────────┐
│ Server: DHCPACK (confirm) │
└──────────────────┬───────────────────────────┘
│
▼
┌──────────────────────────────────────────────┐
│ Client applies: IP, gateway, DNS │
└──────────────────────────────────────────────┘
Override DNS
┌──────────────────────────────────────────────┐
│ DHCP provides DNS: 192.168.1.1 │
└──────────────────┬───────────────────────────┘
│
│ ipv4.ignore-auto-dns yes
▼
┌──────────────────────────────────────────────┐
│ Manual DNS: 1.1.1.1 │
│ → Applied to the interface │
└──────────────────────────────────────────────┘
Summary
| Item | Value |
|---|---|
| NetworkManager DHCP | ipv4.method auto |
| NetworkManager DNS override | ipv4.ignore-auto-dns yes |
| systemd-networkd DHCP | DHCP=yes |
| systemd-networkd DNS override | [DHCPv4] UseDNS=no |
| systemd-networkd renewal | networkctl renew |
| dhclient config | /etc/dhcp/dhclient.conf |
| dhclient release | dhclient -r |
Key takeaways:
- The DHCP client depends on the network manager. The NetworkManager uses its internal client by default. The
systemd-networkduses its built-in client. Thedhclientis the legacy alternative . - The NetworkManager enables the DHCP with the
ipv4.method auto. Thenmcli connection addcreates the connection. Theipv4.ignore-auto-dnsoverrides the DHCP-provided DNS . - The
systemd-networkduses theDHCP=yesin the.networkfile. The[DHCPv4] UseDNS=nooverrides the DNS. Thenetworkctl renewforces the renewal . - The
dhclientreleases and renews the lease with the-rand the verbose flags. Thedhclient -r eth0releases the lease. Thedhclient eth0requests the new one . - The lease contains the IP, the gateway, and the DNS. The lease file shows the current lease. The
nmcli device showand thenetworkctl statusare the inspection commands .
Remember: The DHCP is the dynamic configuration. The NetworkManager is the default. The ipv4.method auto is the switch. The ignore-auto-dns is the override. The networkctl renew is the systemd-networkd. The dhclient -r is the release. The exam tests the commands for the specific network manager.
Stop using slow, ad-bloated tool sites! 🤮
🔎 Search “KandZ Tools” on Google to use many professional utilities for free.
KandZ.me is the ultimate minimalist hub for:
✅ Finance (Mortgage, Interest, Inflation)
✅ Tech (Base64, JSON, Dev Suite, IP)
✅ Health (BMI, BMR, TDEE)
✅ Productivity (Timer, Workspace, QR)
⚡️ Fast & Private
🔒 No data leaves your device
💎 100% Free
🔗 Use it now: https://tools.kandz.me
🔖 Bookmark it—you’ll need it later!