Running Mac OS X's built-in DHCP server
It turns out that Mac OS X comes with a DHCP server built-in. There don't seem to be any good and simple instructions out there on how to use it. Or at least, there weren't any.... until now!
The server is called bootpd and does both DHCP and BOOTP. These instructions just describe using it for DHCP, however.
To start, you need to create a configuration file for the server. The file should be stored in
/etc/bootpd.plist. Here's a sample configuration file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
This file sets up the DHCP server to run on the interface named
en0, which is typically the (non-wireless) Ethernet port. It assumes that that port has been configured with the IP address
192.168.33.1, and dishes out addresses from
To get more information on editing this file, take a look at the bootpd manfile:
To start the server, run the following command:
sudo /bin/launchctl load -w /System/Library/LaunchDaemons/bootps.plist
Stopping the server is very similar:
sudo /bin/launchctl unload -w /System/Library/LaunchDaemons/bootps.plist
If you want to create static assignments, so that a given device always has the same IP address, you need to create a file called
/etc/bootptab. There's a small sample of the file below. For more information, just do
# machine entries have the following format:
# hostname hwtype hwaddr ipaddr bootfile
client1 1 00:01:02:03:04:05 10.0.0.20
client2 1 00:a0:b2:ef:ff:0a 10.0.0.20
Make sure to include the
%% at the top of the file. It's safe to leave the bootfile field empty because we're just using bootpd as a DHCP server, not a bootp server.