32

In Ubuntu 16.04 I had no problems with VPN: after disconnecting I had Internet.

In Ubuntu 18.04 I have no Internet after disconnecting from the VPN. I can actually ping 8.8.8.8 but not www.google.com hence I'm thinking DNS related issue.

A manual solution is to do $ sudo service network-manager reload.

  1. What is causing the problem in Ubuntu 18.04, and
  2. How do we fix it permanently?
3
  • Add 'dns=dnsmasq' to /etc/NetworkManager/NetworkManager.conf then 'sudo systemctl restart NetworkManager'. Haven't tried it myself. Credit goes to riptag100. privateinternetaccess.com/archive/forum/discussion/28717/…
    – Val
    Dec 3, 2018 at 16:09
  • the @Val's solution is not working for me. It makes all VPNs to disconnection immediately. Jan 30, 2019 at 16:54
  • Update: I had to install OpenVPN for unrelated reasons ($ sudo apt install network-manager-openvpn-gnome). Going to Settings > Network > Add VPN I now have an OpenVPN there as well and using that to set up my VPN no more issues. Can disconnect VPN and have Internet immediately afterwards. For me this was a painless fix.
    – Daniel
    Apr 8, 2020 at 21:02

9 Answers 9

30

It could be related to this bug: https://bugs.launchpad.net/ubuntu/+source/network-manager/+bug/1778946

SOLUTION

Edit the file /etc/ppp/ip-up.d/0000usepeerdns

Replace the following line:

cp -a "$REALRESOLVCONF" "$REALRESOLVCONF.pppd-backup.$PPP_IFACE"

With this code:

cp "$REALRESOLVCONF" "$REALRESOLVCONF.pppd-backup.$PPP_IFACE"
chmod 644 "$REALRESOLVCONF.pppd-backup.$PPP_IFACE"

Restart the network manager:

systemctl restart NetworkManager
5
  • Same or similar problem: after using vpn (Cisco any_connect) I can no longer open pages on the server I used for the vpn; all other sites work. Followed xezpeleta's recipe above but problem stays.
    – Rob Rutten
    Sep 1, 2019 at 8:40
  • can i do the same in my ubuntu interface somehow?
    – stiv
    Dec 18, 2019 at 12:19
  • 1
    Thanks, it worked. Apr 15, 2020 at 15:35
  • Thanks, it worked for as well.
    – Kenjiro
    Jul 24, 2020 at 5:16
  • I am facing similar issue. I disconnect from the VPN (netExtender) and the DNS doesn't work anymore. I have to restart the WiFi. I have edited the file, I replaced the line, but for me it didn't fix the problem.
    – razvang
    Oct 9, 2020 at 10:56
4

Try this, it worked for me.

Disconnect from VPN

sudo rm /etc/resolv.conf
sudo gedit /etc/resolv.conf

add: "nameserver 8.8.8.8" then save

sudo service network-manager reload
4
  • 4
    Hello and welcome to Ask Ubuntu! I don't think hardcoding Google DNS in /etc/resolv.conf is a good idea. What if the OP needs his own DNS while connected to the VPN? Also, please keep in mind that in a "default" Ubuntu installation, resolv.conf gets overwritten automatically at each reboot. Dec 22, 2018 at 13:44
  • adding google dns 8.8.8.8 at the first of /etc/resolv.conf solved my problem. Dec 22, 2020 at 17:07
  • in ubuntu 22.04 for the last step use: sudo systemctl restart NetworkManager
    – Jagar
    Sep 28, 2022 at 6:08
  • yet this works like a charm every time..except it still shows ´disconnected' from nmcli
    – dia
    Dec 1, 2022 at 6:38
2

I had a similar but different problem. When my Debian 4.19.37-5+deb10u1 loaded, it started NordVPN Version 3.2.0-4 . Whenever I disconnected the VPN, I had no internet connection. Though, local network was still accessible and DNS returned the correct IPs when attempting an internet ping. NordVPN would not reconnect. My only option was to reboot.

None of the solutions presented previously worked for me. Not even restarting manually the network manager service.

I had to uninstall (purge) and reinstall NordVPN following those instructions: https://support.nordvpn.com/Connectivity/Linux/1322207652/Troubleshooting-connectivity-of-Linux-app.htm

Now, I can connect and disconnect NordVPN as much as I want and I have internet access as expected in both situations. Still works after reboot.

1

OK, so I faced the same problem. My VPN was connected then I pressed CTRL + ALT + F11 then It went into some kind of sleep mode, and then I had to restart my laptop after long pressing power button. So then my internet and Gs connect stopped working, I uninstalled proton vpn but the problem still persisted, So what I did was just reinstalled protonvpn but how? my internet was not working, so I just entered nameserver 8.8.8.8 and nameserver 8.8.4.4 in my /etc/resolv.conf file and then I didn't reload networkmanager and my internet was working but as soon as I reload networkmanager or restart my laptop, resolv.conf changes to its default and internet stopped working. So I just changed resolv.conf file and then installed protonvpn again and tried connecting it, then I got a error message that you need to disconnect other vpn service or buy premium, So that means after uninstalling it, VPN still was in act somewhere so I just closed protonvpn and ran sudo killall vpn and then systemctl restart NetworkManager and viola my internet and Gs connect were working again!!!.

I just wrote the whole scenario above so that someone with this problem doesn't get confused by complex commands answers.

0
0

The issues is with how to manage the /etc/resolv.conf. I removed manually the nameserver added by VPN client and restarted the NetworkManager.

/etc/resolv.conf before VPN:

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 14.139.5.5
nameserver 8.8.8.8

/etc/resolv.conf after VPN:

nameserver 10.200.4.1
nameserver 10.200.4.1
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 14.139.5.5
nameserver 8.8.8.8

I removed the top 2 nameserver lines and restarted NetworkManager: systemctl restart NetworkManager.

0

you need to kill the process, in terminal run the following:

ps -aux | grep vpn

find your process id:

proccesses

in my case it was 14286

so I ran

sudo kill -9 14286

and, Hola! I can connect to the internet again :)

0

For Ubuntu 20.04

You can try this

sudo edit /etc/ppp/ip-up.d/0000usepeerdns

Replace

cp -a "$REALRESOLVCONF" "$REALRESOLVCONF.pppd-backup.$PPP_IFACE"

with

cp -a "$REALRESOLVCONF" "$REALRESOLVCONF.pppd-backup.$PPP_IFACE" || {
        rm -f "$REALRESOLVCONF.pppd-backup.$PPP_IFACE" "$REALRESOLVCONF.tmp"
        exit 1
    }

Then restart your network manager

0

I always had some Internet interruption when using FortiClient VPN. A solution that always works for me :

  • Go to your wifi settings
  • Click on the settings of your connection
  • Click on 'Forget the connection'

Then all I have to do is reconnect to this network (and type the password, hum...) and Internet is back

0

For expressVPN you can:

  • Disconnect from vpn:

    expressvpn disconnect

  • Run:

    expressvpn preferences set network_lock off

    sudo systemctl restart NetworkManager

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.