Ubuntu 12.04 DHCP Server

Overview

A DHCP server issues computers on the network IP addresses. Normally this is done by the router but a computer is more flexible because:

Install

sudo apt-get install dhcp3-server

Configuration

Configuring a DHCP server is where most of the complexities and bulk of the work lies. First thing to do is set the network interface should us DHCP. Edit /etc/default/isc-dhcp-server and change INTERFACES="" to INTERFACES="eth0" where eth0 is the network interface. Save and exit the file.

The DHCP server configuration file is located at /etc/dhcp/dhcpd.conf. It’s probably best to make a backup of the file first

sudo cp /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.old

Edit the configuration file using the preferred text editor. The remainder of this post will be about configuring the server.

Basic Configuration

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

subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.2 192.168.1.254;
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.1.255;
option routers 192.168.1.1;
option domain-name-servers 208.67.222.222, 208.67.220.220;
}

What they mean:

IP Reservation

IP addresses can be reserved so that computers can be assigned the same IP address all the time (except when there’s already assigned). Add the following lines to the bottom of the config file:
host MyComputer {
hardware ethernet AA:11:BB:22:CC:33;
fixed-address 192.168.1.100;
}

Change the above parts highlighted in bold. MyComputer is the name of the computer, hardware ethernet is the MAC address of the network card and fixed-address is the IP address to be reserved.

Completing Configuration

For the changes to take hold, restart the DHCP server sudo service isc-dhcp-server restart

Summary

Setting up the DHCP server was fairly easy but configuring it is a lot harder than using a web interface like almost all routers nowadays. This setup is a precursor to creating a server to replace a router and will be more instrumental when used with other services such as proxy, DNS, etc

dhcp3-server

About Danny

I.T software professional always studying and applying the knowledge gained and one way of doing this is to blog. Danny also has participates in a part time project called Energy@Home [http://code.google.com/p/energyathome/] for monitoring energy usage on a premise. Dedicated to I.T since studying pure Information Technology since the age of 16, Danny Tsang working in the field that he has aimed for since leaving school. View all posts by Danny → This entry was posted in Linux and tagged , , , , , , . Bookmark the permalink.

Leave a Reply

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

All comments must go through an approval and anti-spam process before appearing on the website. Please be patience and do not re-submit your comment if it does not appear.

This site uses Akismet to reduce spam. Learn how your comment data is processed.