How can I redirect *.localhost to 127.0.0.1 in Ubuntu 14.04?

I used to be able to make foo.localhost, bar.localhost, etc. resolve to 127.0.0.1 by adding

address=/localhost/127.0.0.1

to /etc/dnsmasq.conf

But dnsmasq.conf doesn't exist in Ubuntu 14.04, and just creating it and adding the line doesn't work. Creating /etc/dnsmasq.d/star-dot-localhost with the line doesn't work either. So how do I do wildcard DNS redirection in Ubuntu 14.04?


Solution 1:

As @Danatela mentioned, you need to have dnsmasq installed in order for that approach to work. You can check if it is installed using apt-cache policy command:

$ apt-cache policy dnsmasq
dnsmasq:
  Installed: (none)
  Candidate: 2.68-1
  Version table:
     2.68-1 0
        500 http://ru.archive.ubuntu.com/ubuntu/ trusty/universe amd64 Packages

Use these commands to install it:

sudo apt-get update
sudo apt-get install dnsmasq

Alternatively, you can edit your /etc/hosts file and add the following entries:

127.0.0.1    foo.localhost
127.0.0.1    bar.localhost