Making DHCP IP assignments easier Part 2

In a previous article we learned how to set up a DNS/DHCP server for our home network using dnsmasq and a Raspberry Pi. This works well but it is a hassle to add a new device or allow a friend on to our network. In the first part of this series, I introduced SID, an open source web API that can manage the DNS configuration for dnsmasq. This article introduces SIDMobile, a free Android app that uses SID to make adding new devices to our network painless.

For installation and usage, you may follow along with this article and/or watch the video below.

Overview

There are three pieces to the whole system. dnsmasq is managing the network, handing out reserved IP addresses based on a device's MAC address. The Simple IP Dispenser (SID) is running as a web service and monitors DNS requests for addresses. SidMobile polls SID to get a list of MAC addresses that have no IP addresses. You decide which devices you want on the network and use SidMobile to either accept or reject an address. If you accept it, SidMobile tells SID who, in turn, adds the address to the dnsmasq config file and restarts dnsmasq. At that point the new device should get an IP address the next time it requests one.

SID installation

The easiest way to install SID is to download the release debian straight on to your Raspberry Pi and install from there. This must be on the same Pi that is running dnsmasq. So ssh to your Pi and do the following

wget https://github.com/carpie/sid/releases/download/v1.0.0/sid_1.0.0_all.deb
sudo dpkg -i sid_1.0.0_all.deb

The SID debian will install itself to /opt/sid.

SID configuration

If you used the default values in my DNS setup article, SID is already configured. If not, you will want to edit /opt/sid/src/.env and make changes for your network. The only items you may need to change are:

# This is the dnsmasq configuration file to modify with new addresses
DNSMASQ_CONF_FILE='/etc/dnsmasq.d/home.dns'

# This is the base network address of the network to modify
NETWORK_ADDR=192.168.0.0

# This is the network mask of the network to modify
NETWORK_MASK=255.255.255.0

You may edit the file directly, or you can make the modifications using debian's configuration system by running:

sudo dpkg-reconfigure sid

After any changes, restart SID using:

sudo service sid restart

SidMobile installation

SidMobile is currently only available for Android, so go to the play store on your device and search for "SidMobile". Once you've found it, click "INSTALL". Once installed, click "OPEN".

SidMobile configuration

SidMobile needs to know where to contact the SID service. So, you need to do a one-time setup step. Click the gear icon in the top right. Enter the IP address of your Pi. If you are using my setup, that's 192.168.0.2. Finally, click "SAVE".

At this point SidMobile should contact SID and you will see a "No Requests" screen if there are no unknown devices requesting IPs. If there are, you will see a list of MAC addresses for those devices.

Adding a device to the network

With SID and SidMobile set up, have a device try to join your network. You should see the device's MAC address pop up on the SidMobile screen. Simply click the MAC address, optionally give the device a name, and click "ASSIGN". That's it! The device will get an address the next time it makes a request on the network. If you do not give the device a name, SidMobile will name the device as guest with a trailing number such as guest1, then guest2, and so on.

Troubleshooting

If you are trying to add a device to your network and it is not showing up in the SidMobile list, here are some things to check:

  • If connecting via wifi, make sure the wifi settings and password of the device are correct. If it can't connect to wifi, the request will never make it to dnsmasq.
  • If it has been some time since the device first requested the address and you assigned it one via SidMobile, the device may have stopped requesting. Turn the device's wifi off and back on, or reboot it to make it request again.
  • If all else fails, check /var/log/syslog on your Pi for DHCP entries for clues as to what might be wrong.

A note about security

Once you allow someone on to your network, she could conceivably download SidMobile herself and allow others on to your network! I assume you trust who you are letting on to your network, but I wanted to point this out explicitly in case it was something you didn't think about.

Summary

We have added some convenience to our dnsmasq-managed network. We now have a way to dynamically assign static IPs to our network devices and a very easy means of getting new devices on our network!