Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
OpenVPN not updating /etc/resolv.conf
View unanswered posts
View posts from last 24 hours

Goto page 1, 2  Next  
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
LinuxDigger
n00b
n00b


Joined: 23 Jan 2021
Posts: 16

PostPosted: Mon Feb 08, 2021 2:05 pm    Post subject: OpenVPN not updating /etc/resolv.conf Reply with quote

Hi. I have installed OpenVPN on my system and trying to connect to ProtonVPN. I have update-resolv-conf and configured it according to the instructions given in it's GitHub repo. But, it didn't work and my system isn't updating resolv.conf and using proton's DNS server, What should I do?
Back to top
View user's profile Send private message
alamahant
Advocate
Advocate


Joined: 23 Mar 2019
Posts: 3948

PostPosted: Mon Feb 08, 2021 5:43 pm    Post subject: Reply with quote

Isnt it supposed to do so?
Which dns would you like it to use?
Did Proton provide any .ovpn file for connecting to them?
Can you post it?
What is the problem exactly?
Can you pkease be more specific?
Ah you mean it keeps using proton dns AFTER disconnecting from proton?
Have you installed "openresolv"?
_________________
:)
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 23062

PostPosted: Mon Feb 08, 2021 6:15 pm    Post subject: Reply with quote

I think OP is trying to say that the system continues to use the non-VPN resolv.conf even when connected to the VPN, and he considers this undesirable. He wants to switch to DNS servers pushed by the VPN provider, but no such switch happens.
Back to top
View user's profile Send private message
Anon-E-moose
Watchman
Watchman


Joined: 23 May 2008
Posts: 6208
Location: Dallas area

PostPosted: Mon Feb 08, 2021 6:35 pm    Post subject: Reply with quote

How are you determining that its not using your vpn's dns server?
_________________
UM780, 6.12 zen kernel, gcc 13, openrc, wayland
Back to top
View user's profile Send private message
alamahant
Advocate
Advocate


Joined: 23 Mar 2019
Posts: 3948

PostPosted: Mon Feb 08, 2021 6:36 pm    Post subject: Reply with quote

I think he doesnt see a modifiied resolv.conf.
_________________
:)
Back to top
View user's profile Send private message
LinuxDigger
n00b
n00b


Joined: 23 Jan 2021
Posts: 16

PostPosted: Mon Feb 08, 2021 6:41 pm    Post subject: Reply with quote

Hu wrote:
I think OP is trying to say that the system continues to use the non-VPN resolv.conf even when connected to the VPN, and he considers this undesirable. He wants to switch to DNS servers pushed by the VPN provider, but no such switch happens.


You have exactly said what I wanted to mean.
Back to top
View user's profile Send private message
LinuxDigger
n00b
n00b


Joined: 23 Jan 2021
Posts: 16

PostPosted: Mon Feb 08, 2021 6:42 pm    Post subject: Reply with quote

Anon-E-moose wrote:
How are you determining that its not using your vpn's dns server?


I see an unchanged resolv.conf file and testing with sites like ipleak.net or dnsleaktest.com
Back to top
View user's profile Send private message
alamahant
Advocate
Advocate


Joined: 23 Mar 2019
Posts: 3948

PostPosted: Mon Feb 08, 2021 7:05 pm    Post subject: Reply with quote

Do you have a proton .ovpn file?
Can you plz post it?
_________________
:)
Back to top
View user's profile Send private message
pa4wdh
l33t
l33t


Joined: 16 Dec 2005
Posts: 910

PostPosted: Tue Feb 09, 2021 12:40 pm    Post subject: Reply with quote

OpenVPN does not change your DNS settings by itself. If you want it to update your DNS you should use up/down scripts to modify your DNS, the gentoo openvpn package provides /etc/openvpn/up.sh and /etc/openvpn/down.sh for that. In your openvpn configuration you should have statements like this:
Code:

up /etc/openvpn/up.sh
down /etc/openvpn/down.sh

Does your ovpn file have that?
_________________
The gentoo way of bringing peace to the world:
USE="-war" emerge --newuse @world

My shared code repository: https://code.pa4wdh.nl.eu.org
Music, Free as in Freedom: https://www.jamendo.com
Back to top
View user's profile Send private message
LinuxDigger
n00b
n00b


Joined: 23 Jan 2021
Posts: 16

PostPosted: Tue Feb 09, 2021 12:59 pm    Post subject: Reply with quote

pa4wdh wrote:
OpenVPN does not change your DNS settings by itself. If you want it to update your DNS you should use up/down scripts to modify your DNS, the gentoo openvpn package provides /etc/openvpn/up.sh and /etc/openvpn/down.sh for that. In your openvpn configuration you should have statements like this:
Code:

up /etc/openvpn/up.sh
down /etc/openvpn/down.sh

Does your ovpn file have that?


I am using update-resolv-conf script. My. ovpn has the following
Code:

script-security 2
up /etc/openvpn/update-resolv-conf
down /etc/openvpn/update-resolv-conf
Back to top
View user's profile Send private message
tld
Veteran
Veteran


Joined: 09 Dec 2003
Posts: 1850

PostPosted: Tue Feb 09, 2021 1:00 pm    Post subject: Reply with quote

Have you checked to see if PEER_DNS is set to "yes" in /etc/conf.d/openvpn?:
Code:
cat /etc/conf.d/openvpn
# OpenVPN automatically creates an /etc/resolv.conf (or sends it to
# resolvconf) if given DNS information by the OpenVPN server.
# Set PEER_DNS="no" to stop this.
PEER_DNS="no"
...etc...
A "yes" setting is actually the default. In my case above I expressly wanted it set to "no".

Tom
Back to top
View user's profile Send private message
LinuxDigger
n00b
n00b


Joined: 23 Jan 2021
Posts: 16

PostPosted: Tue Feb 09, 2021 1:05 pm    Post subject: Reply with quote

tld wrote:
Have you checked to see if PEER_DNS is set to "yes" in /etc/conf.d/openvpn?:
Code:
cat /etc/conf.d/openvpn
# OpenVPN automatically creates an /etc/resolv.conf (or sends it to
# resolvconf) if given DNS information by the OpenVPN server.
# Set PEER_DNS="no" to stop this.
PEER_DNS="no"
...etc...
A "yes" setting is actually the default. In my case above I expressly wanted it set to "no".

Tom


i have it set to yes.
Back to top
View user's profile Send private message
alamahant
Advocate
Advocate


Joined: 23 Mar 2019
Posts: 3948

PostPosted: Tue Feb 09, 2021 1:11 pm    Post subject: Reply with quote

do you have openresolv or resolvconf installed?
_________________
:)
Back to top
View user's profile Send private message
LinuxDigger
n00b
n00b


Joined: 23 Jan 2021
Posts: 16

PostPosted: Tue Feb 09, 2021 1:13 pm    Post subject: Reply with quote

alamahant wrote:
do you have openresolv or resolvconf installed?


Yes, I have openresolv installed.
Back to top
View user's profile Send private message
LinuxDigger
n00b
n00b


Joined: 23 Jan 2021
Posts: 16

PostPosted: Tue Feb 09, 2021 1:44 pm    Post subject: Reply with quote

pa4wdh wrote:
OpenVPN does not change your DNS settings by itself. If you want it to update your DNS you should use up/down scripts to modify your DNS, the gentoo openvpn package provides /etc/openvpn/up.sh and /etc/openvpn/down.sh for that. In your openvpn configuration you should have statements like this:
Code:

up /etc/openvpn/up.sh
down /etc/openvpn/down.sh

Does your ovpn file have that?


How to use those scripts? Is it enough to put those two lines?
Back to top
View user's profile Send private message
alamahant
Advocate
Advocate


Joined: 23 Mar 2019
Posts: 3948

PostPosted: Tue Feb 09, 2021 1:47 pm    Post subject: Reply with quote

Maybe try to put them in the .ovpn file provided by proton.
Did proton provide you with a .ovpn file?
It must have.
_________________
:)
Back to top
View user's profile Send private message
LinuxDigger
n00b
n00b


Joined: 23 Jan 2021
Posts: 16

PostPosted: Tue Feb 09, 2021 1:57 pm    Post subject: Reply with quote

alamahant wrote:
Maybe try to put them in the .ovpn file provided by proton.
Did proton provide you with a .ovpn file?
It must have.


Yes, and I put those two lines. Still, no results.
Back to top
View user's profile Send private message
alamahant
Advocate
Advocate


Joined: 23 Mar 2019
Posts: 3948

PostPosted: Tue Feb 09, 2021 1:59 pm    Post subject: Reply with quote

How do you connet to proton?
Do you use something
like
Code:

openvpn --config /path/to/proton/ovpn
[quote]
[/quote]

_________________
:)
Back to top
View user's profile Send private message
LinuxDigger
n00b
n00b


Joined: 23 Jan 2021
Posts: 16

PostPosted: Tue Feb 09, 2021 2:01 pm    Post subject: Reply with quote

alamahant wrote:
How do you connet to proton?
Do you use something
like
Code:

openvpn --config /path/to/proton/ovpn
[quote]
[/quote]


Code:
sudo openvpn /path/to/proton.ovpn
Back to top
View user's profile Send private message
alamahant
Advocate
Advocate


Joined: 23 Mar 2019
Posts: 3948

PostPosted: Tue Feb 09, 2021 2:03 pm    Post subject: Reply with quote

please append
--config
Do you see
Code:

Initialization Sequence Completed

in the terminal when running the above?
Also try running the above command as pure root.
_________________
:)


Last edited by alamahant on Tue Feb 09, 2021 2:05 pm; edited 1 time in total
Back to top
View user's profile Send private message
LinuxDigger
n00b
n00b


Joined: 23 Jan 2021
Posts: 16

PostPosted: Tue Feb 09, 2021 2:04 pm    Post subject: Reply with quote

alamahant wrote:
please append
--config
Do you see
Code:

Initialization Sequence Completed

in the terminal when running the above?


Yes, I see that. Let me try with --config.
Back to top
View user's profile Send private message
alamahant
Advocate
Advocate


Joined: 23 Mar 2019
Posts: 3948

PostPosted: Tue Feb 09, 2021 2:07 pm    Post subject: Reply with quote

Also please after connecting open a browser and go to one of these pages that tell you your external ip.
Is it different than when not running the vpn script?
_________________
:)
Back to top
View user's profile Send private message
LinuxDigger
n00b
n00b


Joined: 23 Jan 2021
Posts: 16

PostPosted: Tue Feb 09, 2021 2:08 pm    Post subject: Reply with quote

alamahant wrote:
Also please after connecting open a browser and go to one of these pages that tell you your external ip.
Is it different than when not running the vpn script?


IP address is ok. But, dns server isn't. Didn't work also with --config.
Back to top
View user's profile Send private message
mvaterlaus
Apprentice
Apprentice


Joined: 01 Oct 2010
Posts: 237
Location: Switzerland

PostPosted: Tue Feb 09, 2021 2:20 pm    Post subject: Reply with quote

Hi,
i'm using the following line in my openvpn Config File:

Code:

...
dhcp-option DNS xxx.xxx.xxx.xxx


This is only useful, if you know the IP Address of the DNS server provided by ProtonVPN.
_________________
For calming down your eyes or clearing your mind: www.patrickwehli.ch
Back to top
View user's profile Send private message
alamahant
Advocate
Advocate


Joined: 23 Mar 2019
Posts: 3948

PostPosted: Tue Feb 09, 2021 2:21 pm    Post subject: Reply with quote

Have you tried with
up /etc/openvpn/update-resolv-conf
down /etc/openvpn/update-resolv-conf

If everything else fails you will have to write a minimal bash script to do this for you.

Code:

sed -i '/nameserver/d' /etc/resolv.conf
echo "nameserver <your proton name server>" >> /etc/resolv.conf
openvpn --config proton.ovpn
trap "sed -i '/nameserver/d' /etc/resolv.conf;echo 'nameserver <your-normal name server>' >> /etc/resolv.conf" SIGINT

Then building on the concept you can make it polished end expanded
_________________
:)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum