No Internet connection after disconnecting from VPN in Ubuntu 18.04
Solution 1
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
Solution 2
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.
Solution 3
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
Solution 4
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.
Related videos on Youtube
Daniel
Updated on September 18, 2022Comments
-
Daniel over 1 year
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 notwww.google.com
hence I'm thinking DNS related issue.A manual solution is to do
$ sudo service network-manager reload
.- What is causing the problem in Ubuntu 18.04, and
- How do we fix it permanently?
-
Val over 5 yearsAdd '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/…
-
HosseinAgha over 5 yearsthe @Val's solution is not working for me. It makes all VPNs to disconnection immediately.
-
Daniel about 4 yearsUpdate: I had to install OpenVPN for unrelated reasons (
$ sudo apt install network-manager-openvpn-gnome
). Going toSettings > 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.
-
Daniele Santi over 5 yearsHello 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. -
Rob Rutten over 4 yearsSame 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.
-
stiv over 4 yearscan i do the same in my ubuntu interface somehow?
-
Alex Rešatniak about 4 yearsThanks, it worked.
-
Kenjiro almost 4 yearsThanks, it worked for as well.
-
razvang over 3 yearsI 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.
-
AmirHossein Rezaei over 3 yearsadding google dns 8.8.8.8 at the first of /etc/resolv.conf solved my problem.