Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 587
user1578653 Avatar asked Aug 06 '12 08:08

user1578653


People also ask

How do I access a virtual server on another computer?

First your computer IP and port, then the IP of your virtual machine attached to your NATNETWORK and the port. In my case used 192.168. 1.102:8069 for the host and 10.0. 2.7:8069 for the guest.

Can host file have multiple IP addresses?

Save this answer. Yes, it is and always has been possible to have more than one IP address for a hostname. Note that while gethostbyname returns only one mapping (generally the first found in /etc/hosts), in modern Unix you can use getaddrinfo to walk through the entries.

Can you have multiple host files?

unfortunately, no. There cannot be two files with the same name. But you can concatenate two files into one. if you'll find someone's post helpful, mark it as an answer and rate it please.


1 Answers

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:

  • Windows 2000
  • Windows XP or Windows Server 2003
  • Windows Vista or Windows 7 or Windows Server 2008

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.

like image 78
ANDiTKO Avatar answered Sep 19 '22 04:09

ANDiTKO