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

7,648

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
Share:
7,648

Related videos on Youtube

Alex Henrie
Author by

Alex Henrie

Updated on September 18, 2022

Comments

  • Alex Henrie
    Alex Henrie almost 2 years

    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?

    • Alex Henrie
      Alex Henrie about 10 years
      Oh. I thought it was installed by default. Thanks!
  • lrkwz
    lrkwz over 8 years
    Is there any way to achieve the same result with "default" sw installed i.e. w/out dnsmasq?
  • Gomzy
    Gomzy almost 5 years
    Is it possible to create a dynamic host like if I enter xyz.localhost or pqr.localhost or etc.localhost then it will open the same?