Are there any alternatives to hosts file for accessing virtual hosts from multiple PCs?

user1578653 picture user1578653 · Aug 6, 2012 · Viewed 15.2k times · Source

I have several virtual hosts set up on my PC running WAMP. All the other PCs in the office need to be able to access these too. Traditionally, every time I added a new virtual host to my PC, I need to go to all of the other office PCs and modify their hosts files. This works fine, but it is a pain to go edit all of these files.

Is there an alternative to this? Is there some way of having a centralised hosts file on the network or some other solution?

Answer

ANDiTKO picture ANDiTKO · Jan 8, 2013

Some routers have the ability to map domain records into IP adresses and act like a DNS. But if your router dont support this:

Try Acrylic DNS Proxy. Acrylic is a free and open source local DNS proxy. Follow the installation instructions on the website to set it up. Basicly you will need to install this program only on your main PC that will act like a "DNS proxy". Then you will need to set your other computers primary DNS server to hook with your main pc.


Step 1: Install

Launch the Acrylic.exe file and click on the Next button. Read and (if you like it) accept the license agreement by clicking on the I Agree button. Choose the installation folder (the default is the Program Files\Acrylic DNS Proxy folder) and click on the Install button.

Step 2: Configure

Do the following steps only on your main PC

  • Click on Start Menu -> Programs -> Acrylic DNS Proxy -> Config -> Edit Configuration File
  • Find the text "; ALLOWING REQUESTS FROM OTHER COMPUTERS" and configure it properly. Its well commented and very easy.
  • Click on Start Menu -> Programs -> Acrylic DNS Proxy -> Config -> Edit Custom Hosts File
  • Edit the host file as you want. You can use Wildcards like "192.168.0.2 *.local" or regular expressions. So all the domains ending with ".local" will be pointed to your main server.

Note: After changing the configuration files you must restart the Acrylic DNS Proxy service from the start menu.

Step 3: Hook to the DNS Proxy

In order to use Acrylic you have to tell your computer that the DNS servers to be contacted for name resolution is no more your ISP's but Acrylic. There are ways to do it depending on the version of the OS you are running:

Note: On your other computers you will have to replace the "127.0.0.1" to your main PC network address. For example "192.168.0.2" . And leave the secondary DNS to 8.8.8.8 (Google DNS) so the other computers can browse the internet even when your main PC is not connectable (or turned off). Like this

Step 4: Test

Make sure everything is properly configured and your main PC is connectable and running. If you have antivirus or firewall programs they will block this DNS proxy so make sure you configure them properly or disable them at first just to test everything is working. Also your main PC local IP address must be static.