DHCPD Quick Setup Instructions


Sample of how to set up DHCPD server on Red Hat 7.0

  1. Copy over the sample dhcpd.conf file
  2. cp /usr/share/doc/dhcp-2.0pl5/dhcpd.conf.sample /etc/dhcpd.conf
  3. Edit /etc/dhcpd.conf
  4. Here’s a copy of the unmodified sample:


    subnet 192.168.0.0 netmask 255.255.255.0 { # --- default gateway option routers 192.168.0.1; option subnet-mask 255.255.255.0; option nis-domain "domain.org"; option domain-name "domain.org"; option domain-name-servers 192.168.1.1; option time-offset -5; # Eastern Standard Time # option ntp-servers 192.168.1.1; # option netbios-name-servers 192.168.1.1; # --- 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 192.168.0.128 192.168.0.255; default-lease-time 21600; max-lease-time 43200; # we want the nameserver to appear at a fixed address host ns { next-server marvin.redhat.com; hardware ethernet 12:34:56:78:AB:CD; fixed-address 207.175.42.254; } }

    Here’s the file I used after modifying the above sample:


    subnet 192.168.0.0 netmask 255.255.255.0 { # --- default gateway option routers 192.168.0.1; option subnet-mask 255.255.255.0; option nis-domain "linuxclinic.org"; option domain-name "linuxclinic.org"; option domain-name-servers 192.168.0.100; option time-offset -6; # Central Standard Time # option ntp-servers 192.168.1.1; # option netbios-name-servers 192.168.1.1; # --- Selects point-to-point node (default is hybrid). Don't change this unless # -- you understand Netbios very well # option netbios-node-type 2; #Dhcpd server will give out addresses between 128 and 255 range dynamic-bootp 192.168.0.128 192.168.0.255; default-lease-time 21600; max-lease-time 43200; #server.linuxclinic.org:/techtour/ks.cfg is the nfs share # for a kickstart confgiuration file filename "/techtour/ks.cfg"; next-server server.linuxclinic.org; } #I'm handing out fixed addresses and names for the following mac addresses #Cim Console host TechCommEv { hardware ethernet 00:80:5f:1d:57:47; fixed-address 192.168.0.2; } host tech1 { hardware ethernet 00:50:8b:d3:f9:ed; fixed-address 192.168.0.30; option host-name "tech1"; } host tech2 { hardware ethernet 00:50:8b:e1:5d:dc; fixed-address 192.168.0.31; option host-name "tech2"; } host tech3 { hardware ethernet 00:50:8b:e1:e8:f2; fixed-address 192.168.0.32; option host-name "tech3"; } host tech4 { hardware ethernet 00:50:8b:e0:1c:e2; fixed-address 192.168.0.33; option host-name "tech4"; } host tech5 { fixed-address 192.168.0.34; option host-name "tech5"; hardware ethernet 00:50:8b:f2:c5:c4; }
  5. If your dhcpd.leases file doesn’t exist, then generate it with the touch command
  6. touch /var/lib/dhcp/dhcpd.leases
  7. Restart dhcpd
  8. /etc/rc.d/init.d/dhcpd restart
  9. Check that dhcpd is running
  10. ps ax | grep dhcpd | grep -v grep
  11. If dhcpd is not running, then run it directly to get more description on the error
  12. /usr/sbin/dhcpd
  13. Also check /var/log/messages for other error messages
  14. tail -50 /var/log/messages
  15. Make sure that you have dhcpd starting on bootup
  16. chkconfig --list dhcpd
  17. If it is not set for runlevels 2345, then set it
  18. chkconfig --level 2345 dhcpd on
  19. After adding my 2nd network card, I noticed dhcpd wasn’t working anymore.

    If more than one network card resides in the DHCP server, it is recommended to specify which interface(s) the DHCP server will use. Edit /etc/sysconfig/dhcpd by adding the appropriate interface to the DHCPDARGS= line. The entry in /etc/sysconfig/dhcpd should appear as follows:

    DHCPDARGS=eth0

    The dhcpd server loads without problem after adding this entry.

  20. Check out the pump.html page if you will be working with Linux dhcp clients. Pump can be used to request, release, or give status on dhcp responses.
  21. Cool test
  22. ping -c 2 -b 192.138.0.255 | sort
    arp -a
    

  23. More Info / Debugging
  24. Here are several means for debugging in no particular order:

    • /usr/sbin/dhcpd -d -f
    • tail -f /var/lib/dhcpd.leases
    • tail -f /var/log/messages

  25. Getting Help
  26. You can look at the help files: “man dhcpd” and “man dhcpd.conf”.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.