Tinydns (djbdns) on Mac OS X with Launchd

This information comes with no warranty.

Introduction

Tinydns is a piece of software from the djbdns suite. Unfortunately, it was written long, long ago, and although it still performs very well compared to Bind, the install instructions don’t really help too much if you’re trying to install on Mac OS X.

This page should step you through what you need to do to install tinydns on Mac OS X

Much of what I’ve written is nicked from http://www.jms1.net/djbdns/osx.shtml and http://cr.yp.to/djbdns

Install Developer Tools

Download and install the latest verson of Xcode Tools from Apple’s developer site.

Install daemontools

This step is almost certainly redundant, as we use launchd to manage the service. But I’ve included it for completeness. You can use MacPorts to do this, or follow these steps:

mkdir -m 1755 /package
cd /package
curl -O http://cr.yp.to/daemontools/daemontools-0.76.tar.gz
tar xvzf daemontools-0.76.tar.gz
rm daemontools-0.76.tar.gz
cd admin/daemontools-0.76

# This is only needed for OS X 10.4.
echo x >> src/trypoll.c
package/install

Unfortunately, this will add a line to a new file called /etc/rc.local. Remove it, we won’t be needing it.

Install ucspi-tcp

You can use MacPorts to do this, or follow these steps:

cd /package
curl -O http://cr.yp.to/ucspi-tcp/ucspi-tcp-0.88.tar.gz
tar xvzf ucspi-tcp-0.88.tar.gz
rm ucspi-tcp-0.88.tar.gz
cd ucspi-tcp-0.88
make
make setup check

Install djbdns

You can use MacPorts to do this, or follow these steps:

cd /package
curl -O http://cr.yp.to/djbdns/djbdns-1.05.tar.gz
tar xvzf djbdns-1.05.tar.gz
rm djbdns-1.05.tar.gz
cd djbdns-1.05
make
make setup check

Configure djbdns

Create groups and users:

nicl / create /groups/djbdns gid 88
nicl / create /groups/djbdns passwd '*'
nicl / create /users/dnsrun uid 88
nicl / create /users/dnsrun gid 88
nicl / create /users/dnsrun shell /bin/false
nicl / create /users/dnsrun home /nohome
nicl / create /users/dnsrun realname dnsrun
nicl / create /users/dnsrun passwd '*'

nicl / create /users/dnslog uid 89
nicl / create /users/dnslog gid 88
nicl / create /users/dnslog shell /bin/false
nicl / create /users/dnslog home /nohome
nicl / create /users/dnslog realname dnslog
nicl / create /users/dnslog passwd '*'

You’ll need to create a directory, /etc/tinydns, and populate with a few things you’re going to need. tinydns contains a script to do this for you, called tinydns-conf. Replace ‘1.2.3.4’ with the IP number of your server.

/usr/local/bin/tinydns-conf dnsrun dnslog /etc/tinydns 1.2.3.4

You’ll need to edit the file /etc/tinydns/run, and give fully qualified names to all the binary paths. So the last line will look something like this:

exec /usr/local/bin/envuidgid dnsrun /usr/local/bin/envdir ./env /usr/local/bin/softlimit -d300000 /usr/local/bin/tinydns

The normal thing to do at this point would be to use daemontools to start and run the service. But we’re going to use launchd instead.

Configure launchd

cat > /System/Library/LaunchDaemons/to.rp.cy.tinydns.plist << EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>Label</key>
    <string>to.yp.cr.tinydns</string>
    <key>ServiceDescription</key>
    <string>tinydns</string>
    <key>ProgramArguments</key>
    <array>
      <string>/private/etc/tinydns/run</string>
    </array>
    <key>OnDemand</key>
    <false/>
    <key>WorkingDirectory</key>
    <string>/etc/tinydns</string>
    <key>StandardErrorPath</key>
    <string>/Library/Logs/tinydns/error.log</string>
    <key>StandardOutPath</key>
    <string>/Library/Logs/tinydns/out.log</string>
  </dict>
</plist>

EOF

You’ll need to load this into launchd:

launchctl load /System/Library/LaunchDaemons/to.rp.cy.tinydns.plist 

and then start it (or reboot)

launchctl start to.rp.cy.tinydns
 
technical/unix/mac_os_x/launchd_tinydns.txt · Last modified: 2006/11/14 05:18 by garylaw