Linux Host file entry to verify websites
Introduction
Host file is a system file used by an operating system to map a hostname to an IP-addresses. The host file is a plain text file and is conventionally named hosts.
Once website migration is over, we might need to make sure everything is in place, before flipping DNS. This can be done by adding an entry in our system’s hosts file.
Acess the hostfile location
sudo vim /etc/hosts
Enter the password of your PC, to grant Sudo access.
Press the I key, to enable the insert mode.
Lets add an example host file,
172.16.19.10 example.org www.example.org
127.0.0.1 localhost
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.16.19.10 example.org www.example.org
To save
After the host file entry is made, press the Esc key and type :wq! and hit the Enter key.
To check
Try the ping command to check if the host file entry made is right.
ping www.example.org
Ping for www.example.org must point to the Ip address 172.16.19.10
ping www.example.org
PING example.org (172.16.19.10) 56(84) bytes of data.
Once we have tested everything, you can flip the DNS. Also, make sure to remove this entry from the host file after testing.