Skip to content

Instantly share code, notes, and snippets.

@simenbrekken
Created May 9, 2012 08:06
Show Gist options
  • Save simenbrekken/2642843 to your computer and use it in GitHub Desktop.
Save simenbrekken/2642843 to your computer and use it in GitHub Desktop.
Setting up a local wildcard DNS server

#Installation#

First you'll need dnsmasq, assuming you're on OSX installation is simply:

brew install dnsmasq

#Configuration#

Add 127.0.0.1 to to the top of your DNS server list in your Network Configuration:

Network Configuration

Make sure you keep your router DNS address in there as well, or you'll be stuck on localhost.

Attached are sample dnsmasq.conf and Apache virtual host configuration files. With this setup you won't need any /etc/hosts entries since dnsmasq provides wildcard DNS resolution.

After (re)starting dnsmasq, verify your setup:

dig someone.like.you.dev

It should return the following:

;; ANSWER SECTION:
someone.like.you.dev.	0	IN	A	192.168.1.100
<VirtualHost *:80>
DocumentRoot "/Users/You/Sites/acme" # This is symlinked to /Users/You/Projects/ACME/www
ServerName acme
ServerAlias acme.you.dev
<Directory "/Users/You/Sites/acme">
Options All
AllowOverride All
Order allow, deny
Allow from all
</Directory>
</VirtualHost>
# In this example I assume you're using .dev as your local domain
address=/you.dev/127.0.0.1
# Never forward plain names (without a dot or domain part)
domain-needed
# Provide only DNS service, disable DHCP and TFTP
no-dhcp-interface=
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment