[HOWTO] Build hosts add blocker into your ROM

  • Find a good hosts file, like here
  • append the file above to /srv/src/PIE/system/core/rootdir/etc/hosts
  • Make sure you don’t overwrite and ::1
  • Build your ROM and now the hosts file will block a lot of adds and trackers. Now you can do this also with existing ROM’s, remount system and replace hosts file (/etc/hosts).
1 Like

I’m a little confused.

  1. If it is so easy to setup IP blocker, why isn’t it integrated in standard.
  2. I have tried to block these domains www.play.googleapis.com www.google.com play.googleapis.com google.com www.connectivitycheck.gstatic.com connectivitycheck.gstatic.com

it works when using the addresses in browser. But my pi-hole shows me theses connection which are called from system direct. There the hosts file isn’t working :frowning:

As in every OS, use of hosts file is not mandatory.
If the program calls system API (such as GetHostByName() with a “use hosts first” policy), it will work.

But if the program has it’s own DNS mechanisms it won’t use the hosts file.
For example the “proxy DNS” found in some browsers when using HTTP proxy (redirects DNS requests through HTTP proxy) has been proven to ignore hosts file.

I’ve posted an answer regarding host file blocking in a previous thread about more or less the same topic.