Main navigation

Resolve all local domains to 127.0.0.1 with dnsmasq

You need DNS to resolve locally ?

Option 1: edit your hosts file

sudo vim /etc/hosts

Add the following: 127.0.0.1 example.dev

Option 2: Alternatively, I recommend running dnsmasq and configuring all .dev extensions to resolve to 127.0.0.1. Note that using the .local extension results in lots of problems and kills baby kittens, don’t use it.

First, Ubuntu 12.04 has dnsmasq installed and enabled by default. Config file, y u no work? This needs to be disabled so we can install a version of dnsmasq that allows configuration.

sudo vim /etc/NetworkManager/NetworkManager.conf

Comment out dns=dnsmasq

sudo restart network-manager

Now, install dnsmasq

sudo apt-get install dnsmasq

sudo vim /etc/dnsmasq.conf

Around line 60 ... set *.dev=127.0.0.1
# Add domains which you want to force to an IP address here.
# The example below send any host in double-click.net to a local
# web-server.
#address=/double-click.net/127.0.0.1
address=/.dev/127.0.0.1

Around line 90 put listen-address=127.0.0.1
# Or which to listen on by address (remember to include 127.0.0.1 if
# you use this.)
#listen-address=
listen-address=127.0.0.1