The hosts file is a file used to convert domain/hostnames to IP addresses. Adding an entry to hosts file helps you to override DNS for a domain/hostname and use the IP specified in the hosts file to resolve the domain/hostname on a specific machine.
Hosts file entry contains the IP address to which you want the domain/hostname to resolve.
123.123.123.123 layerexample.com www.layerexample.com
See the instructions for editing hosts file on Linux & Windows below.
Linux
The hosts file location for the Linux system is as follows :
# /etc/hosts
Open a console and enter the following command to open the hosts file in VI editor
.
# vi /etc/hosts
Add the entries as follows in this file and save
.
123.123.123.123 layerexample.com www.layerexample.com
After saving, you could see layerexample.com
and www.layerexample.com
resolve to 123.123.123.123
.
Windows
The hosts file location for Windows system is as follows:
# /etc/hosts
Select Start
> All Programs
> Accessories
.
Right-click Notepad
and then select Run as administrator
.
Open the file C:\Windows\System32\drivers\etc\hosts
in Notepad.
Add the entries as follows in this file and save
.
123.123.123.123 layerexample.com www.layerexample.com
After saving, you could see layerexample.com
and www.layerexample.com
resolve to 123.123.123.123
from the command prompt.