DNS vs the Windows hosts file
We’ve been working on a local LAB environment, you probably know that even in this kind of scenarios we can emulate the service provided by a DNS just adding entries for each of your local domain names (domains that are not valid outside your LAB) into the file called “hosts” located at the following folder on a Windows machine.
Opening Notepad as an Administrator
The “hosts” file is a system file and as such it can only be modified by a user with Administrative rights, since we’re going to use Notepad to open the “hosts” file, then you must open Notepad as the Administrator user, see image below.
Notepad will be open empty, now you can open the “hosts” file and rest assured that you’ll be able to save all the changes done.
Browse the file system of your Windows machine to reach the folder “C:\Windows\System32\drivers\etc” then switch from Text Documents to All Files to be able to see the “hosts” file.
Maping Local Domain to Local IP Address
In order to be able to “emulate” one DNS you can add pairs of Local Domain Names and the Localhost IP Address, see image below.
As you can see in the image above, just as an example, we do have 2(two) Virtual Machines running on Oracle Virtual Box, their ip addresses are different both VM’s are hosting multiple websites taking advantage of the great Apache’s feature that allow us to run Virtual Hosts.
Once you’ve saved the changes and only if the counter part configuration was done on the Apache’s side, that is a Virtual Host was properly configured, then you’ll be able to go to your website using its local domain name.
Not a real DNS but a useful trick
You must be aware that this kind of configuration is only good for a LAB, this is not by any means equivalent to a real DNS, we’re going to cover the building of a real DNS running on a Linux CentOS VM in further article, stay tuned.