In my /etc/hosts/ file on Linux/OSX, how do I do a wildcard subdomain?
I need to test sub-domains on my localhost. How can I effectively have this result of adding *.localhost.com
to my /etc/hosts/
file?
If it's not possible, how do I work around this problem? I need to test wildcard sub-domains on my localserver. It is a Django devserver, can the Django dev server handle the sub-domains? Can some other piece of software/routing give me the end result I want?
Solution 1:
I have written a dns proxy in Python. It will read wildcard entries in /etc/hosts. See here: https://github.com/hubdotcom/marlon-tools/blob/master/tools/dnsproxy/dnsproxy.py
Solution 2:
Install dnsmasq (I do this on all my Linux desktops as a DNS cache anyways). In dnsmasq.conf
add the line:
address=/localhost.com/127.0.0.1
Solution 3:
It is not possible to specify wildcards in the /etc/hosts
file. Either specify the required hostnames explicitly or alternatively set up a local name server with the appropriate rules.
Solution 4:
You need to set up a DNS server and have each client use it for resolution. The server itself can be something as "light" as dnsmasq or as heavy as BIND.