5

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?

4
  • 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, 2013 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. Sep 17, 2013 at 16:06
  • This seems like a duplicate of the following answer: stackoverflow.com/questions/138162/…
    – Josh
    Oct 13, 2016 at 22:53
  • Everyone, beware - .dev domain is now TLD: domains.google/tld/dev Jul 5, 2022 at 15:35

4 Answers 4

3

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

3
  • We don't; you're proposing doing this at the AD level, so that any machines on the domain would pick it up? Sep 17, 2013 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). Sep 17, 2013 at 17:22
  • Got it. That sounds a lot saner than doing this on each box. Sep 17, 2013 at 19:06
8

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.

2
  • 11
    I'm not sure that adding an untrusted public domain to your workflow is a great plan!
    – JamesRyan
    Jan 15, 2014 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. Jan 17, 2014 at 16:20
5

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.

0
3

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

1
  • 5
    I'm not sure that adding an untrusted public domain to your workflow is a great plan!
    – JamesRyan
    Jan 15, 2014 at 23:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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