The hosts file on your system is a powerful tool that maps hostnames to IP addresses. It is like having a configurable DNS server sitting in a plain text file right on your system. This file is located in:
Windows c:\windows\system32\drivers\etc Linux /etc Mac /private/etc
I mainly use it to block malicious websites and advertisements. You do this by mapping known malicious sites and ad servers to your system basically making the requests for the actual IP addresses impossible since your system will not respond to the request. The mappings look like this:
127.0.0.1 adserver.com or 0.0.0.0 anotheradserver.com
You can use this to map names of computers on your local network to their respective local IP addresses. First you need access to your router back end. This is most likely located at 192.168.1.1 for most consumer routers. It may also be at 192.168.1.254. In the back end you need to create static IP addresses for each of your computers. Once you have assigned static IP addresses to each computer you must edit the hosts file on each computer using these assigned addresses. Your hosts file entries will look similar to this:
192.168.1.2 living-room-desktop 192.168.1.3 work-laptop 192.168.1.4 tablet
If you share files between your computers or use ssh this technique will make your life easier. You can name your devices anything you'd like. In this case I named mine 'living-room-desktop', 'work-laptop', and 'tablet'. This is also an easy way to run LAMPP on your local network without having to register a domain name. Now you can already see where this file can be maliciously edited to make a persons computer visit the wrong websites or malicious servers. First you will need to open a terminal in Linux or Mac or a command console in Windows. Type:
The server will answer with its IP address. This is the address that a normal DNS server usually gives you. You now take this IP address and add an entry in the hosts file for a trusted website.
The above entry will send the user to net-security.org if they type in the address trustedwebsite.com. Though once they reach the malicious website the correct URL will show and the user will be alerted to the redirected website.