Recently I switched to OpenWRT as my gateway to the Internet. It has been a great pleasure. Stock firmware of routers just sucks. With OpenWRT, I can ssh into it, install packages, a nice web interface, the configuration makes sense, super smooth and quick, ad blocking, VPN, so on and on.
I just added adblock to my router yesterday, here are the commands of the process:
# Install packages
opkg update
opkg install adblock
# Provide web interface
opkg install luci-app-adblock
# Backup the blocklists
uci set adblock.global.adb_backupdir="/etc/adblock"
# Save and apply
uci commit adblock
/etc/init.d/adblock restart
You can read more about it here
The default configuration should cost about 6M RAM (with "DNS Report" turned on) and less than 1M disk space. In my situation this is fine, you should check your router's ram and disk before applying these commands.
You can turn on "DNS Report" on the Luci web. I like to analyze the performance and result so I turned it on.
However, using DNS to block ads is inefficient and prone to be bypassed. For example, the apps on your phone can use their DNS server, or use DNS-over-HTTPS, to bypass it. Not much can be done to DNS-over-HTTPS and doh is becoming more and more common. The ecosystem of mobile phones is pretty toxic. Personally, I prefer using browsers, even on my phone. Blocking ads on mobile browsers is another story.