Change DNS when connected to VPN

I fixed it I fixed it, woohoo!!! Or rather I found a workaround…the trick is to make a copy of resolv.conf in the script and then restore it upon OpenVPN exit as found at the bottom of https://forums.openvpn.net/topic15508.html

cp /etc/resolv.conf /etc/resolv.conf.default
#echo -n “$R” | $RESOLVCONF -p -a “${dev}”
echo -n “$R” | $RESOLVCONF -a “${dev}.inet”
;;
down)
$RESOLVCONF -d “${dev}.inet”
mv -f /etc/resolv.conf.default /etc/resolv.conf
;;
esac

Funnily enough my swiss cheese brain seems to have an inkling somewhere that I may have had to do it back in the raspbmc days too…

Oh well thanks for your patience tonight Sam…and if any OpenVPN users want to hide their DNS leaks, well loads of info in this thread, so it hasn’t all been useless… :wink:

1 Like