OpenBSD DHCP Server

Configuration is very simple, direct and intuitive. It would be easy to duplicate this setup quickly.

Configuration

Setup the main Ethernet device to reserve the first available IP address:

/etc/hostname.re0

inet 192.168.0.2 255.255.255.0

Setup the name server resolution manually:

/etc/resolv.conf

search beandog.org
nameserver 192.168.0.2
nameserver 205.171.3.25
nameserver 205.171.2.25

Setup the server's gateway:

/etc/mygate

192.168.0.1

The localhost name:

/etc/myname

d64.beandog.org

Configure the daemons to start up on boot:

/etc/rc.conf.local

dhcpd_flags=re0
pkg_scripts="dnsmasq dbus_daemon avahi_daemon"
dnsmasq_flags=
dbus_daemon_flags=
avahi_daemon_flags=

Here's a very basic dhcpd configuration:

/etc/dhcpd.conf

option domain-name "beandog.org";
option domain-name-servers 192.168.0.2;
subnet 192.168.0.0 netmask 255.255.255.0 {
  option routers 192.168.0.1;
  range 192.168.0.3 192.168.0.254;
}

Router

Setting up the OpenBSD server as a router only adds a few more changes. First of which, is to use a second NIC, and run the DHCP and DNS servers there.

Turn on network IP forwarding in /etc/sysctl.conf:

net.inet.ip.forwarding=1

Setup packet filtering in /etc/pf.conf:

pass out on re0 from em0:network to any nat-to (re0)

Set the second NIC's IP address manually:

inet 192.168.12.1 255.255.255.0

Extras

To preserve sanity, disable the PC speaker:

/etc/wsconsctl.conf

keyboard.bell.volume=0