11. DHCP server

Configuring the DHCP server

Having a dhcp server is once again not The Only Way. We could easily setup the local network with only devices with static IP addresses. This, however, would have the disadvantage that you will need to add some information into the configuration files of the Knoppix server, like the name of the client and the IP address for instance, for every computer on your local subnet. Using a DHCP server is an easy way for the server to know about all the clients it is providing services for without to much effort: they have all requested an IP address and have to do so, so the server knows about them.

The dhcp server comes preinstalled with your Knoppix distribution, it just needs configuration. Unfortunately, webmin is not totally compatible with the dhcp server, as it still expects an older version of the dhcp server. Therefore we would do better tweaking the configuration file by hand. It is located at /etc/dhcp3/dhcpd.conf and it should look like this:

Code listing 11.1: dhcpd.conf file

Change the 192.168.1.* setting to your local configuration.
ddns-update-style none;
option domain-name "pandora.be";
option domain-name-servers 192.168.1.1;

default-lease-time 3600;
max-lease-time 7200;

subnet 192.168.1.0 netmask 255.255.255.0 {
        range 192.168.1.5 192.168.1.20;
        option routers 192.168.1.1;
}

log-facility local7;

This is the configuration file assuming your host is at IP address 192.168.1.1, and with a range for 5 client IP addresses. Most options should be equal to the default and pretty self explanatory. Every client will get the lease saying that the name server is the Knoppix box.

The ddns-update-style should be set to none because we do not use a dns server that supports this anyway. Dnsmasq has it's own way of finding out what IP addresses are on your local network by interpreting the leases file. We do, however still need to update the /etc/dnsmasq.conf file, because it expects a different place for the leases file than the one dhcpd3 uses. So, you need to change the line in /etc/dnsmasq.conf from dhcp-leasefile=/var/lib/dhcp/dhcpd.leases to dhcp-leasefile=/var/lib/dhcp3/dhcpd.leases.

The domain-name is not really that important, but I think it makes sence to just use the ISP's domain name, in my case pandora.be. I have made the lease times a bit higher than they are by default, because I thought that requesting a new dhcp every other minute or so was useless and only polluted the log files with loads of useless information.

The domain-name-servers directive tells the clients that they should use this server as a Nameserver. This is because we set up the DNSMasq program in the previous section.

The subnet section basically tells about the network our box is routing for, and the range of dhcp addresses to hand out. The option routers makes sure that every dhcp client uses the router as a gateway. In normal language: whenever a clients does not know where to send it's IP traffic too, it sends it to the gateway, the knoppixbox, which does know where to send the traffic to.

Make sure to change /etc/defaults/dhcp3-server so that it says INTERFACES="eth1", which makes sure the dhcpd server only listens on the intranet interface. And also issue the following command: update-rc.d dhcp3-server defaults, which adds the dhcp server to the bootup sequence, and makes sure we get the dhcp server running again after a reboot.

To make sure we get the dhcp server running at start up we need to issue another command: update-rc.d dhcp3-server defaults.

To make sure the dhcp server only listens on one interface, adapt /etc/default/dhcp3-server to have INTERFACES="eth1".

Surfing from the clients

Here we are! You're firewall is set (remember we checked the DHCP setting for both interfaces?), and your dhcp server is running. You can try surfing from a client computer by requesting a new IP address from the server. The configuration of the clients is different for different Operating Systems, but it should not be too hard to do.

line
Updated $LastChangedDate: 2004-11-05 23:24:59 +0100 (Fri, 05 Nov 2004) $
line
Kristof Van Landschoot
Author

line
Summary: Installing a DHCP server is the easiest way to configure the the local network.
line
Copyright 2003-2004 Coin-C bvba. Questions, Comments, Corrections? Email knoppix@coin-c.com.