Skip to content

Instantly share code, notes, and snippets.

@zoonderkins
Last active February 16, 2019 13:53
Show Gist options
  • Save zoonderkins/439c1fa9336420780793b7f52a0223cc to your computer and use it in GitHub Desktop.
Save zoonderkins/439c1fa9336420780793b7f52a0223cc to your computer and use it in GitHub Desktop.
Reroute local DNS to your custom DNS #linux
iptables -t nat -A PREROUTING -i eth0 -p udp ! --source 192.168.2.196 ! --destination 192.168.2.196 --dport 53 -j DNAT --to 192.168.2.196

iptables -t nat -A PREROUTING -i eth0 -p tcp ! --source 192.168.2.196 ! --destination 192.168.2.196 --dport 53 -j DNAT --to 192.168.2.196

or 

iptables -t nat -I PREROUTING -i br-lan -p tcp --dport 53 -j DNAT --to 192.168.2.4:53
iptables -t nat -I PREROUTING -i br-lan -p udp --dport 53 -j DNAT --to 192.168.2.4:53

iptables -t nat -I PREROUTING -i br-lan -p tcp -s 192.168.2.4 --dport 53 -j ACCEPT
iptables -t nat -I PREROUTING -i br-lan -p udp -s 192.168.2.4 --dport 53 -j ACCEPT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment