[Android Apps and Games] ipdev:
Your local hosts file is the first step in dns. (Domain Name System)

When you call a location by name, it will first check your local hosts file for a corresponding ip address. If not found it will check the external dns servers that you have configured.

So by adding the name and corresponding ip address to your local hosts file, the name call will be found (resolved). The external dns servers are not used.

The name call will then go to the ip address that it found in your local hosts file.

You can still call the original by the ip address since it does not look for name resolution.

That is why it is mentioned time and time again, if ads are being called by an ip address.

Hosts based ad blocking will not work since name servers are not used.

---

Two examples.

Note the name and ip address differences.

See how the ping response changes to localhost (127.0.0.1) after adding the name to local hosts file.

Notice we can still ping the proper ip address and get the same result even after adding name to the local hosts file.

Example 1.

Using a dead registered dns server.

204.29.202.50 earth.execpc.com

$ ping earth.execpc.com
ping: unknown host earth.execpc.com

$ ping 204.29.202.50
PING 204.29.202.50 (204.29.202.50) 56(84) bytes of data.
^C
--- 204.29.202.50 ping statistics ---
7 packets transmitted, 0 received, 100% packet loss, time 6005ms

Add earth.execpc.com to hosts file. 127.0.0.1 earth.execpc.com

$ ping earth.execpc.com
PING earth.execpc.com (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.183 ms
64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.641 ms
64 bytes from localhost (127.0.0.1): icmp_seq=3 ttl=64 time=0.244 ms
64 bytes from localhost (127.0.0.1): icmp_seq=4 ttl=64 time=0.580 ms
64 bytes from localhost (127.0.0.1): icmp_seq=5 ttl=64 time=0.274 ms
^C
--- earth.execpc.com ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4006ms
rtt min/avg/max/mdev = 0.183/0.384/0.641/0.188 ms

$ ping 204.29.202.50
PING 204.29.202.50 (204.29.202.50) 56(84) bytes of data.
^C
--- 204.29.202.50 ping statistics ---
6 packets transmitted, 0 received, 100% packet loss, time 5008ms

Example 2.

Using google's.

8.8.8.8 dns.google.com

$ ping dns.google.com
PING dns.google.com (8.8.8.8) 56(84) bytes of data.
64 bytes from dns.google (8.8.8.8): icmp_seq=1 ttl=117 time=18.5 ms
64 bytes from dns.google (8.8.8.8): icmp_seq=2 ttl=117 time=23.9 ms
64 bytes from dns.google (8.8.8.8): icmp_seq=3 ttl=117 time=24.2 ms
64 bytes from dns.google (8.8.8.8): icmp_seq=4 ttl=117 time=25.5 ms
64 bytes from dns.google (8.8.8.8): icmp_seq=5 ttl=117 time=25.4 ms
64 bytes from dns.google (8.8.8.8): icmp_seq=6 ttl=117 time=33.8 ms
^C
--- dns.google.com ping statistics ---
6 packets transmitted, 6 received, 0% packet loss, time 5007ms
rtt min/avg/max/mdev = 18.555/25.248/33.814/4.491 ms

$ ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=117 time=25.4 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=117 time=20.9 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=117 time=25.4 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=117 time=23.4 ms
64 bytes from 8.8.8.8: icmp_seq=5 ttl=117 time=28.1 ms
64 bytes from 8.8.8.8: icmp_seq=6 ttl=117 time=24.7 ms
64 bytes from 8.8.8.8: icmp_seq=7 ttl=117 time=20.7 ms
^C
--- 8.8.8.8 ping statistics ---
7 packets transmitted, 7 received, 0% packet loss, time 6008ms
rtt min/avg/max/mdev = 20.722/24.148/28.199/2.463 ms

Add dns.google.com to hosts file. 127.0.0.1 dns.google.com

$ ping dns.google.com
PING dns.google.com (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.183 ms
64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.397 ms
64 bytes from localhost (127.0.0.1): icmp_seq=3 ttl=64 time=0.488 ms
64 bytes from localhost (127.0.0.1): icmp_seq=4 ttl=64 time=0.518 ms
64 bytes from localhost (127.0.0.1): icmp_seq=5 ttl=64 time=0.580 ms
^C
--- dns.google.com ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4006ms
rtt min/avg/max/mdev = 0.183/0.433/0.580/0.138 ms

$ ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=117 time=28.4 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=117 time=26.9 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=117 time=22.2 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=117 time=25.2 ms
64 bytes from 8.8.8.8: icmp_seq=5 ttl=117 time=24.1 ms
64 bytes from 8.8.8.8: icmp_seq=6 ttl=117 time=23.8 ms
^C
--- 8.8.8.8 ping statistics ---
6 packets transmitted, 6 received, 0% packet loss, time 5009ms
rtt min/avg/max/mdev = 22.247/25.136/28.443/2.058 ms

Hope that helps explain how the hosts file works.

Cheers. :cowboy:

Edit:

Fixed three bad auto-correct typos.