OpenWRT + SafeSearch

I’ve got an OpenWRT router, and here’s how I configured it to enable safesearch on my home network.

Update May, 2022: Not recommended. I upgraded my router to OpenWRT 21.02.3 and suddenly, all searches through google, bing, and duckduckgo stopped working. At first, I thought it was cloudflare’s 1.1.1.3 DNS that was broken, but I was wrong. Once I removed the cname entries from my router and restarted dnsmasq, searches started working again.

uci add dhcp cname
uci set dhcp.@cname[-1].cname="www.google.com"
uci set dhcp.@cname[-1].target="forcesafesearch.google.com"
uci commit dhcp

uci add dhcp cname
uci set dhcp.@cname[-1].cname="www.bing.com"
uci set dhcp.@cname[-1].target="strict.bing.com"
uci commit dhcp

uci add dhcp cname
uci set dhcp.@cname[-1].cname="duckduckgo.com"
uci set dhcp.@cname[-1].target="safe.duckduckgo.com"
uci commit dhcp

for name in www.youtube.com m.youtube.com youtubei.googleapis.com youtube.googleapis.com www.youtube-nocookie.com ; do
    uci add dhcp cname
    uci set dhcp.@cname[-1].cname="$name"
    uci set dhcp.@cname[-1].target="restrict.youtube.com"
    uci commit dhcp
done

service dnsmasq restart

See the configuration:

grep -A2 cname /etc/config/dhcp