How to change dns on mobile network

Setting DNS server with connmanctl still seems to be possible, but the configuration will get lost on every network change.

Instead I use (Quad9 example)

iptables -t nat -A OUTPUT -p  udp -d 127.0.0.1 --dport 53 -j ACCEPT
iptables -t nat -A OUTPUT -p  udp ! -d 9.9.9.9 --dport 53 -j DNAT --to 9.9.9.9

Problems here:

  • Only UDP here, but size-exceeded should not be a problem for only A or AAAA. TCP can be added if needed.
  • Does not work with DoH, DoT.
  • Might cause problems in walled gardens where external DNS is blocked but not redirected.
1 Like