A quick and rewarding setup

Oct 12, 2006 06:16 GMT  ·  By

In my opinion, in every network, there should be a DHCP server. For me, a network without a DHCP server is like a city without an administrative apparatus. DHCP stands for Dynamic Host Configuration Protocol and it's very useful because it provides the TCP/IP configuration parameters to the computers connected in a network. Since you are probably a networking person, you noticed that not anyone knows what an IP address is and how to configure it and if you manage a network, it can be sometimes exhausting / boring, but with a little help from DHCP most of the problems can be solved making you and the users happier.

Basically, DHCP can be set to deliver to a client the subnet mask, the IP address, the DNS and basically anything your client needs on that particular network. There are actually many advantages and in the simplest configuration possible, in only a couple of minutes, you can tell DHCP to assign IP addresses to an incredible number of hosts. This would make very effective use of scarce IP addresses.

I will assume that you'll get DHCP installed by yourself because this shouldn't be a problem. Now, you should know that the server is run with the command dhcpd that should be started by a script in your distribution and you can also see around the binary dhcpcd, which is the client daemon. The first one assigns network settings and the second one should be used on Linux client machines to communicate with the server.

The configuration file for the server is /etc/dhcpd.conf.

In the first part of the file, we have to define some global values that apply to all systems. max−lease−time specifies the longest time DHCP is allowed to grant an address to a client. The time is in secconds and in this example, we have a week. The default−lease−time specifies for how long an IP address is assigned to a computer when it doesn't request for a specific length. The following three options are pretty self explanatory and I don't think you'll have any trouble understanding them.

In the second part of our example, we define dynamic addressing of IP addresses to a subnet. As you can see, first of all, we have to define the network and then we can add our various options. Here, we can overwrite our default option we set earlier and we can also set new options. The last two statements define two ranges of IP addresses. Assigning a range is the simplest configuration possible and will make the best use of the available IP addresses. The addresses will be dynamically assigned starting from the first one in the range.

The third part of our configuration shows how you can assign static IP addresses only to the hosts you want. For two of the computers that perform functions like a file server, mail server or whatever you like, you can assign fixed IP addresses. The DHCP server checks the MAC address of the NIC installed on that computer and on that criterion, assigns the IP and other options that you want. Some administrators who want to have more control and a better management over the network, add host statements for every PC in the network. In very large networks where computers come and go all the time, it isn't practical to always add your new PCs and remove the old ones but in many cases it is very useful if you wish to know which IP address is assigned to each user.

Don't imagine for a minute that DHCP provides some sort of security. If a user decides at some point that he doesn't want the settings provided by the server, he can set the network manually at any time. For securing your network, other actions should be considered.

If at some point you feel that dhcpd doesn't perform correctly, I advise you to start the server with the debug parameter. Then you'll be able to see if everything goes well or if it hangs at some point.

DHCP provides over 60 options that can be assigned to a TCP/IP network but some of the clients don't know how to interpret all the options and you could end up stressing yourself why doesn't everything goes smoothly. Writing everything about DHCP would take a lot more than the average person can read without getting very bored and if you want to find out more about it you should read the official documentation. This document only wants to give you a first glimpse over this type of server that should now be usable at about 90% of its usability.

One of the coolest things I used DHCP for is to setup a PXE server. This means that with a DHCP server set properly and a TFTP server, I can allow computers to boot one or several Linux operating systems directly from the network or I can install them over the network.

Photo Gallery (2 Images)

Open gallery