As part of a broader organisational restructure, data networking research at Swinburne University of Technology has moved from the Centre for Advanced Internet Architecture (CAIA) to the Internet For Things (I4T) Research Lab.

Although CAIA no longer exists, this website reflects CAIA's activities and outputs between March 2002 and February 2017, and is being maintained as a service to the broader data networking research community.


Simple Local DHCP Service under FreeBSD

CAIA Technical Report 031215A


Grenville Armitage
December 15th, 2003

Introduction

This report summarizes the tools we used to enable a locally controlled DHCP service for temporary hosts inside Swinburne's Centre for Advanced Internet Architectures (CAIA). This report is primarily for internal archival purposes.

Initially the CAIA network used statically assigned IP addresses on our LAN segment. As the number of independent and/or temporary boxes flourished we've installed a dhcp server service to automagically hand-out temporary IP addresses from a small pool. The setup is relatively painless and simple, using software from the Internet Software Consortium (ISC) that is conveniently available as a pre-compiled binary "package" for the FreeBSD environment we use here at CAIA.

Problem statement

In a nutshell here's the problem we're solving:
  1. We have a growing collection of dual-booting FreeBSD/Windows machines on desktops, for which we'd been assigning static, routable IP addresses from a /24 given to us by the University's ITS group
  2. We have a growing number of projects that need to create and tear down temporary hosts
  3. Co-ordinating temporary IP address assignment was becoming a pain
  4. We have a UPS-powered FreeBSD 4.x machine (mordor) already doing service as our central, backed-up file server (running SAMBA for access from desktops running Windows)
Points 1, 2 and 3 define the core technical problem. The solution revolves around point 4.

Installing DHCP Servers under FreeBSD

FreeBSD only includes a DHCP client by default (/sbin/dhclient), but it is quite simple to install a third-party DHCP server. We chose to install ISC's reference implementation of DHCP client and server software - available as a pre-compiled FreeBSD 'package' known as "isc-dhcp3". At the time of writing this report the FreeBSD package was ISC's version 3.0.1.r12.

Our server mordor is well connected to the Internet, so the simplest approach to installing isc-dhcp3 is one command (run as root):

pkg_add -r isc-dhcp3

The "pkg_add -r" automagically retrieves and installs the latest binary package over the Internet from freebsd.org.

(Confirm that the package is installed using "pkg_info -x isc-dhcp3", or get a detailed listing of the files installed as part of the isc-dhcp3 package with "pkg_info -xLd isc-dhcp3")

Initialising the ISC DHCP Server

After the package is installed, there are two key steps to starting a minimal DHCP Server service:

  1. Create /usr/local/etc/rc.d/isc-dhcpd.sh so that the server re-starts each time mordor is rebooted
  2. Create a configuration file /usr/local/etc/dhcpd.conf
The package installs two example files - /usr/local/etc/rc.d/isc-dhcpd.sh.sample and /usr/local/etc/dhcpd.conf.sample.

Copy
/usr/local/etc/rc.d/isc-dhcpd.sh.sample to /usr/local/etc/rc.d/isc-dhcpd.sh - this script looks after starting or stopping the dhcp server whenever FreeBSD starts up or shuts down.

The configuration file (
/usr/local/etc/dhcpd.conf) is best understood by reading the newly installed manual page ("man dhcpd.conf") but you can see our minimal installation below:

#
# dhcpd.conf file for CAIA
#
# 136.186.229.240-253 is DHCP pool, all others are static
#

option domain-name "caia.swin.edu.au";
option domain-name-servers 136.186.20.9, 136.186.1.111, 136.186.1.115;
default-lease-time 600;
max-lease-time 7200;
authoritative;
ddns-update-style none;
log-facility local7;

# Basic subnet declaration creating a small address pool
# usable by unkown hosts - adresses in range 136.186.229.240-253

subnet 136.186.229.0 netmask 255.255.255.0 {
  range 136.186.229.240 136.186.229.253;
  option routers 136.186.229.1;
}

# Fixed IP addresses can also be specified for hosts identified
# by MAC address.

host www.caia {
  hardware ethernet 00:03:47:07:00:6a;
  fixed-address 136.186.229.16;
}
#

Start the dhcp server (a daemon) by running:

/usr/local/etc/rc.d/isc-dhcpd.sh start

This should result in the dhcpd process starting up, reading the config file, and noting any problems to the console and /var/log/messages. The process automatically detaches from the console.

From this point onwards, any dhcp client starting on the 136.186.229/24 network will be assigned an address from the small pool from 136.186.229.240 to 136.186.229.253. The client will also be configured with the caia domain (caia.swin.edu.au) and the IP addresses of the Swinburne University DNS servers. Our dhcp server is also configured to act as "authoritative" for 136.186.229/24 (because we've asked our ITS department to NOT provide their own DHCP service for the entire 136.186.229/24 subnet).

Machines that we wish to have statically assigned address can also be listed in the config file (e.g. the config file shown above provides a fixed 136.186.229.16 address for the machine with MAC address
00:03:47:07:00:6a if it were, for some reason, to use dhcp when rebooting).

And that's basically it for a simple DHCP service that hands out a from a small pool of IP addresses! The isc-dhcp3 server has tons more options for conditionally assigning addresses to known and unkown hosts, shared subnets, dynamic DNS updates, etc... check the manual pages for dhcpd.conf and dhcpd.


Last Updated: Monday 15-Dec-2003 13:08:00 AEDT | Maintained by: Grenville Armitage (garmitage@swin.edu.au) | Authorised by: Grenville Armitage (garmitage@swin.edu.au)