Configure DHCP for a Private LAN

Now that you have the scouting app working on a Raspberry Pi, it is almost ready to be used at a competition. The last step is to configure the Raspberry Pi as a DHCP server.

DHCP stands for Dynamic Host Configuration Protocol. This is the service that gives out IP addresses to any device that askes for one.

Laptops, phones, desktops, smart TVs, Alexa, and many other devices that connect to the internet are typically configured to request an IP address whenever they are cabled to a network or come in range of wireless access point. A DHCP service is what responds to that request. The wireless router in your school, coffee shop, and even in your home is running a DHCP service.

A DHCP service is configured with a list or pool of IP addresses which it can give out. Any device can get any IP address. When you are a DHCP client, like a laptop or phone in your home, it doesn't matter which IP address you get. The only entities that need to know your IP address are the ones that you reach out to first, like a network or a website. However, if you are a device that needs to be reached, like a printer or a web server, then you don't want your IP address subject to changing, otherwise your client devices won't know how to reach you.


When we configured a static IP address on the Raspberry Pi, we disabled the default behavior of making a DHCP request for an IP address. Now the Raspberry Pi boots up with a known, statically configured IP address, so we can reach it at that IP address whenever we want.


Here we will install and configure a DHCP service so that it is ready to go when we need it.


Step 1. Install the DHCP service


The DHCP service on Ubuntu is called isc-dhcp-server. Before we install it, we should make sure that all of our existing software is up-to-date. Do this by running the following commands and respond appropriately to the prompts:

ubuntu@ubuntu:~$ sudo apt update

ubuntu@ubuntu:~$ sudo apt upgrade


Now we can install the DHCP service:

ubuntu@ubuntu:~$ sudo apt install isc-dhcp-server


Step 2. Configure the Pool of IP Addresses

To configure the DHCP service, we will be editing the /etc/dhcp/dhcpd.conf file. By default this file contains a lot of comments and examples on how to configure the DHCP service. We just need a simple configuration, so let's rename this file:

ubuntu@ubuntu:~$ cd /etc/dhcp

ubuntu@ubuntu:/etc/dhcp$ sudo mv dhcpd.conf dhcpd.conf-orig


Here is the basic config that we will use. The explanation of the settings is below, so you can adjust these settings as needed for your setup:

ubuntu@ubuntu:/etc/dhcp$ sudo emacs -nw dhcpd.conf

ubuntu@ubuntu:/etc/dhcp$ cat dhcpd.conf


# scouting DHCP



default-lease-time 7200;

max-lease-time 7200;


ddns-update-style none;


subnet netmask {


        option routers;




The default-lease-time setting and the max-lease-time setting control how long a requested IP address is assigned to a specific device before it expires and the device has to request another one. You shouldn't need to change these settings.

The ddns-update-style setting should be set to none since we are not interfacing with a DNS server.

The subnet defines the local network. The netmask controls the size of the local network. An IP address consists of 4 octets from 0 to 255. A subnet of and a netmask of means that the network contains all IP addresses from to This is the same subnet as the one managed by my home router.

The range setting defines the pool of IP addresses that will be given out by the DHCP service. Since my router is configured with a range of to, this range won't overlap. But I won't start the service and let it run while on my home network.

The option routers just tells the DHCP clients that the Raspberry Pi is the gateway server for this local network.

Step 3. DHCP service management

You can start and stop a service in Linux. You can also enable and disable a service. When you enable a service, that means that it will start automatically on the next bootup. A disabled service will not bootup automatically.

Before going to a competition, you want to enable the DHCP service like this, so that it will start up on bootup and serve IP addresses to the tablets:

ubuntu@ubuntu:/etc/dhcp$ sudo systemctl enable isc-dhcp-server.service

Synchronizing state of isc-dhcp-server.service with SysV service script with /lib/systemd/systemd-sysv-install.

Executing: /lib/systemd/systemd-sysv-install enable isc-dhcp-server



After a competition, if you plan to connect it back to your home network then you will want to stop the service because it will have started automatically on bootup:

ubuntu@ubuntu:/etc/dhcp$ sudo systemctl stop isc-dhcp-server.service



Then, to prevent the DHCP service from starting again on bootup, disable the service:

ubuntu@ubuntu:/etc/dhcp$ sudo systemctl disable isc-dhcp-server.service

Synchronizing state of isc-dhcp-server.service with SysV service script with /lib/systemd/systemd-sysv-install.

Executing: /lib/systemd/systemd-sysv-install disable isc-dhcp-server

Removed /etc/systemd/system/