It's not possible to use a wildcard in the hosts file on windows or linux. Is there a way to do it with a browser plugin or something else?
I have a dev server on a vbox instance so it's practically LAN. I'm creating .dev domain for my virtual hosts so example.com becomes example.dev. For an application I'm creating random subdomains (abd34dn.example.dev) which should all point to the dev server's IP.
What are my options?
Instead of editing hosts file (which does not work for your requirement), setup a DNS server and setup Wildcard DNS A record -- like
*.example.dev IN A 1.2.3.4
You mentioned subdomains, but I am assuming you actually want host entries (A address entries) under example.dev. Now abcd.example.dev indicates "abcd" is a host entry, and not a subdomain. Only if you say xyz.abcd.example.dev, then "abcd" becomes a subdomain. The key point is to say - since you want only abcd.example.dev - then you need only DNS A records and it is suggested as above.
I made this simple tool to take the place of hosts. Regular expressions are supported. https://github.com/stackia/DNSAgent Windows only. Probably working with Mono.
A sample configuration:
[
{
"Pattern": "^.*$",
"NameServer": "8.8.8.8"
},
{
"Pattern": "^(.*\\.googlevideo\\.com)|((.*\\.)?(youtube|ytimg)\\.com)$",
"Address": "203.66.168.119"
},
{
"Pattern": "^.*\\.cn$",
"NameServer": "114.114.114.114"
},
{
"Pattern": "baidu.com$",
"Address": "127.0.0.1"
}
]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With