Editing hosts file

The hosts file is a system file on a device that lets you map specific domain names to an IP address. If you want to add new entries to the hosts file, you’ll need the IP address of the server that you want to map a hostname to.

XXX.XXX.XXX.XXX some.domain.name 

The hosts file lets you override DNS entries for any domain name. There are lists of common ad networks and tracking servers available online which you can use to keep an up-to-date list of sites to block. Blocking is achieved by setting the IP address of the ad networks to a loopback address like 127.0.0.1 which will not return anything. There are lists of common ad networks and tracking servers available online which you can use to keep an up-to-date list of sites to block.

If your device is infected with malware, then your hosts file may be compromised to included unknown entries for known domain names. That is NOT the IP address of your bank! This type of DNS attack is known as DNS pharming, and checking your hosts file can uncover potential infection.

iOS devices, such as the iPhone and iPad, use a hosts file to map hostnames to IP addresses. It can not be changed unless you

  • Jailbreak the device

  • Use a portable Wi-Fi router and set iOS cto get DNS from the router and the router will need the custom hosts set up.

  • Tether it to an Android with custom hosts file.

And that is most likely not enough in situations where governments are using DNS poisoning to block sites, like in China.