Setting Up a DHCP Server on Ubuntu

Updated on June 9, 2015
Setting Up a DHCP Server on Ubuntu header image

DHCP can be used to dynamically provide local IP addresses to client computers. This prevents you from having to setup static IP addresses for every computer on your network. DHCP is very useful for busy environments such as schools and businesses.

Setting up a DHCP server on Ubuntu is not very difficult. Simply follow the steps in this tutorial and you will have a DHCP server running.

Step 1: Installing the DHCP server

First off, install the server.

apt-get install isc-dhcp-server

Step 2: Setting the network interface

We will need to determine the network interface that we want to lease addresses on. To do this, replace eth0 with the sufficient network interface.

vi /etc/default/isc-dhcp-server

Step 3: Configuring the DHCP server

Next, configure the DHCP server.

vi /etc/dhcp/dhcpd.conf

You will see the following sample configuration. Review the configuration options and set them to your liking. Take into account that the option domain-name is the name of your DNS zone.

#
#Sample configuration file for ISC dhcpd for Debian
#
#Attention: If /etc/ltsp/dhcpd.conf exists, that will be used as
#configuration file instead of this file.
#
#
....
option domain-name example.org;
option domain-name-servers ns1.example.org, ns2.example.org;
option domain-name example.com;
default-lease-time 600;
max-lease-time 7200;
log-facility local7;
subnet 10.0.0.0 netmask 255.255.255.0 {
range 10.0.0.150 10.0.0.253;
option routers 10.0.0.2;
option subnet-mask 255.255.255.0;
option broadcast-address 10.0.0.254;
option domain-name-servers 10.0.0.1, 10.0.0.2;
option ntp-servers 10.0.0.1;
option netbios-name-servers 10.0.0.1;
option netbios-node-type 8;
 ......
}

Step 4: Starting the DHCP server

Finally, restart the DHCP server.

service isc-dhcp-server restart

The setup is complete. You can now use your DHCP server to assign IP addresses.