Ubuntu: Use /etc/hosts to direct wildcard domain name



Question:

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:

192.168.129.3 ts.buck  192.168.129.3 www.ts.buck  

I tried using the *

192.168.129.3 *.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.


Solution:1

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

add

 address=/localhost.com/127.0.0.1  


Solution:2

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:

address=/somesite.local/127.0.0.1  

WILL NOT WORK

address=/somesite.loc/127.0.0.1  

will work.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »