Edit the hosts file
Monday, November 1st, 2010If you have every wanted to set certain IP addresses in your network without depending on a nameserver, you can edit the ‘hosts’ file in your operating system. This can be done to stop access to any inappropriate sites as well.
The hosts file in Windows is:
%systemroot%System32driversetchosts
This is typically in:
c:windowsSystem32driversetchosts
On linux this file is:
/etc/hosts
The common layout of the file is
<IP address> hostname [hostname]
So if would look something like this:
127.0.0.1 localhost 192.168.2.222 homeserver homeserver.mydomain.net 127.0.0.1 badlocation
Remember that these lookups happen before looking to a nameserver. So this will override any name lookup. So if you happen to do this on a laptop that you regularly use outside of your home network, make sure that you do not override an address that might be needed when you are not at home.
You will need appropriate privileges to access the file. So you may have to be root or use sudo on Linux and you may have to open an editor as administrator before opening the file on Windows.