Check System Compatibility
Type:
ifconfig -a
you should see something like:
eth0 Link encap:Ethernet HWaddr 00:09:5B:04:5E:78
inet addr:82.36.57.31 Bcast:255.255.255.255 Mask:255.255.248.0
inet6 addr: fe80::209:5bff:fe04:5e78/64 Scope:Link
UP BROADCAST NOTRAILERS RUNNING MULTICAST MTU:1500 Metric:1
RX packets:5561334 errors:0 dropped:0 overruns:0 frame:0
TX packets:214278 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:462931787 (441.4 Mb) TX bytes:28300458 (26.9 Mb)
Interrupt:12 Base address:0xa000
If it doesnt say MULTICAST you should reconfigure your kernal and add multicast support.
Currently the latest version is 2.0 (suggested for most users) but 3.0 is in beta testing. You can get them from ftp://ftp.isc.org/isc/dhcp/
After you download unpack it, then cd into the distribution directory:
./configure
make
make install
Server Configuration:
Next step is to add route for 255.255.255.255. Quoted from DHCPd README:
“In order for dhcpd to work correctly with picky DHCP clients (e.g., Windows 95), it must be able to send packets with an IP destination address of 255.255.255.255. Unfortunately, Linux insists on changing 255.255.255.255 into the local subnet broadcast address (here, that’s 192.5.5.223). This results in a DHCP protocol violation, and while many DHCP clients don’t notice the problem, some (e.g., all Microsoft DHCP clients) do. Clients that have this problem will appear not to see DHCPOFFER messages from the server.”
Type: route add -host 255.255.255.255 dev eth0
(or eth1 depending on the interface you are configuring)
DHCPd.conf Configuration
create or edit /etc/dhcpd.conf
The following is a sample which randomly assigns IP addresses.
#sample /etc/dhcpd.conf
ddns-update-style ad-hoc;
option subnet-mask 255.255.255.000;
option routers 192.168.60.1;
option domain-name-servers 62.31.144.39, 195.188.53.175, 195.188.53.175;
default-lease-time 3600;
max-lease-time 7200;
subnet 192.168.60.0 netmask 255.255.255.000
{ range 192.168.60.2 192.168.60.244;
}
This will give a client an IP address in the range 192.168.60.2-192.168.60.244. It will lease an IP address for 3600 seconds if the client doesn’t ask for specific time frame. Otherwise the maximum (allowed) lease will be 7200 seconds. It sets the default DNS servers as 62.31.144.39, 195.188.53.175 and 195.188.53.175.
You can also assign specific IP addresses based on clients ethernet address e.g.
host myPC {
hardware ethernet 00:25:83:17:a3:6e;
fixed-address 192.168.60.246;
}
This will assign IP address 192.168.60.246 to a client with ethernet address 00:25:83:17:a3:6e
You can mix and match, giving certain clients “static” IP addresses such as servers and others being given dynamic IPs such as mobile users with laptops.
Starting the server
Generally DHCP installation doesn’t create a dhcpd.leases files, this file is needed by DHCPd to store information about current leases. To create dhcpd.leases type:
touch /var/state/dhcp/dhcpd.leases
If you get a message saying that file exists simply ignore it and carry on.
You can now invoke the DHCP server. Simply type (or include in the bootup scripts)
/usr/sbin/dhcpd
This will start dhcpd on eth0 device. To start it on another device just supply the device on the command line i.e.
/usr/sbin/dhcpd eth1
If you want dhcpd to start at boot-up include dhcpd in e.g.
/etc/rc.d/rc.local