Shortround.net Articles

Ubuntu DHCP Server

Ubuntu

This article is part of a series on setting up an Ubuntu Network Server. Below are the other sections of the article.


As before, we need to install some software first.

sudo apt-get install dhcp3-server

By default, the package installs a config file that is full of the thousands of options you can give to the DHCP server. We don't really need this, so I first make a backup of the /etc/dhcp3/dhcpd.conf file and then start with a blank file. In that file, put the following:

shared-network LOCAL-NET {
    option domain-name "shortround.net";
    option domain-name-servers 192.168.100.1;
    option netbios-name-servers 192.168.100.1;

    subnet 192.168.100.0 netmask 255.255.255.0 {
        option routers 192.168.100.1;
        range dynamic-bootp 192.168.100.50 192.168.100.100;
    }

    host biggles {
        hardware ethernet 00:1b:63:ef:db:54;
        fixed-address 192.168.100.20;
    }

    host giap {
        hardware ethernet 00:0a:95:b4:d4:b0;
        fixed-address 192.168.100.21;
    }

    host gimli {
        hardware ethernet 00:16:cb:aa:2a:cd;
        fixed-address 192.168.100.22;
    }

    host squirt {
        hardware ethernet 00:0a:95:f5:8f:b3;
        fixed-address 192.168.100.23;
   }
}

Again, you will have to modify the domain names and IP addresses to fit your needs. The important parts are the first two sections. The first block gives our settings for anything that gets an address from our server. The second block sets up a pool of addresses to give out.

The last set of blocks specifies IP addresses for given MAC addresses. I do this so that I never have to mess with network settings on my laptops and other machines. When they are on my network, the DHCP server always gives them the same address. Notice that these addresses line up with the addresses in the DNS server. Doing this gives me the ability to get to any of machines in the network by just remembering their host name.

Before we can start up the server, edit the /etc/defaults/dhcp3-server file. The last line of the file denotes which interfaces to run the server on. By default, the DHCP server will listen on every network card on your computer. I changed the line so that it only runs on my internal interface.

INTERFACES="eth1"

Now we can restart the DHCP service.

sudo invoke-rc.d dhcp3-server restart

This was posted on Wednesday, August 27, 2008 at 10:39. It is filed under Ubuntu.
It is licensed under the Creative Commons Attribution 3.0 Unported License. View the markdown for this article.