6/6/2013 - 11:47 AM

this is what i have used to create a wildcard dns resolver when am trying to work with #laravel and domain routings

this is what i have used to create a wildcard dns resolver when am trying to work with #laravel and domain routings

#orginal one from

Bind DNS Setup (OSX 10.8+)

BIND is the little piece of software the runs the internet. BIND is a DNS server and it works in a distributed fashion. It’s really fascinating how DNS works but that’s outside the scope of this post. There are a few steps to get BIND set up to serve domains and they are crucial.

sudo -s

This will let you run a shell as root. I suggest doing this because most of the next commands you will execute need to be on privileged files and directories.

Create the rndc.conf and rndc.key You can easily do this by running the following commands:

rndc-confgen > /etc/rndc.conf
head -n5 /etc/rndc.conf |tail -n4 > /etc/rndc.key

Add the zone to /etc/named.conf I am going to use .dev for all my examples. I have used .local on my machine but I have found that this can be troublesome with the OS X default Multicast being .local. You can make this whatever top level domain you would like (.dev, .rails, .php, etc.) In /etc/named.conf add:

zone "dev" IN { type master; file ""; allow-update { none; }; };

Create /var/named/ Use this template for your zone file:

$TTL  60
$ORIGIN dev.
@      1D IN SOA localhost. root.localhost. (
          42   ; serial (d. adams)
          3H   ; refresh
          15M    ; retry
          1W   ; expiry
          1D )   ; minimum

      1D IN NS localhost
      1D IN A 60 IN A
*.dev. 60 IN A

The only thing you should have to change is the serial (42) to any random number and if you decided to go with something else other than .dev: everthing that has .dev in it. Note that the dots (.) after the dev entries are intentional and required.

launchctl load -w /System/Library/LaunchDaemons/org.isc.named.plist

This will cause named to load everytime the system restarts.


This loads named now. It doesn’t give you any input if it fails to load so I recommend running named -g first to make sure it parses you zones and configs. -g will tell named to run in the forground and write all logging to STDOUT. Once you’ve verified that it starts then Ctrl-c and run named as normal.


Next we have to create an entry in the /etc/resolver folder. This folder is checked every time a DNS entry is looked up. If a file exists here then it will use the special resolv configuration to look up DNS names. Here you can specify custom domains, search orders, and in this case nameservers. The resolver folder may not exist in the /etc directory. If it doesn’t, create it.

Create a file with the root domain you want to use for your projects.. I.e. if your root domain is *.dev then create the file dev ( i got this note from the comments ) and inside it put:


Now when you go to your root web directory should load, but you can also go to or and it should still go to your root web directory.

Log out of the root shell by typing exit.

Your wildcard DNS settings are now ready to go.

now anything you have to do is related to your apache one