2

I recently installed Ubuntu 18.04. I set up a VPN through the standard Settings->Network GUI. I can connect to the VPN with no problems, but when I disconnect the VPN I cannot access the internet through my web browser. I can, however, ping an internet address from a shell window.

My /etc/resolv.conf file is a symlink to /run/systemd/resolve/stub-resolv.conf.

Before I connect to the VPN, the permissions/ownership are as follows:

-rw-r--r-- 1 systemd-resolve systemd-resolve 701 Jun 20 20:28 /run/systemd/resolve/stub-resolv.conf

While I am connected to the VPN these permissions stay the same, but when I disconnect, the read permissions are dropped and the ownership changes to root:root, like this:

-rw------- 1 root root 701 Jun 20 20:31 /run/systemd/resolve/stub-resolv.conf

It seems that because of this, my web browser cannot read the resolv.conf file and thus does not know what nameserver to use

If I chmod a+r this file, I can access the internet fine, even though the ownership is still root:root.

Does anyone have any idea what is happening here and how it could be fixed without manually changing permissions of the resolv file every time I disconnect the VPN?

  • The VPN modifies resolv.conf with the DNS server address from the VPN provider, and then changes it back when disconnected. You may have added an incorrect OpenVPN command to your VPN script file. – heynnema Jun 21 '18 at 13:37
0

Update: I added a script in the /etc/network/if-post-down.d directory that just changes the permissions/ownership of the stub-resolv.conf file when the VPN disconnects.

if [ "$IFACE" = ppp0 ]; then
    chmod a+r /run/systemd/resolve/stub-resolv.conf
    chown systemd-resolve:systemd-resolve /run/systemd/resolve/stub-resolv.conf
fi

That seems to work for now.

0

I have the same issue. Maybe it is a bug. But I use NetworkManager. This solution does not work with it. The script does not run. I add my solution for it.

The NetworkManager has similar solution. The script must be added to the directory:

/etc/NetworkManager/dispatcher.d

I have added this file: "02-fix-resolv.conf.sh":

#!/bin/sh
if [ "$1" = "ppp0" -a "$2" = "vpn-up" ]; then
  echo "bleeeeeee je dole" > /tmp/testjenahore.txt
  chmod a+r /run/systemd/resolve/stub-resolv.conf.pppd-backup.ppp0
  chown systemd-resolve:systemd-resolve /run/systemd/resolve/stub-resolv.conf.pppd-backup.ppp0
fi

It works for me. And I finded out, that the file "/run/systemd/resolve/stub-resolv.conf.pppd-backup.ppp0" has permission and owner badly. And my script fix permission and awner, when the VPN goes UP. Then it works too if the VPN goes DOWN.

0

For network-manager-pptp or network-manager-l2tp, the actual fix is to install the resolvconf package:

sudo apt install resolvconf

The resolvconf package makes sure NetworkManager does the /etc/resolv.conf handling, extract from /etc/ppp/ip-up.d/000resolvconf :

[ -x /sbin/resolvconf ] || exit 0

[ "$USEPEERDNS" ] || exit 0

case "$6" in
  nm-pptp-service-*|nm-l2tp-service-*|/org/freedesktop/NetworkManager/PPP/*)
    # NetworkManager handles it
    exit 0
    ;;
esac

See Ubuntu LP bug#1778946 for more details.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.