Sample of how to set up DHCPD server on Red Hat 7.0
- Copy over the sample dhcpd.conf file
- Edit /etc/dhcpd.conf
- If your dhcpd.leases file doesn’t exist, then generate it with the touch command
- Restart dhcpd
- Check that dhcpd is running
- If dhcpd is not running, then run it directly to get more description on the error
- Also check /var/log/messages for other error messages
- Make sure that you have dhcpd starting on bootup
- If it is not set for runlevels 2345, then set it
- 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.
- 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.
- Cool test
- More Info / Debugging
- /usr/sbin/dhcpd -d -f
- tail -f /var/lib/dhcpd.leases
- tail -f /var/log/messages
- Getting Help
cp /usr/share/doc/dhcp-2.0pl5/dhcpd.conf.sample /etc/dhcpd.conf
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; }
touch /var/lib/dhcp/dhcpd.leases
/etc/rc.d/init.d/dhcpd restart
ps ax | grep dhcpd | grep -v grep
/usr/sbin/dhcpd
tail -50 /var/log/messages
chkconfig --list dhcpd
chkconfig --level 2345 dhcpd on
ping -c 2 -b 192.138.0.255 | sort arp -a
Here are several means for debugging in no particular order:
You can look at the help files: “man dhcpd” and “man dhcpd.conf”.