Better Local Dev Hostnames with Dnsmasq

I use ghost to configure development environment hostnames for all my local test sites. Some DTrace tomfoolery showed me how ghost handles this config: each new hostname is saved to its own plist file.

Update: for zero-configuration wildcard DNS, check out

ambackstrom@fsck:~:1$ sudo cat /var/db/dslocal/nodes/Default/hosts/
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">

There's filesystem caching going on behind the scenes and I expect the net impact is negligible, but I wondered if there wasn't a more robust solution that supported wildcards. Having just configured dnsmasq on my router, I started with a brewinstall dnsmasq and was pleasantly surprised to get a progress bar rather than "no available formula." Homebrew recommended a couple post-install actions for setting up a default config file and configuring launchd to keep dnsmasq alive, which I dutifully ran. After that, I enabled my fake TLD in dnsmasq.conf:

# respond to *.zomg with

By sheer luck I ended up on this great post explaining Mac OS X's resolver(5) and the /etc/resolver directory. Forcing dnsmasq lookup on my zomg TLD is as easy as:

echo 'nameserver' >/etc/resolver/zomg

These settings will work on any network we connect to, no need to modify the DNS servers via System Preferences and put (dnsmasq) in front. Simple, clean, flexible.