The DCHP server (dhcpd) source works without any modification on OS X. The DHCP client is already part of OS X, so it's probably better to leave the version that Apple provided alone. To install only the server, we'll specify specific subdirectories.
Before you run it the first time, you need to create an empty leases file to keep it from complaining:
Can't open lease database /var/db/dhcpd.leases: No such file or directory --
check for failed database rewrite attempt!
sudo touch /var/db/dhcpd.leasesWe'll setup a basic network and give clients the 192.168.1.70-100 range.
One reason you might want to run DHCPD is to host a network boot, which is called a PXE (Pre-eXecution Environment) boot. We'll throw a couple lines in our config to tell such machines to load the Linux network loader from the file pxelinux.0 on the host at 192.168.1.50 (which is the same Mac running the DHCP server - I'll discuss what I did with PXE in another post).
Here's a complete recipe to download, build and configure dhcpd for OS X:
curl -O http://ftp.isc.org/isc/dhcp/dhcp-3.1.3.tar.gzFor my uses, I want this dchpd to serve clients hooked up to my MacBook's ethernet port, so I manually set an IP address that's on the appropriate network range (it's okay if it already has an IP address, this will just give it another one):
tar xzvf dhcp-3.1.3.tar.gz
cd dhcp-3.1.3
./configure
make
sudo make install SUBDIRS='common dhcpctl omapip server'
sudo touch /var/db/dhcpd.leases
cat > dhcpd.conf <<END
default-lease-time 86400;
max-lease-time 604800;
ddns-update-style ad-hoc;
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.70 192.168.1.100;
filename "pxelinux.0";
next-server 192.168.1.50;
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.1.255;
option routers 192.168.1.1;
}
END
sudo cp dhcpd.conf /etc/
sudo ifconfig en0 192.168.1.50When you start the dhcp server, you'll probably get a warning that there's no subnet declaration for en1 since we didn't configure anything for the AirPort network. That's okay, just ignore that wordy warning:
No subnet declaration for en1 (192.168.10.100).
** Ignoring requests on en1. If this is not what
you want, please write a subnet declaration
in your dhcpd.conf file for the network segment
to which interface en1 is attached. **
Start the dhcp server:
sudo /usr/sbin/dhcpdStop the dhcp server:
sudo killall dhcpd
Running on OS 10.5.7, under bash, after the command ./configure
ReplyDeleteI get:
System Type: darwin
./configure: line 269: make: command not found
Any thoughts?
Do you have XCode installed? You need developer tools to build binaries.
ReplyDeletedhcp-3.1.2 is no longer available from that host. It's now dhcp-3.1.3
ReplyDeleteThanks... I updated the recipe so folks can copy/paste again
ReplyDelete