Install BIND 9 on macOS (DNS Server)


When Apple destroyed macOS Server they recommended switching to open source alternatives which were actually integrated into the old Server.app. Server app also had a DNS Server which was a version of BIND from ISC. The binary which provides the DNS server is called ‘named’. Apple recommended compiling BIND from source and pointing the configuration files to the /Library/Server/named directory. This tutorial includes compiling from source but this process is actually obsolete with new dependencies namely ‘pkg-config’ which you’d have to install with something like MacPorts of HomeBrew anyway which can also provide an automated install of BIND which is what I recommend you do instead; the latest date that you can be supported with the manual source download to is December 2021 with BIND 9.11.33 Current-Stable, ESV .

You will still need to make the plist file and launch the installed ‘named’ which is the same regardless of how you acquire it.

Preparing the Mac (obsolete method, follow MacPorts or HomeBrew instructions instead)

  1. For newer macOS versions you may need to enable Full Disk Access for the Terminal.app in System Preferences > Security & Privacy
  2. Download Xcode from the Mac App Sore
  3. Open Terminal and install the command-line developer tools with the following command: Xcode-select --install
  4. Agree to the Xcode licence agreement: sudo xcodebuild -licence # followed by ‘q’ then type ‘agree’ then press return
  5. cd into your Downloads folder and extract the bind-9.11.33.tar.gz archive with: tar -xvzf bind-9.11.33.tar.gz
  6. : cd bind-9.11.33
  7. Now enter the following command to prepare the source for building: ./configure --infodir="/usr/share/info" --sysconfdir="/etc" --localstatedir="/var" --enable-atomic="no" --with-openssl=no --with-gssapi=yes --enable-symtable=none --with-libxml2=no --without-python
  8. Now perform the build with: make
  9. Finally install everything to /usr/local with: sudo make install

Setup the service (all installations)

With bind installed you now need to make a plist file to load ‘named’ as a service then configure the system to launch it and keep it alive.

  1. You need to create an ‘org.isc.named.plist’ file in /Library/LaunchDaemons/ , the file should have the following contents:
<?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>Disabled</key>
               <true/>
               <key>EnableTransactions</key>
               <true/>
               <key>Label</key>
               <string>org.isc.named</string>
               <key>KeepAlive</key>
               <true/>
               <key>ProcessType</key>
               <string>Standard</string>
               <key>ProgramArguments</key>
               <array>
               <string>/usr/local/sbin/named</string>
               <string>-f</string>
               <string>-c</string>
               <string>/Library/Server/named/named.conf</string>
               </array>
            </dict>
       </plist>
  1. Now set appropriate file permissions with: sudo chown root:wheel /Library/LaunchDaemons/org.isc.named.plist
  2. Load the service for the first time with: sudo launchctl load -w /Library/LaunchDaemons/org.isc.named.plist
  3. Verify it’s working with: launchctl print system/org.isc.named

Conclusion

With all that done you should have DNS server running independent of macOS Server. This should be able to coexist with macOS Server Catalina or latter but will conflict with Server.app on macOS Mojave and earlier due to the inclusion of a redundant ‘named’ binary which will kill your new service on startup. To manage the DNS server configuration you edit files in /Library/Server/named/ and issue the command ‘sudo killall -HUP named‘ to make your edits take effect.

Required Files

BIND 9.11.33