4

We'd like to set things up on our developers' Windows boxes such that all .dev domains resolve to localhost. On Unix systems, firing up dnsmasq with a single additional line to hosts would do it, but dnsmasq is sadly Unix-only. On the Windows side, I'm not aware of an equivalent solution, either built-in or available in a third-party utility. The best I've been able to come up with are some PowerShell scripts, running as administrator, that would alter c:\Windows\System32\Drivers\etc\hosts directly—ugly and error-prone at best.

What's the right way to do this? Does no solution meaningfully exist right now?

  • I don't think the hosts files in Windows supports wildcards. You could do what TheFiddlerWins is suggesting and set a wildcard A record to 127.0.0.1, but yes it would go to all Windows clients using that DNS server. Probably doesn't matter since it is a .dev though. But mixing "production" and "development" is typically taboo. Why the need? Can't the dev peeps create their own entries as they build up a local site/server/host? – TheCleaner Sep 17 '13 at 15:58
  • The issue here is that there are a collection of sites (foo.com, bar.com, etc.) that talk to each other; we'd like to make it so that their location on the dev boxes is similar (foo.dev, bar.dev), which allows for consistency without editing the hosts file for each site. Making new virtual hosts in IIS would be sufficient. – Benjamin Pollack Sep 17 '13 at 16:06
  • This seems like a duplicate of the following answer: stackoverflow.com/questions/138162/… – Josh Oct 13 '16 at 22:53
3

Do you have a .dev zone in DNS already? You can create a wildcard entry where *.dev goes to the loopback.

| improve this answer | |
  • We don't; you're proposing doing this at the AD level, so that any machines on the domain would pick it up? – Benjamin Pollack Sep 17 '13 at 15:48
  • It's not really at the "AD" level, although if you use AD integrated DNS and create the zone as such it would work out that way - it would be for any machine that resolved against that DNS server(s). – TheFiddlerWins Sep 17 '13 at 17:22
  • Got it. That sounds a lot saner than doing this on each box. – Benjamin Pollack Sep 17 '13 at 19:06
7

Alternative: get your devs to just append .localtest.me, which is a public DNS zone that already exists (with a * A record) for this purpose.

| improve this answer | |
  • 7
    I'm not sure that adding an untrusted public domain to your workflow is a great plan! – JamesRyan Jan 15 '14 at 23:48
  • If this concerns you, it would be simple to add a DNS test to whatever monitoring solution you use. If the DNS for localtest.me has changed in the last second, make it blast an alert to your devs. – Ross Presser Jan 17 '14 at 16:20
4

I have resolved this situation using Acrylic DNS Proxy. It's a free, open-source software for Windows that allows you to wildcard a folder as local top domain registry.

  1. Download Acrylic DNS Proxy here: http://mayakron.altervista.org/wikibase/show.php?id=AcrylicHome
  2. Configure your Network settings to point to your local IP address as explained here: http://mayakron.altervista.org/wikibase/show.php?id=AcrylicWindows10Configuration
  3. Open your Acrylic config file here: Start > Programs > Acrylic DNS Proxy > Edit Custom Hosts File (AcrylicHosts.txt)
  4. Add your wildcarded top level domain like this: 127.0.0.1 *.dev
  5. Restart Acrylic like this: Start > Programs > Acrylic DNS Proxy > Restart Acrylic Service
  6. Add the wildcard to your Apache config file. It may look similar to this:

It may look similar to this:

LoadModule vhost_alias_module modules/mod_vhost_alias.so  

NameVirtualHost *.dev:80  

<Directory "/www/sites">  
    Options Indexes FollowSymLinks Includes ExecCGI  
    AllowOverride All  
    Order allow,deny  
    Allow from all  
 </Directory>  

 <VirtualHost *.dev:80>  
     VirtualDocumentRoot c:/www/sites/%-1/%-2+/  
 </VirtualHost>  

That should do the trick.

| improve this answer | |
3

I can recommend http://localhost.tv - all subdomains resolve to 127.0.0.1

| improve this answer | |
  • 3
    I'm not sure that adding an untrusted public domain to your workflow is a great plan! – JamesRyan Jan 15 '14 at 23:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.