I'm trying to setup iptables rules on my gateway server to force my kids to use opendns (I've recently discovered that 1 of them has manually is using google DNS instead on his local computer).
Here is my conf in /etc/dhcp/dhcpd.conf:
option domain-name-servers 220.127.116.11, 18.104.22.168;
It's working fine because when an IP is assigned to a local computer, the default DNS server is the 1st OpenDNS entry:
$ nslookup > serverfault.com Server: 22.214.171.124 Address: 126.96.36.199#53 Non-authoritative answer: Name: serverfault.com Address: 188.8.131.52 Name: serverfault.com Address: 184.108.40.206 Name: serverfault.com Address: 220.127.116.11 Name: serverfault.com Address: 18.104.22.168
Now, if I put the following rules on my server:
#allow dns requests to opendns sudo iptables -A OUTPUT -p udp --dport 53 -d 22.214.171.124 -j ACCEPT sudo iptables -A OUTPUT -p udp --dport 53 -d 126.96.36.199 -j ACCEPT #block all other dns requests to other servers sudo iptables -A OUTPUT -p udp --dport 53 -j DROP sudo ip6tables -A OUTPUT -p udp --dport 53 -j DROP
...it's working fine, but only on the server itself, not on the clients. Indeed, clients are still able to use any other DNS servers than the ones from OpenDNS.
I suspect that as I'm performing NAT (gateway router), there is something wrong with the table I'm reaching in iptables.
Can you please help? Many thanks in advance for your support.