Sharing Knowledge | System Admin Articles

DHCP Installation and Configuration in Linux

DHCP - Dynamic Host Configuration Protocol Daemon

What DHCP Server can do? 

1. Provides automatic configuration of IPv4 clients

  • IPv4 address
  • Subnet mask
  • Default gateway
  • DNS Server
  • NTP Servers
  • WINS Servers

 2. Leases the addreses and related information based on predefined values:

  •   1 day
  •   1 week
  •   1 month

 3. DHCP uses UDP protocol and layer-2 information to request/assign addresses

 4. DHCP Process - DORA

  • Discovery - client broadcasts on the local subnet for a DHCP server
  • Offer - returned by the DHCP server
  • Request - formal address request by client
  • Acknowledgement/Acceptance - Acknowledgement occurrs

Note: DHCPD daemon records leases in: /var/lib/dhcpd/dhcpd.leases

Installing DHCP Server:

 1. Install DHCP server
     #yum -y install dhcp

 2. Configure: /etc/dhcpd.conf - primary config file.

Look at sample dhcp configuration file below for the details:

ddns-update-style interim;                                   
ignore client-updates;

subnet netmask {

range;                # Range of IP addresses to be issued to DHCP clients
option subnet-mask    ;     # Default subnet mask to be used by DHCP clients
option broadcast-address;      # Default broadcastaddress to be used by DHCP clients
option routers        ;             # Default gateway to be used by DHCP clients
option domain-name              "";
option domain-name-servers,;   # Default DNS to be used by DHCP clients
option netbios-name-servers; # Specify a WINS server for Windows clients. Its Optional.
default-lease-time 21600;                      # Amount of time in seconds that a client may keep the IP address
max-lease-time 43200;
option time-offset              -18000;                        # Eastern Standard Time
option ntp-servers    ;               # Default NTP server to be used by DHCP clients

# We want the nameserver "mailsrv2" to appear at a fixed address.
# Name server with this specified MAC address will recieve this IP.

        host mailsrv2 {
                hardware ethernet 00:12:f3:d0:f5:93;

        host laser-printer-hp1 {
                hardware ethernet 06:20:2e:4f:b3:88;

Note: DHCP can be configured with more and more options. I have specified very limited only here. refer the man page for details.

 3. Set service up to start when system boots
     #chkconfig dhcpd on - 2345

 4. Start DHCP service:
     #service dhcpd start

 How to Setup DHCP reservations? 

  •  Requires the MAC address of the client (00:0D:69:A5:15:94)
  •  Requires the 'fixed-address' - IPv4 address to map to the MAC address
  •  Optional 'option-*' are supported between host { } block
  •  service dhcpd restart - restart to effect changes

Labels: DHCP, Linux

My Profile PhotoAbout the Author

I'm Parthiban, An UNIX System Admin by Profession. I'm Experienced in Linux/Unix System Administration and Scripting. I have done lot of work on the infrastructure Mgmt side in Linux, UNIX and Windows system administration, Hardware, Storage and Data center. I'm blogging since 2008.
Follow Me On Twitter or On Facebook

0 Comments for "DHCP Installation and Configuration in Linux"

What do you think about this Article? Add your Opinion..!

Back To Top