Setting up the Server
For starters, lets configure the /etc/dhcpd.conf file. It's pretty self explanitory. If you are planning on setting up a local DNS server leave in the 3 lines pertaining to Dynamic DNS, otherwise take them out.
#
# Global Settings
#
# Turn on Dynamic DNS:
ddns-domainname "domain.lan";
ddns-update-style interim;
ddns-updates on;
# Don't allow clients to update DNS, make the server do it
# based on the hostname passed by the DHCP client:
deny client-updates;
allow unknown-clients;
#
# 10.0.0.0/255.255.255.0 Scope Settings
#
subnet 10.0.0.0 netmask 255.255.255.0 {
# Range of DHCP assigned addresses for this scope
range 10.0.0.100 10.0.0.200;
# 1 day
default-lease-time 86400;
# 2 days
max-lease-time 172800;
# Configure the client's default Gateway:
option subnet-mask 255.255.255.0;
option broadcast-address 10.0.0.255;
option routers 10.0.0.2;
# Configure the client's DNS settings:
option domain-name "domain.lan";
option domain-name-servers 10.0.0.1;
}
Now things get a little tricky. If you have Windows clients you are going to need to modify the /etc/rc.d/init.d/dhcpd file. In the start() directive you should see a line that looks something like
daemon /usr/sbin/dhcpd ${DHCPDARGS}
Comment that out with a # and add in the following lines. If you want, add in the DHCPDARGS also, but I don't really use it.
/sbin/route add -host 255.255.255.255 dev eth0 2> /dev/null
daemon /usr/sbin/dhcpd eth0
Make sure you set the ethx to the network interface you want to serve dhcpd requests on. This is particularly vital if you have a multihomed server.
Setting up the Client
The client needs to send a hostname for this to work correctly. The DHCP server needs to know what hostname to set in DNS. Windows does it by default, however you'll need to make sure your /etc/sysconfig/network-scripts/ifcfg-ethx file looks something like this (with the DHCP_HOSTNAME directive set properly.
# make sure this line is has no settings on it!
DEVICE=eth0
BOOTPROTO=dhcp
HWADDR=01:01:01:01:01:01
ONBOOT=yes
TYPE=Ethernet
DHCP_HOSTNAME=host
USERCTL=no
PEERDNS=yes
READ MORE - Setting up the Server
For starters, lets configure the /etc/dhcpd.conf file. It's pretty self explanitory. If you are planning on setting up a local DNS server leave in the 3 lines pertaining to Dynamic DNS, otherwise take them out.
#
# Global Settings
#
# Turn on Dynamic DNS:
ddns-domainname "domain.lan";
ddns-update-style interim;
ddns-updates on;
# Don't allow clients to update DNS, make the server do it
# based on the hostname passed by the DHCP client:
deny client-updates;
allow unknown-clients;
#
# 10.0.0.0/255.255.255.0 Scope Settings
#
subnet 10.0.0.0 netmask 255.255.255.0 {
# Range of DHCP assigned addresses for this scope
range 10.0.0.100 10.0.0.200;
# 1 day
default-lease-time 86400;
# 2 days
max-lease-time 172800;
# Configure the client's default Gateway:
option subnet-mask 255.255.255.0;
option broadcast-address 10.0.0.255;
option routers 10.0.0.2;
# Configure the client's DNS settings:
option domain-name "domain.lan";
option domain-name-servers 10.0.0.1;
}
Now things get a little tricky. If you have Windows clients you are going to need to modify the /etc/rc.d/init.d/dhcpd file. In the start() directive you should see a line that looks something like
daemon /usr/sbin/dhcpd ${DHCPDARGS}
Comment that out with a # and add in the following lines. If you want, add in the DHCPDARGS also, but I don't really use it.
/sbin/route add -host 255.255.255.255 dev eth0 2> /dev/null
daemon /usr/sbin/dhcpd eth0
Make sure you set the ethx to the network interface you want to serve dhcpd requests on. This is particularly vital if you have a multihomed server.
Setting up the Client
The client needs to send a hostname for this to work correctly. The DHCP server needs to know what hostname to set in DNS. Windows does it by default, however you'll need to make sure your /etc/sysconfig/network-scripts/ifcfg-ethx file looks something like this (with the DHCP_HOSTNAME directive set properly.
# make sure this line is has no settings on it!
DEVICE=eth0
BOOTPROTO=dhcp
HWADDR=01:01:01:01:01:01
ONBOOT=yes
TYPE=Ethernet
DHCP_HOSTNAME=host
USERCTL=no
PEERDNS=yes