Linux Networking HOWTO - DocBook Rev .02 | ||
---|---|---|
Prev | Chapter 7. IP Related Information | Next |
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 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 (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 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 follow instructions below. I suggest configuring it by hand at least once. It will help in the diagnostics that a GUI can't give you. Unfortunately Micrsoft doesn't believe this.
The easiest thing to do is assign IP addresses randomly. Below is a sample configuration file that shows this type of setup.
# 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.
It will lease an IP address for 1200 seconds if the client doesn't request a longer time frame. Otherwise the maximum (allowed) lease the server will allow is 9200 seconds. The server send the following paramaters 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 clients ethernet MAC address e.g.
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 ethernet MAC address of 08:00:2b:4c:59:23.
In most cases the DHCP installation doesn't create a dhcpd.leases file. Therefore before you start the server you must type to 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 e.g.
/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 come up.
Your done