I searched this term and didn't find my answer: "wildcard domain name in hosts"

I have a HostGator account where I create secret domains so I can build and test websites. In order to use them, I add the domain to my /etc/hosts file like: ts.buck www.ts.buck

I tried using the * *.buck

but it doesn't work.

This is on my desktop, I don't have a server here. It is also for internal use only, not for the rest of the world to see or access.

It would be nice to have a simple way to use my own TLD for building test sites.


2 Answers 2


You need to set up a DNS server. (install dnsmasq (is light) or bind (is rather heavy)). To install ...

 sudo apt-get install dnsmasq

In /etc/NetworkManager/dnsmasq.d/dnsmasq-localhost.conf




 sudo /etc/init.d/dnsmasq restart

Important note.

If dnsmasq service failed to start, please check your service logs by running systemctl status dnsmasq.service command.

Then, If you will see the following message in the logs Failed to create listening socket for port 53: Address already in use - you may resolve this error as described here

  • This was a very easy fix and very simple answer. Much better than the pages in the links. I wish I had asked this years ago.
    – Buck
    Mar 7, 2016 at 13:32
  • I added the line: address=/.buck/ to dnsmasq-localhost.conf. This did the trick.
    – Buck
    Mar 7, 2016 at 13:45
  • Thanks, I didn't mean to override your answer, just clarify the added line without editing your answer. WOW, I am happy.
    – Buck
    Mar 7, 2016 at 13:46
  • Oh you are welcome to edit anything important into this answer ;-)
    – Rinzwind
    Mar 7, 2016 at 14:25
  • 1
    sudo service network-manager restart : make sure to restart the network manager too :)
    – Josh.F
    Jan 4, 2017 at 2:14

Just a quick addition to the above answer, make sure that your local domain name DOES NOT end with .local, it looks like this is a reserved name so in your /etc/dnsmasq.conf:




will work.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .