Mastering DHCP on CentOS: Theory, Configuration, and Hands‑On Setup
This guide explains DHCP fundamentals, its four‑step lease process, allocation methods, advantages, and provides a step‑by‑step tutorial for installing and configuring a DHCP server on CentOS 6.5, including client testing and static host assignments.
Overview
DHCP (Dynamic Host Configuration Protocol) is widely used in large LANs to centrally manage and distribute IP addresses, gateways, DNS servers, and other network parameters, improving address utilization and simplifying host configuration.
Working Principle
The DHCP lease process consists of four broadcast phases:
Client boots without an IP and broadcasts a DISCOVER message to locate any DHCP server.
Available servers respond with an OFFER containing an IP address; the client typically selects the first offer after ARP verification.
The client sends a REQUEST broadcast to confirm the chosen server and inform other servers of its selection.
The server finalizes the lease with an ACK , delivering the IP address, subnet mask, gateway, DNS, and lease time.
When a client reboots, it may receive an ACK if the previous IP is still free (lease must be renewed after 50% of its duration) or a NACK if the address is taken, prompting a new lease cycle.
DHCP Allocation Methods
Automatic allocation : Assigned IP is used permanently.
Manual allocation : Administrator explicitly assigns a specific IP.
Dynamic allocation : IP is released after use for reuse by other clients.
Advantages of DHCP
Reduces administrative workload.
Prevents IP address conflicts.
Facilitates network renumbering without reconfiguring each host.
Improves IP address utilization.
Simplifies client configuration.
Information Provided to Clients
IP address and subnet mask.
Network and broadcast addresses.
Default gateway.
DNS server addresses.
Experimental Environment
Operating system: CentOS 6.5
Host IP: 192.168.1.20
DHCP package: dhcp-4.1.1-38.P1.el6.centos.x86_64.rpm
Setup Steps
1. Install DHCP Server
Execute the following commands on the server:
# cd /mnt/sr0/Packages/ # rpm -ivh dhcp-4.1.1-38.P1.el6.centos.x86_64.rpm2. Inspect and Edit Main Configuration
Open the default configuration file to review its contents: # vim dhcpd.conf Replace the sample configuration with a fresh copy and edit it:
# cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf # vim /etc/dhcp/dhcpd.confAdjust the address pool, subnet mask, default router, DNS servers, and any static host mappings as needed (see the screenshots in the original article).
3. Test from a Client
Modify the client’s network script to use DHCP: # vim /etc/sysconfig/network-scripts/ifcfg-eth0 After restarting the network service, the client should obtain an IP lease from the server, which can be verified with ifconfig or ip addr.
4. Assign a Fixed IP to a Specific Host
Obtain the client’s MAC address (shown in the screenshot) and add a host reservation in /etc/dhcp/dhcpd.conf:
host myhost { hardware ethernet 00:11:22:33:44:55; fixed-address 192.168.1.100; }Reload the DHCP service to apply the changes.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
