subdomains with dnsmasq on localhost

I started by editing /etc/hosts when adding new local domain names. But then I heard about dnsmasq which is the better option.

Install dnsmasq

sudo aptitude install dnsmasq

Edit dnsmasq configuration:

sudo vim /etc/dnsmasq.conf

And add a line like this (in order to use all submodmains like *.localhost):


Edit /etc/resolv.conf to always look for localhost on dns lookups first. This should be the first nameserver in the file:


Your /etc/reolv.conf file which is (depending on your setup) automatically created on boot, should also know that we need to keep as first name server. In order to do this we uncomment the following line in /etc/dhcp/dhclient.conf

prepend domain-name-servers

For dhcp3 you will need to add this line (note the ';')

prepend domain-name-servers;

Now it should work from boot every time!

This page has been viewed 4239 times. First hit: 01-Nov-2015 22:28:19
Share email, Google+, Twitter, Facebook.
comments powered by Disqus