How To Edit Hosts File on Your System

So often you will need to edit the hosts file on your machine. Sometimes because of an attack  and others so that you can simply and freely control access to websites and network traffic.This file is available on each operating systems and useful for mapping domains with IP address without making any DNS entry.
Using hosts file we can use any test domain name like, configure on server and map with IP in hosts file.

Edit Hosts File on Linux:

On Linux operating systems this file is normally available at following location:


Now we will edit this file and make proper entry with hostname and ip address as follows:

nano /etc/hosts   localhost.localdomain   localhost
::1         localhost6.localdomain6 localhost6

Save file and close it. 

Edit Hosts File on Windows:

On Windows operating systems this file is available with name “hosts” at following location:


Edit “hosts” file in notepad and make any entry like below at end of file.   localhost.localdomain   localhost
::1         localhost6.localdomain6 localhost6     testdomain

Save file. Now you have done mapping between domain name and IP locally on your system.