Lampros - Weird Bricks

DHCP Server on FreeBSD 9.2

14 January, 2014 | DHCP

I've been meaning to set up a DHCP server on FreeBSD for a while, so these are my notes for a simple configuration. This is based on the following:

On a new FreeBSD 9.2 installation, make sure you have the ports installed. Install the following packages as dependencies, to make things go a little faster:

pkg_add -r gettext gmake

Then via the ports install the isc-dhcp42-server port:

Note: Make sure to untick all the ldap stuff, we're not going to need it:

cd /usr/ports/net/isc-dhcp42-server
make config-recursive

Now begin the installation:

make install clean

Before we continue you'll probably want to change the IP address of your DHCP server machine to static. Edit the file /etc/rc.conf - you'll probably have a line like this:


Change it to static by replacing it with:

ifconfig_em0="inet netmask"

While in the same file make sure you manually add your gateway, in my case it's my internet router which is at


Also add the following lines so the DHCP server starts on boot:


The FreeBSD Handbook on DHCP says the following with regards to the configuration file:

Copy /usr/local/etc/dhcpd.conf.example to /usr/local/etc/dhcpd.conf and make any edits to this new file.

However I found that the file /usr/local/etc/dhcpd.conf was already there, so I just went ahead and edited it (the /usr/local/etc/dhcpd.conf.example was there as well) - this is what I ended up with:

option domain-name "";
option domain-name-servers;

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

ddns-update-style none;

subnet netmask {
  option routers;

host perkelen {
  hardware ethernet 08:00:27:ea:75:34;
  option host-name "";

For an explanation of the above you can't beat the handbook, I just want to add a quick note that if you want to specify a hostname for a host, you can do it with the following:

option host-name "";

Note: On the target client make sure that you haven't already set a hostname in /etc/rc.conf ! In my case I had:


and I simply commented it out so it looks like:


Once you have the above in place, reboot the server so that the static IP address change and the DHCP server turns on. If you need to simply restart the DHCP server, make sure to stop it first and then start it back up like this:

service isc-dhcpd stop && service isc-dhcpd start

With the above configuration all logs will go under /var/log/messages On the client side, if you need to get a new DHCP address for testing use the following:

service netif restart; dhclient em0

On the client you can check a few things: Check that you got the hostname you want with: hostname Note: If you've changed the hostname on the DHCP server, request a new DHCP IP but you still don't get the new hostname, try restarting the client - I didn't get any problems with the IP,Gateway and DNS entries - as long as the DHCP client was re-run they were changed Check that you got the IP you want with:

ifconfig em0 | grep inet

Check that your gateway is correct with:

netstat -rn | grep default

Check that you're getting the correct DNS Server with:

cat /etc/resolv.conf