I like to use a wildcard DNS entry for my localhost. The reason? If I want to establish a new virtual domain in Apache for testing, I need only go in and create my own arbitrary virtual domain (like railsdev.localhost), and the DNS side will "just work." On Linux machines, you can just edit /etc/hosts and put a *.localhost entry in. This didn't appear to work on OS X, so I instead enabled a local nameserver and went down that path.
I gathered hints from various parts of the net when it came to enabling DNS on OS X Tiger, and I think I have found the most efficient way to do that.
First up, run the following commands to generate a rndc.conf and key file. You can disable this stuff in /etc/named.conf if you like; otherwise:
Now you need to add the wildcard record to the localhost zone file. To do this, add the following line to the end of /var/named/localhost.zone:
$ rndc-confgen > /etc/rndc.conf $ head -n 6 /etc/rndc.conf > /etc/rndc.key
In OS X Tiger, daemons like named are controlled via launchctl. There is a simple XML configuration file called org.isc.named.plist, which you'll find in /System/Library/LaunchDaemons. The first few lines are listed here:
* IN A 127.0.0.1
Simply change the true/ bit to false/ to enable named. You can then use launchctl to bounce this process:
<plist version="1.0"> <dict> <key>Disabled</key> <true/>
Don't worry if the first two lines give you an error.
$ launchctl stop org.isc.named $ launchctl unload org.isc.named.plist $ launchctl load org.isc.named.plist $ launchctl start org.isc.named
Mac OS X Hints