I have an Ubuntu server running openvpn, and iptables is used to push all incoming traffic through the vpn server. The IP tables config is very basic, and generated with the following series of commands:
sudo iptables --flush
sudo iptables --table nat --flush
sudo iptables --delete-chain
sudo iptables --table nat --delete-chain
sudo iptables --table nat --append POSTROUTING --out-interface tun0 -j MASQUERADE
sudo iptables --append FORWARD --in-interface eth0 -j ACCEPT
I have been trying to rewrite traffic to force the use of a specific dns server by adding the following two lines:
sudo iptables --table nat --append PREROUTING -i eth0 -p tcp --sport 53 -j DNAT --to-destination 146.148.119.121:53
sudo iptables --table nat --append PREROUTING -i eth0 -p udp --sport 53 -j DNAT --to-destination 146.148.119.121:53
but it's not working as I had hoped (the output of nslookup www.netflix.com and nslookup www.netflix.com 8.8.8.8 are different).
Any advice for how to achieve this?