How to use wildcards for *.localhost in Ubuntu

I was tired of a very long /etc/hosts, with tens of lines with different test environments (client1.localhost, client2.localhost). So I found a way to make it easier: dnsmasq.

Information from http://serverfault.com/questions/118378/in-my-etc-hosts-file-on-linux-osx-how-do-i-do-a-wildcard-subdomain/118589#118589 and tested in Ubuntu Maverick 10.10 (should work on any Linux)

sudo aptitude install dnsmasq
sudo echo "address=/localhost/127.0.0.1" >> /etc/dnsmasq.conf
sudo /etc/init.d/dnsmasq restart

Now you just add 127.0.0.1 as a DNS server and you are done.

One comment.

  1. Thanks, you helped a lot, it’s exactly what i’ve needed.

Post a comment.