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 192.168.1.0 netmask 255.255.255.0 {


range  192.168.1.10 192.168.1.250;                # Range of IP addresses to be issued to DHCP clients
option subnet-mask              255.255.255.0;     # Default subnet mask to be used by DHCP clients
option broadcast-address    192.168.1.255;      # Default broadcastaddress to be used by DHCP clients
option routers                  192.168.1.1;             # Default gateway to be used by DHCP clients
option domain-name              "your-domain.com";
option domain-name-servers   50.145.43.254, 50.145.43.253;   # Default DNS to be used by DHCP clients
option netbios-name-servers     192.168.1.200; # 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              192.168.1.1;               # 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 {
                next-server mailsrv2.your-domain.com;
                hardware ethernet 00:12:f3:d0:f5:93;
                fixed-address 50.145.43.254;
        }


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

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

Share this

Related Posts

Previous
Next Post »

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