Setting Up a Local Nameserver on Mac OS X 10.4.x

23 10 2006

Instructions for setting up a local Nameserver in Mac OS X 10.4.x For Local Website Development

Introduction

Mac OS X Tiger comes with lots of traditional UNIX goodies, one of these is the BIND name server.

These guidelines are intended as a quick reference for setting up bind to resolve arbitrary
domain names so that in turn you can set up virtual hosts in apache.

I prefer this method to mucking about with NetInfo Manager and please feel free to point out
gotchas and caveats with this approach.

References

An Article at MacOSXHints.com

DNS & BIND By Paul Albitz

Set up the BIND Configuration files
  • Open up a terminal and become root
  • mkdir /System/Library/StartupItems/BIND
  • cd /System/Library/StartupItems/BIND
  • touch BIND
  • touch StartupParameters.plist

Edit the ./BIND file in your favourite editor and insert the following:

#!/bin/sh

. /etc/rc.common

if [ "${DNSSERVER}" = "-YES-" ]; then
  ConsoleMessage "Starting BIND DNS Server"
  /usr/sbin/named
fi

Make the BIND file executable with a chmod +x BIND

Edit the ./StartupParameters.plist

{
  Description = "Local Caching DNS Server";
  Provides = ("DNS Server");
  OrderPreference = "None";
  Messages =
  {
  start = "Starting BIND DNS Server";
  stop = "Stopping BIND DNS Server";
  };
}
Set up the rndc utility
  • Create the rndc.conf file: rndc-confgen > /etc/rndc.conf
  • Copy the key from rndc.conf into a new rndc.key file: head -n 6 /etc/rndc.conf > /etc/rndc.key

Edit the rndc.conf file and change the line that reads:

options {
	.....
	default-port 953;
};

To:

options {
	.....
	default-port 54;
};
Create a new Zone File
  • cd /var/named
  • touch my.site (rename my.site to your name of choice such as powerbook.site or something. Try to avoid ‘real’ tlds such as .com or .net etc…)
    • Edit the new zone file to read something like this:

      $TTL        86400
      @           IN    SOA      localhost. root.localhost.  (
                                 2003072405
                                 7200
                                 7200
                                 1209600
                                 172800 )
      
      ; Primary Name Server
                  IN    NS       localhost.
      
      ; which subdomains map to which address...
      my.site.    IN    A        127.0.0.1
      *.my.site.  IN    A        127.0.0.1
      

      Add the zone file to the end of the master named configuration file in /etc/named.conf

      zone "my.site" IN {
      	type master;
      	file "my.site";
      	allow-update { none; };
      };
      

All done!

Startup named by issuing as root # /System/Library/StartupItems/BIND/BIND

Now all you have to do to add a new domain name to your configuration is create a new zone file
as for my.site earlier, add the zone to the named configuration file in /etc/named.conf
and issue a rndc reload as root have your new “Domain Name” resolve to your local
machine.

Add as many virtual hosts in Apache as you like and off you go…


Actions

Informations

Leave a comment

You must be logged in to post a comment