Script to run the MacOS Built-in DHCP Server

by Oct 9, 2025IT Tips0 comments

For info on how to configure http://www.jacquesf.com/2011/04/mac-os-x-dhcp-server/

DHCP Server Start Stop Script

#!/bin/bash

# /usr/local/bin/dhcpmgmt.sh

function start {
	sudo /bin/launchctl load -w /System/Library/LaunchDaemons/bootps.plist
}

function stop {
	sudo /bin/launchctl unload -w /System/Library/LaunchDaemons/bootps.plist
}

case "$1" in
	"start")
		echo "Starting DHCP Server"
		start
		;;

	"stop")
		echo "Stopping DHCP Server"
		stop
		;;
	"status")
		echo "Checking status"
		sudo launchctl list com.apple.bootpd
		;;
	"leases"|"l")
		echo "Viewing leases"
		cat /var/db/dhcpd_leases
		;;
	*)
		echo "Usage:"
		echo dhcp-tgn start\|stop\|leases\|lstatus
		echo .  
		;;
esac



The important bits are change your bootpd.plist to point to the correct interface (mine is en7), add a static ip to it (e.g. 10.77.80.1) and modify the range and other settings to work for you.

<?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">
<plist version="1.0">
<dict>
	<key>Subnets</key>
	<array>
		<dict>
			<key>allocate</key>
			<true/>
			<key>dhcp_router</key>
			<string>10.77.80.1</string>
			<key>lease_max</key>
			<integer>86400</integer>
			<key>lease_min</key>
			<integer>86400</integer>
			<key>name</key>
			<string>10.77.80.0</string>
			<key>net_address</key>
			<string>10.77.80.0</string>
			<key>net_mask</key>
			<string>255.255.255.0</string>
			<key>net_range</key>
			<array>
				<string>10.77.80.20</string>
				<string>10.77.80.30</string>
			</array>
		</dict>
	</array>
	<key>bootp_enabled</key>
	<false/>
	<key>detect_other_dhcp_server</key>
	<false/>
	<key>dhcp_enabled</key>
	<array>
		<string>en7</string>
	</array>
	<key>reply_threshold_seconds</key>
	<integer>0</integer>
	<key>use_server_config_for_dhcp_options</key>
	<true/>
</dict>
</plist>

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.