Retrieve DHCPD (if your machine does not already have it installed). Get DHCPD
Quick Note: MAKE SURE YOU HAVE MULTICAST ENABLED IN THE KERNEL.
If there is not a binary distribution for your version of linux, then you will have to compile DHCPD.
Edit your /etc/rc.d/rc.local to reflect an addition of a 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 (in this case, the address would be 192.5.5.223). This results in a DHCP protocol violation. While many DHCP clients don't notice the problem, some (e.g., all Microsoft DHCP clients) will recognize the violation. Clients that have this problem will appear not to see DHCPOFFER messages from the server.
Type the following as root:
route add -host 255.255.255.255 dev eth0
If the message appears:
255.255.255.255: Unknown host
Try adding the following entry to your /etc/hosts file:
255.255.255.255 dhcp
Then, try:
route add -host dhcp dev eth0
Now you need to configure DHCPd. In order to do this, you will have to create or edit /etc/dhcpd.conf. There is a graphical interface for dhcpd configuration under linuxconf. This makes configuring and managing DHCPD extremely simple.
If you want to configure it by hand, you should follow instructions below. I suggest configuring it by hand at least once. It will help in the diagnostics that a GUI can't provide. Unfortunately Micrsoft doesn't believe this!
The simplest way to assign IP addresses is to assign them randomly. A sample configuration file that shows this type of setup is displayed below:
# Sample /etc/dhcpd.conf # (add your comments here) default-lease-time 1200; max-lease-time 9200; option subnet-mask 255.255.255.0; option broadcast-address 192.168.1.255; option routers 192.168.1.254; option domain-name-servers 192.168.1.1, 192.168.1.2; option domain-name "mydomain.org"; subnet 192.168.1.0 netmask 255.255.255.0 { range 192.168.1.10 192.168.1.100; range 192.168.1.150 192.168.1.200; } |
This will allow the DHCP server to assign the client an IP address from the range 192.168.1.10-192.168.1.100 or 192.168.1.150-192.168.1.200.
If the client doesn't request a longer time frame, then the DHCP server will lease an IP address for 1200 seconds. Otherwise, the maximum (allowed) lease the server will allow is 9200 seconds. The server sends the following parameters to the client:
Use 255.255.255.0 as your subnet mask Use 192.168.1.255 as your broadcast address Use 192.168.1.254 as your default gateway USE 192.168.1.1 and 192.168.1.2 as your DNS servers.
If you specify a WINS server for your Windows clients, you need to include the following option in the dhcpd.conf file:
option netbios-name-servers 192.168.1.1;
You can also assign specific IP addresses based on the clients' ethernet MAC address as follows:
host haagen { hardware ethernet 08:00:2b:4c:59:23; fixed-address 192.168.1.222; } |
This will assign IP address 192.168.1.222 to a client with the ethernet MAC address of 08:00:2b:4c:59:23.
In most cases the DHCP installation doesn't create a "dhcpd.leases" file. Before you start the server, you must create an empty file:
touch /var/state/dhcp/dhcpd.leases
To start the DHCP server, simply type (or include in the bootup scripts):
/usr/sbin/dhcpd
This will start dhcpd on eth0 device. If you need to start it on another device, simply supply it on the command line as shown below:
/usr/sbin/dhcpd eth1
If you wish to test the configuration for any oddities, you can start dhcpd with the debugging mode. Typing the command below will allow you to see exactly what is going on with the server.
/usr/sbin/dhcpd -d -f
Boot up a client.Take a look at the console of the server. You will see a number of debugging messages appear on the screen.
Your done