OpenVPN Client connects, but DNS setting are not correct (cannot resolve domain names)

5,702

The interface settings are fairly unimportant. Instead - look in /etc/resolv.conf

The OpenVPN client should write this content on connection

nameserver 8.8.8.8
nameserver 8.8.4.4

and restore your original nameservers on exit.

Share:
5,702

Related videos on Youtube

vishwa
Author by

vishwa

Updated on September 18, 2022

Comments

  • vishwa
    vishwa over 1 year

    I've an active subscription with VPNUnlimited, and they have sent a few settings in order to be able to use OpenVPN client with their service. (they have sent me pre-made .ovpn files for each of their servers)

    the thing is, I've followed a tutorial to setup OpenVPN in my raspberry pi, and whenever I start the OpenVPN client with the .ovpn file, it authenticate and connects successfully.

    this looks great but the problem is after a successfull connection, it looks like DNS configuration is not correct as any trial to navigate/ping any domain name fails, although pinging any IP is succeeded, so it's normally state that there is a DNS problem.

    disconnecting the session will restore back the ability to resolve domain names normally and use the built-in web browser to browse websites.

    I've searched for a while and found that one possible fix is to add the following line (provided from this question) to the client.conf file in order to force the client to use Google DNS:

    dhcp-option DNS 8.8.8.8

    but unfortunately it's not working.

    this is what is on my screen as a result on connecting to openvpn: enter image description here

    and this is the ifconfig after the connection is established: enter image description here

    and this is the ifconfig result when I disconnect the OpenVPN client: enter image description here

    I hope I could clarify the situation, and if anyone can help me to setup the proper configuration to make my raspberry pi use google DNS (or anything that would work) I would much appreciate it as I can't figure it out yet.

  • Criggie
    Criggie over 7 years
    @MohammedElSayed perhaps you have some other DNS resolver on the local machine. Please post the content of /etc/resolv.conf with and without the VPN connected.
  • vishwa
    vishwa over 7 years
    Actually the problem was that the contents of the file was not changing when the VPn connects, and when I change the DNS to 8.8.8.8 in the resolv.conf file, it solved the problem of DNS not resolving, but also not changing between VPN sessions. I really appreciate your answer :)
  • Criggie
    Criggie over 7 years
    Are you establishing the VPN as root ? You might need to tweak permissions to allow a the VPN / non-root user to edit the resolv.conf file.
  • vishwa
    vishwa over 7 years
    I'm establishing it as root.