DNSmasq for custom development domain name

Setting up a custom domain name for a local development may be really useful especially when you want to test multisite setup (e.g. for Wordpress multisite site). In the tutorial below I will show how to point all *.dev addresses back to your localhost (or any other IP e.g. Vagrant host or Docker container).

Install Dnsmasq. On OS X it is available via homebrew package manager.

brew up
brew install dnsmasq

For Ubuntu you may install dnsmasq via sudo apt-get install dnsmasq (official docs)

Then you should be able to configure address redirections in the Dnsmasq config file (/usr/local/etc/dnsmasq.conf on OS X) e.g.


Above instructions will redirect every *.dev address to the localhost, which may be useful if you are using localhost as a development server or a Docker with 80 port bound to your localhost.

In case you are using Vagrant you would probably write something like this in your dnsmasq config (if you Vagrant host is available on IP address).


Next thing to do after adjusting Dnsmasq config file is restarting the Dnsmasq service.

sudo launchctl stop homebrew.mxcl.dnsmasq
sudo launchctl start homebrew.mxcl.dnsmasq

Now when you enter any address which ends with .dev to the browser you will see the content of your localhost/Docker container/Vagrant host. For example if this site would be developed with that approach I would probably have a local development copy under the http://grzegorowski.dev address.