hanki.dev

block websites on phone with custom dns

On desktop, I've been blocking unwanted websites by modifying hosts file. Unfortunately this is impossible to do on Android without root, and since I don't want any extra apps, I've been using NextDNS for this. Work great and is free!

When you create a profile you get your custom DNS address, you can configure list of domains you don't want to visit. It also blocks ads & trackers which is nice.

NextDNS Denylist example NextDNS Denylist
NextDNS analytics example NextDNS analytics

I've noticed no difference in speed (even if my network slowed down that's okay since I'm trying to spend as little time as possible on it). The free tier has 300,000 queries/month which has been more than enough to tackle my phone usage.

How to setup (Android)

  1. Sign up
  2. Go to Denylist → add sites you want to block
  3. Modify other privacy settings if needed
  4. Android: Settings → Network & internet → Advanced → Private DNS
  5. 'Private DNS provider hostname'
  6. Enter <ID>.dns.nextdns.io

Android: automatically change back to private DNS after disabling

Sometimes I go to settings and disable the private DNS if I really "need" to check some reddit post or something similar, lol. I've set up Tasker to change back to using private DNS every midnight in case I've disabled it.

  1. Add task to turn private DNS on
    1. Tasks → New → "Private DNS on"
    2. Add action: Setings → Custom Setting
    3. Name: private_dns_mode
    4. Value: hostname
    5. Save
  2. Create profile to trigger above action every day
    1. Profiles → New → Time
    2. "From" time to 00:00 (or whatever you prefer)
    3. Click "To" button to disable the second time, we don't need it
    4. Add earlier created "Private DNS on" task to this profile
    5. Save

Tada, now if you ever disable private DNS, it will get turned back on every day at midnight.


✌🏼 Like my content? Subscribe via RSS feed.