Map Hostname to IP Address Using Hosts
Mapping a hostname to IP address using hosts file is very convenient, we do not need to alter DNS preference anymore, In fact, we have no permissions to visit the local DNS servers unless you are the administrator.
So this post will be useful for your preference to map (change) a hostname to an individual IP address.
1. Find and open hosts file in your system
For Windows XP/7/8, it may be in C:\Windows\System32\drivers\etc\hosts, if you have not modify the default installation directory. If we are using Vista/Windows 7/8, we cannot edit the hosts file and save it directly.
Screenshot of hosts:
2. Map hostname to IP address
Map a hostname to Loop back address,
Then mydomain.com will always point to the local computer.
Map a hostname to null address,
Then blockdomain.com will be blocked because it point to a null IP.
3. Save changes and Replace hosts
If your testing browser is opened before your changes, it may be need to closed first and reopen again to take effect.