What is DHCP Server on Linux ?

 

DHCP Server topology

 

 

  • Dynamic Host Configuration Protocol (DHCP) automatically assigns IP addresses and other network configuration information to devices on a network.
  • A client configured for DHCP will send out a broadcast request to the DHCP server requesting IP Address. The DHCP server will then issue a “lease” and assign it to that client. The time period of a valid lease can be specified on the server. DHCP reduces the amount of time required to configure clients and allows one to move a computer to various networks and be configured with the appropriate IP address, gateway and subnet mask automatically.
  • DHCP assignment:
  1. Lease Request: Client broadcasts request to DHCP server. The request includes the MAC address which is used to direct the reply.
  2. IP lease offer: DHCP server replies with an IP address, subnet mask, network gateway, name of the domain, name servers, duration of the lease and the IP address of the DHCP server.
  3. Lease Selection: Client recieves offer and broadcasts to al DHCP servers that will accept given offer so that other DHCP server need not make an offer.
  4. The DHCP server then sends an ack to the client. The client is configured to use TCP/IP.
  5. Lease Renewal: When half of the lease time has expired, the client will issue a new request to the DHCP server.
  • To set up a DHCP server, we need make sure the network card can handle multicast requests. Then you can configure DHCP configuration file, /etc/dhcp.conf.
  • If we want to use DHCP server for remote networks, we have to use dhcprelay on router/gateway between LANs. The dhcprelay supports the BOOTP protocol.
  • We can install dhcp by rpm or yum on Centos Redhat, or install by dpkg package or apt-get on Ubuntu – Debian.

Basic knowledge about DHCP Server on Linux.

  • Before we start configuring dhcp /etc/dhcp.conf, we need check if multicast support on network card or not. We may also need to enable the “all ones” broadcast address.
  • To check multicast address, we can use “ifconfig” command.
[root@ITHelpBlog ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:BF:74:53
inet addr:192.168.0.102 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:febf:7453/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:37674 errors:0 dropped:0 overruns:0 frame:0
TX packets:13581 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:46680179 (44.5 MiB) TX bytes:1138849 (1.0 MiB)
  • The configuration file /etc/dhcp.conf
    • have one sample file from dhcp-*. RPM, dhcp.conf.sample in /usr/share/doc/dhcp-version directory.
    • To learn more about DHCP servers, we may find it helpful to analyze the file in detail.
    • ddns-update-style interim;   –> allow Dynamic DNS updates to lastest available “interim” standard.
    • ingore client-updates;  –> We don’t want individual users to update their hostname or IP address on DNS server.
    • subnet 192.168.0.0 netmask 255.255.255.0 {  –> default range of allowable IP Addresses.
    • option routers 192.168.0.1;  –> Gateway for our DHCP subnets, normally it’s router ip address.
    • option subnet-mask 255.255.255.0; –> subnet mask of the DHCP subnets.
    • option nis-domain “ithelpblog.com”; –> NIS authorization database for our network.
    • option domain-name “ithelpblog.com”; –> Domain name of our DHCP client network.
    • option domain-name-servers 192.168.0.5; –> DNS Server configurationf for DHCP clients.
    • option time-offset -18000; –> keep our dhcp server and client synchronized. Default is second 18000 –> 5 hours.
    • option ntp-servers 192.168.0.10; –> NTP server to update time automatically on dhcp clients.
    • option netbios-name-servers 192.168.0.5; –> WINS servers.
    • option netbios-node-type 2;   –> configure dhcp server as a “p-node”.
    • range dynamic-bootp 192.168.0.128 192.168.0.253  –> configure the range of IP address what this DHCP server can assing to computer on remote networks. (if we only serve for local LAN, we don’t need this).
    • default-lease-time 21600 –> the time IP will be renewed.
    • max-lease-time 43200 –> maximum time IP will be renewed.
    • host ns { hardware ethernet xx:xx:xx:xx:xx:xx fixed address 192.168.0.100} –> configure fixed ip address for DHCP client by mac-address.
  • Start dhcp server : /etc/init.d/dhcpd start

 

Thanks for using IThelpblog.com.

Leave a Reply

Your email address will not be published. Required fields are marked *

Go to top