Home Account

subdomains with dnsmasq on localhost

2012-02-10 17:09 dennis iversen

Tags: dnsmasq linux

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 requested 5107 times