Adding DHCP to your Ubuntu server

DHCP

I have in the previous articles described how to get the DNS working on your server. To complete the setup, it is useful to add DHCP to the mix so that you can have computers set to automatically receive the correct settings for your network. And the more computers you have on the network, the more useful it is.

After a bit of research, I found a post about this that helped me get things right on the first try. Here is what I did:

First I needed to install the DHCP package:

sudo apt-get update
sudo apt-get install dhcp3-server

After that is well and done, I needed to edit the configuration for it:

sudo nano /etc/dhcp3/dhcpd.conf

Here is what my dhcp.conf file look like now:

# DHCP configuration file for Argoz
#
# Attention: If /etc/ltsp/dhcpd.conf exists, that will be used as
# configuration file instead of this file.
#
# $Id: dhcpd.conf,v 1.1.1.1 2002/05/21 00:07:44 peloy Exp $
#

# The ddns-updates-style parameter controls whether or not the server will
# attempt to do a DNS update when a lease is confirmed. We default to the
# behavior of the version 2 packages ('none', since DHCP v2 didn't
# have support for DDNS.)
ddns-update-style none;

# option definitions common to all supported networks...
option domain-name "lan1.domainname.com";
option domain-name-servers 10.11.12.100, 208.67.222.222, 208.67.220.220;

default-lease-time 600;
max-lease-time 7200;

# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
authoritative;

# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
# log-facility local7;

# The rest of the network info

option subnet-mask 255.255.255.0;
option broadcast-address 10.11.12.255;
option routers 10.11.12.1;

# The subnet

subnet 10.11.12.0 netmask 255.255.255.0 {
range 10.11.12.150 10.11.12.170;
}

I chose to keep the comments in there as I am not working with these things on a daily basis and thought it might be a good thing to have some reminders if I needed to edit it again.

Notice that all lines starting with # is just a comment and will not influence the DHCP server. This is a pretty common way of doing things in Ubuntu.

I chose to set the range for IP addresses from 10.11.12.150 to 10.11.12.170 as this should give me more than enough addresses for the little use I have. Your need might vary here.

After saving the configuration, the only thing left to do is starting the DHCP server:

sudo /etc/init.d/dhcp3-server start

You should now have a reliable DHCP service on your network and if you had one running in a wireless router or ADSL router, you can log on there and turn it off. Have you considered setting up your own server yet?

The photograph of the computer classrom is by Extra Ketchup and has a Creative Commons license.

Related Posts:

About the Author

After living in Norway for over 40 years, I have moved to Brazil. I still sometimes travel to Norway to work, but aim at making those trips shorter and shorter. My worklife has been spent in the professional broadcast area. I have been doing regular production, both recorded and live shows. And I have been working for one of the major suppliers of editing systems, Avid Technology. The last few years I have done a lot of training and teaching. It is a very rewarding kind of work and no two days are the same. I also spend some time hacking together websites and tell people about the benefits of having websites with content management systems - CMS and lately also about the advantages of Linux. My preferred flavour is called Kubuntu.