On my Android-based device I need to block access to all websites except ones are in a whitelist. I know that on desktop Windows I can list allowed hosts in the hosts file and then switch the DNS in the network adapter from automatically obtained to
127.0.0.1. And now I can access only websites from the hosts file.
I've tried the same thing by adding allowed hosts in the
system/etc/hosts file on Android and then I've added the line
to the beggining of the file
/etc/dhcpcd/dhcpcd-hooks/20-dns.conf as described by the link.
And then I've restarted my device.
But I still can access all websites, so the solution doesn't work. And even if I just add a website to be resolved as 127.0.0.1 in the hosts file and clear browser cache, the website is still opened.
PS: I'm interested only in a solution which could be done on rooted device only (Android 4.0.4)