Jump to content
  • 0

DNS leaks command line

Rate this question



Here is a simple set of scripts I use to keep dns requests from leaking on Ubuntu 17.10 but should work on any linux distribution.

An older fix which doesn't work on my system was to do the following

append the following lines to the .opvn file so openvpn can edit the /etc/resolv.conf file

script-security 2
up /etc/openvpn/update-resolv.conf
down /etc/openvpn/update-resolv.conf


The solution is I use 2 simple scripts to write the resolv.conf file from elsewhere and put it back to way it was when the connection is closed

First I create a secondary resolv.conf.bk with the following entries

#nameservers for torguard VPN


then I create the scripts saving them in /etc/openvpn and make them executables.


# replace /etc/resolv.conf to fix torguard dns leak
mv /etc/resolv.conf /etc/resolv.conf.bak
cp /etc/resolv.conf.bk /etc/resolv.conf


# restore original /etc/resolv/conf
rm /etc/resolv.conf
mv /etc/resolv.conf.bak /etc/resolv.conf

sudo chmod +x resolv_on.sh
sudo chmod +x resolv_off.sh

Finally the .opvn files needs the following lines added.

script-security 2
up /etc/openvpn/resolv_on.sh
down /etc/openvpn/resolv_off.sh

No more dns leaks when running openvpn from the command line.


Link to comment
Share on other sites

1 answer to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...