DHCP Explained: Installing & Configuring A Free DHCP Server [Linux]

Varun Kashyap 11-02-2010

dhcp domain server internetDHCP is Dynamic Host Configuration Protocol. On a network configured with DHCP, the computers ask for an IP address and the DHCP server responds with a unique IP address and other required information like domain name servers and router addresses. DHCP thus saves the administrator a lot of work and is specially useful in larger networks.


However there is nothing stopping you using such a free DHCP server setup on your home network as well. Another advantage is that all the settings are stored in one place so any changes can be done easily without having to reconfigure all of your computers.

Installing free DHCP server is easy, it is the configuration that takes some time and thought. That said, once you have installed and configured a DHCP server you are saved from all the chores like rotating IP addresses, keeping track of what IPs have been assigned and configuring each computer/device separately etc.

We will be looking at how you can configure a free DHCP server on your Linux computer. As always I will be demonstrating this using my Ubuntu Machine, but you can very well adapt it to be used with any other distribution. First and foremost you need to install a DHCP server on your computer. Doing so is simple, all you need to do is to issue the following command:

sudo apt-get install dhcp3-server

Alternatively you can also achieve this via the synaptic package manager. Keep in mind that you might have to enable the universe and mulitverse repositories. (To do so, check the appropriate checkbox inside System > Administration > Software Sources).


free DHCP server

Once installed you need to get configuring. Configuring the DHCP server requires editing configuration files and having a decent knowledge of networking won’t hurt either. That said, I will try to walk you through the configuration file and what all you need to change for a basic setup, so follow along:

  • There are a couple of files we are concerned with. Most of the work will be done with /etc/dhcp3/dhcpd.conf. However first we need to configure which interface the server should monitor for DHCP requests. Open up the file /etc/defaults/dhcp3-server and add the required interface to the INTERFACES=”” line. e.g for eth0, the line will look like INTERFACES=”eth0″.
  • free DHCP server

  • Now back up /etc/dhcp3/dhcpd.conf (create a copy) just in case things go wrong.
  • Next up, open the file in your favorite text editor. You may require elevated privileges to edit the file so don’t forget to use sudo (or gksudo if using a GUI text editor).
  • This is how the file looks like at first:
  • free DHCP server

  • We will change a couple of lines. The settings I am about to show you are good enough for a home network. The great thing about DHCP is that it scales very well, so if you are using this to manage a larger network you would need to make some edits to the setup that I am presenting. The file is nicely commented so if you are unsure about what an option does, make sure you read the comment above the line that you are going to edit.
  • Go through the file line by line and comment out any line that is not required in your setup. In the first part of the file you can specify domain name, domain name servers and parameters like default and max lease time. The settings you configure in this part of the file will be used for all the sections of the file that don’t mention them explicitly.
  • If instead you are configuring only a single network interface, I recommend you comment out these first lines and configure the domain name and domain name servers in the individual sections.
  • Now search the file and look for a line that reads “A slightly different configuration for an internal subnet“. This is where you specify the settings of your internal subnet. While the file lists only one such section, you can create more if you want to create more than one subnet.
  • dhcp domain server internet

  • Uncomment the section once you find it. You now need to change the settings to suit the network that you are configuring. Here is a brief description of what each line does:
  • subnet netmask – Specifies the subnet all the hosts will belong to. eg if you want to assign IP addresses from the subnet with a mask of you will change the line to subnet netmask

    range specifies a range of IP addresses within the subnet that will be assigned to any machine requesting an address. In our case we can change it to a suitable range

    The other lines are used to configure optional parameters like router address, DNS servers etc. You can specify them here to override the default ones you provided at the start of the file.

    dhcp domain server internet

With a little configuration, the DHCP server is ready for work. All you need to do now is to start the server and configure the clients to request IP via DHCP from this server that you configured. As an option you can also use Webmin to configure your DHCP server using a web browser. If you have a router, it can do most things that you want to do with a DHCP server, in such a case you can access the router’s settings panel to specify things like how IP addresses are assigned, DNS servers and the likes.

Have you ever configured a DHCP server for your home network? Or do you use static IPs? Feel free to contribute your tips in the comments section.


Related topics: Computer Networks, IP Address, Web Server.

Affiliate Disclosure: By buying the products we recommend, you help keep the site alive. Read more.

Whatsapp Pinterest

Leave a Reply

Your email address will not be published. Required fields are marked *

  1. Nick
    February 11, 2010 at 2:18 pm

    This is a great how to for someone that wants to make a custom DHCP server for some reason. Though mostly all consumer routers have DHCP, but of course this guide is for the geeks that want to make their own DHCP server. I know that the High School that I went to used a dedicated DHCP server.

    However, I have a Cisco 2811 router that I am going to be using to run my home network. hehe.

    Great Post!

  2. Simon
    February 11, 2010 at 11:19 am

    Don't all home "routers" come with a DHCP server embedded these days?

    They have a GUI also, most of the time. I love Linux and all, but isn't it simpler to just use what you already have on hand? Someone who needs DHCP has more than one machine, and must have a common device to share the internet connection...

    Sure, you can have far more control over the settings provided by your own DHCP server, but what's the point if you have less than 10 machines?

    I personnally use my DD-WRT router to give ip adresses dynamically to the wireless devices, as the three wired computers have static adresses, since they're, well, static.