# 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):

address=/localhost/127.0.0.1


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

nameserver 127.0.0.1


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

prepend domain-name-servers 127.0.0.1


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

prepend domain-name-servers 127.0.0.1;


Now it should work from boot every time!

This page has been viewed 3144 times. First hit: 01-Nov-2015 22:28:19