Last active
August 6, 2024 03:32
-
-
Save milankragujevic/12c5c8c96985256915a1cca7768f9646 to your computer and use it in GitHub Desktop.
Hijack DNS on OpenWrt to another DNS server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
iptables -I FORWARD ! -s 192.168.100.242 -p tcp --dport 53 -j ACCEPT | |
iptables -I FORWARD ! -s 192.168.100.242 -p udp --dport 53 -j ACCEPT | |
iptables -t nat -A PREROUTING ! -s 192.168.100.242 -p tcp --dport 53 -j DNAT --to 192.168.100.242:53 | |
iptables -t nat -A PREROUTING ! -s 192.168.100.242 -p udp --dport 53 -j DNAT --to 192.168.100.242:53 | |
iptables -I FORWARD ! -s 192.168.100.242 -p tcp --dport 5353 -j ACCEPT | |
iptables -I FORWARD ! -s 192.168.100.242 -p udp --dport 5353 -j ACCEPT | |
iptables -t nat -A PREROUTING ! -s 192.168.100.242 -p tcp --dport 5353 -j DNAT --to 192.168.100.242:53 | |
iptables -t nat -A PREROUTING ! -s 192.168.100.242 -p udp --dport 5353 -j DNAT --to 192.168.100.242:53 | |
iptables -A FORWARD -p tcp --dport 53 -s 192.168.100.242 -j ACCEPT | |
iptables -A FORWARD -p udp --dport 53 -s 192.168.100.242 -j ACCEPT | |
iptables -t nat -I POSTROUTING ! -s 192.168.100.242 -p udp --dport 53 -d 192.168.100.242 -j MASQUERADE | |
# NOTE: 192.168.100.242 is the IP of the DNS server |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment