Sample Header Ad - 728x90

Redirect all outgoing DNS queries to local stub resolver at 127.0.0.1:53

2 votes
1 answer
3966 views
I am attempting to redirect all outgoing DNS queries on my Linux box to my local caching stub resolver (unbound). iptables -t nat -A OUTPUT -p tcp --dport 53 -j DNAT --to 1.1.1.1:53 iptables -t nat -A OUTPUT -p udp --dport 53 -j DNAT --to 1.1.1.1:53 iptables -t nat -A POSTROUTING -j MASQUERADE When I use the above rules, all the outgoing DNS queries are intercepted and redirected to the DNS server at 1.1.1.1 However, if I replace the '1.1.1.1' with '127.0.0.1', all DNS queries fail and are not directed to my local stub resolver. I did pass the below sysctl parameter sysctl -w net.ipv4.conf.eth0.route_localnet=1 but my problem remained the same. Any pointers?
Asked by donghakim187 (61 rep)
Apr 5, 2019, 06:36 PM
Last activity: Apr 5, 2019, 09:35 PM