Solving DNS problems with OpenVPN on Ubuntu box

Solving DNS problems with OpenVPN on Ubuntu box

I want to share some experiences working with VPN from Ubuntu. I had some trouble using OpenVPN as after connecting I couldn’t access any resource referenced by a domain name.
I couldn’t find any solution to this problem but finally after trying a few things out, I have come out with a solution I want to share below.
Assuming you have OpenVPN installed and working ‘.ovpn’ configuration file (but without proper DNS resolving) follow the steps below:
1. Install resolveconf

sudo apt-get install resolvconf

2. Link your auto-generated resolve.conf to existing ‘/etc/resolve.conf’

cd /etc
#backup your original resolve.conf just in case
cp resolv.con resolv.conf.orig
ln -s /etc/resolvconf/run/resolv.conf /etc/resolv.conf

3. Add the following lines to the bottom of your ‘.ovpn’ configuration file:

up /etc/openvpn/update-resolv-conf
down /etc/openvpn/update-resolv-conf

4. Run openvpn with the following flags (as root):

openvpn --script-security 2 --config youropenvpnconfig.ovpn

That should do it.
Enjoy

6 responses on “Solving DNS problems with OpenVPN on Ubuntu box

  1. Anon June 25, 2011 at 1:31 pm

    thanks a lot! this worked flawless for ubuntu Meerkat.

  2. Anon January 31, 2012 at 8:50 pm

    Worked flawlessly for me on Ubuntu Desktop 11.10 x32

  3. wojtas March 21, 2012 at 7:58 pm

    It really works. Thanks a lot.

  4. dani September 13, 2012 at 6:09 pm

    Just perfect! you are the man!

  5. Satrapes December 21, 2013 at 2:28 am

    You sir are a lifesaver. Thank you very much with all my heart.

  6. Andrew Dick March 6, 2015 at 1:24 pm

    This worked perfectly for me. Thank you.

    There is a typo in step 2:-
    [cp resolv.con resolv.conf.orig] => [cp resolv.CONF resolv.conf.orig]

Leave a Reply

Related Posts

    No Releated Posts