Logo free mcse ccna rhce linux java learning free mcse ccna rhce linux java learning
          Sharefacebook twitter google+ google bookmark yahoo bookmark delicious digg linkedin pinterest reddit stumbleupon evernote diigo blinklist blogmarks livejournal email feed


How to configure Dynamic Host Configuration Protocol (DHCP) in Linux

External Resources

Dynamic Host Configuration Protocol (DHCP) is a client/server protocol that automatically provides an Internet Protocol (IP) host with its IP address and other related configuration information such as the subnet mask and default gateway.

Dynamic Host Configuration Protocol (DHCP) Lease Process

The process of leasing an IP address occurs in the following four phases:

• Discovery (Message from DHCP client to DHCP Server): The DHCP client broadcasts a DHCP discover message on the network containing its MAC address to find a DHCP server running in the network.

• Offer (Message from DHCP server to DHCP client): Each DHCP server on the network that receives the request responds with a DHCP offer message. An offered IP address is included in the message.

• Request (Message from DHCP client to DHCP Server): When a DHCP client receives a DHCPOffer packet, it responds by broadcasting a DHCPRequest packet that contains the offered IP address, and shows acceptance of the offered IP address. If multiple DHCP servers respond, the client selects the first offer it receives and broadcasts a DHCP request for the IP address. The message is broadcast on the network because the client has not yet been assigned an IP address; it has only been offered one.

• Acknowledge (Message from DHCP server to DHCP client): The DHCP server responds with a DHCPACK (acknowledgment) granting the client's request to use the IP address. The DHCPACK also contains information about any DHCP options that have been configured on the server (such as the IP address of the DNS server).

Dynamic Host Configuration Protocol (DHCP) configuration file (/etc/dhcpd.conf)

A sample Linux dhcpd.conf file is copied below.

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

subnet netmask {

# --- default gateway
option routers;
option subnet-mask;

# option nis-domain "";
option domain-name "";
option domain-name-servers;

# option time-offset + 19800; # Eastern Standard Time
# option ntp-servers;
# option netbios-name-servers;
# --- Selects point-to-point node (default is hybrid). Don't change this unless
# -- you understand Netbios very well
# option netbios-node-type 2;

# range dynamic-bootp;
default-lease-time 21600;
max-lease-time 43200;

# we want the nameserver to appear at a fixed address
# host ns {
# next-server;
# hardware ethernet 12:34:56:78:AB:CD;
# fixed-address;
# }

• ddns-update-style interim: Confirms Dynamic DHCP.

• ignore client-updates: This setting don't allow users on client computers to change their host names.

• subnet netmask Describes a network with an address of and a subnet mask of This allows the local DHCP server to assign addresses in the range to to different computers on this network. If you've configured a different network IP address, you'll want to change these settings accordingly.

• option routers: Lists the default router.

• option subnet-mask: Specifies the subnet mask for the local network.

• option nis-domain: Specifies the NIS domain name

• option domain-name: Domain name for the network

• option domain-name-servers DNS Server for the network

• option time-offset: Lists the difference from Greenwich Mean Time.

• option ntp-servers Network Time Protocol (NTP) servers

• option netbios-name-servers: WINS (Windows Internet Name Servers) Servers. Used for NetBIOS name resolution.

• range dynamic-bootp: BOOTP range

• default-lease-time: Specifies the lease time for IP address information, in seconds.

• max-lease-time Specifies the maximum lease time for IP address information, in seconds.

• next-server: Boot server for network computers

Linux Dynamic Host Configuration Protocol (DHCP) leases file is /var/lib/dhcpd/dhcpd.leases.

Dynamic Host Configuration Protocol (DHCP) Client Configuration

The command used to set up a DHCP client is the "dhclient" command, or "system-config-network" GUI tool. Make sure that the /etc/sysconfig/network configuration file includes the following line:


Next, make sure that the /etc/sysconfig/network-scripts/ifcfg-eth0 script contains the following lines (if you're using a different network device, modify the appropriate file in /etc/sysconfig/network-scripts directory):


The next time when the client is rebooted, it will get the IP address information automatically from the DHCP server configured in the network.

              Jajish Thomason Google+
Related Topics
Common Linux network tools - ping, telnet, netstat and arp Linux xinetd Super Server daemon Linux Network Interface Configuration tool - ifconfig Important Linux network configuration files Introduction to Domain Name System (DNS) Linux Domain Name System (DNS) client configuration files /etc/hosts, /etc/nsswitch.conf and /etc/resolv.conf Berkeley Internet Name Domain (BIND) as a DNS server How to configure caching-only name server BIND configuration file (/etc/named.conf) Domain Name System (DNS) zone files RNDC (Remote Name Daemon Control)
comments powered by Disqus

eXTReMe Tracker