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

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