OpenVPN connecting but no internet access on Ubuntu 16.04 / 18.04 / 20.04

118,101

Solution 1

i fixed the openvpn no internet issue also

first completely remove openvpn and autoremove after that then add ppa as shown in the link and execute the commands one by one then yu should be good to go .. and if no dns issue add opendns at resolv.conf its 202.67.222.222 and 208.67.220.220 the link

Solution 2

I'm using the gnome network manager with OpenVPN Network Manager plugin.

You can install it with:

sudo apt-get install network-manager-openvpn-gnome

My connection is working fine if I try directly with OpenVPN. But if I try using Network Manager, it works, but no internet access.

To fix this, edit the OpenVPN connection configuration on Network Manager and click in IPv4 Settings tab, then click in Routes button:

IPv4 tab

Then mark Use this connection only for resources on its network.

IPv4 routes

Click Ok, then Save and reconnect.

Solution 3

You can simply solve this issue by turning on your firewall. In Linux Mint, i went to Firewall Configuration and turned on the Firewall. After that I connected VPN and there was no problem. I hope that helps.

Solution 4

I know this is old but I dont have a working solve to this problem from this thread and have a similar problem.

Here is my problem. I downloaded my openVPN keys from my router. installed on Linuxmint Virtual machine and ElementaryOS both Virtual and Host OS on a laptop.. Both versions give the same problem. VPN connects but has absolutely no traffic through it. Enabling "use this connection only for resources on its network" is completely useless and i still don't get access to the vpn network resources anyways. scratch that...

Here is what I did.. I noticed some said when they connected via command line vpn seemed to work. the problem must resides in the fact you can not import the openVPN configuration. so i pulled out my trusty text editor opened the openvpn .conf file. I noticed in the openvpn connection profile it had an "advanced" tab. with lots of various options. So I attempted to translate all the config options into the advanced tab and what do you know... it worked...

[Solve]

So i did it again on the laptop with a different distro.. I changed options One by One this time checking the vpn each time and the vpn started functioning after i configured the compression.

Under Connection Settings VPN > Advanced button > Check Use LZO Data Compression (I set to adaptive) and the tunnel started functioning no issues and "My IP" shows as the vpn router's external IP.

There is no special configs or firewall or anything in my experience. Just need to set all the options the same as the config file and you can use the built in network manager to handle it.

Solution 5

Problem makes routes. To be precise, default route.

First, if you wish to route all traffic trough vpn in NM you do not check option "use this connection only for resources on its network".

Second problem is route about default gw

0.0.0.0 10.211.1.2 128.0.0.0 UG 0 0 0 tun0

Problem can fix with manual adding route or check configuration on vpn server.

To set manual route for all traffic go to tun0 after connecting to vpn put command

ip route add default via ip_address_of_vpn_server

Edit 1

Wait, you can add default route aka default, if you wish traffic go to wlan0 with command

sudo ip route add default via 172.16.156.65

or for traffic routing through vpn

sudo ip route add default via 10.211.1.2

After that you can add more route

Example, if you wont to go to 106.158.15.233 via wlan0

 ip route add 106.158.15.233/32 via 172.16.156.65 dev wlan0

or via vpn

 ip route add 106.158.15.233/32 via 10.211.1.2 dev tun0

172.16.156.65 is address of your wifi router

10.211.1.2 is address of your vpn server

Share:
118,101

Related videos on Youtube

Shantanu Shady
Author by

Shantanu Shady

Updated on September 18, 2022

Comments

  • Shantanu Shady
    Shantanu Shady over 1 year

    I'm trying to connect to a VPN using OpenVPN.

    I tried using network-manager with OpenVPN plugin and tried too in terminal with ovpn.conf file.

    Everything connects (it says connection established) in terminal, but no internet access.

    I can ping anything, not even the gateway of the tunnel.

    Here is what I tried

    I've tried:

    • disable ufw;
    • tried several config files;

    Same result.

    Tried ticked the option under VPN configaration > IPv4> routes > use this connection only for resources on its network. After this, the internet worked again and the VPN shows connected. But my traffic is not encrypted and IP and location still the same. At last, I tried --redirect-gateway option, still no use.

    I'm out of my league now. Please help. Thanks for reading!

  • 2707974
    2707974 almost 9 years
    You have my edit 1
  • Shantanu Shady
    Shantanu Shady almost 9 years
    i added another answer . not working :(
  • 2707974
    2707974 almost 9 years
    And now something completely different. Remove any configuration for vpn, client, config in NM. After that restart pc. This will back us on begining. We will get clear routing table. Try agan with NM. When you connected give me output from route -n.
  • Shantanu Shady
    Shantanu Shady almost 9 years
    did it and gave the output in EDIT 2 thanks for bearing with me .. just cant get internet through vpn and dont want to go back to windows .i should mention again it worked few times rather than that no connectivity
  • 2707974
    2707974 almost 9 years
    Ok, now we are clean. Your wifi router is on 172.16.156.65. Now create connection to vpn server in NM. Go to NM then vpn then add vpn server address, user, pass. If work this is it if not. When you are connected do route -n We must see with route add vpn.
  • Shantanu Shady
    Shantanu Shady almost 9 years
    pptp connected after 2 days of banging my head against the wall .. but openvpn still same routing problem i will let you know . thank you very much for bearing with a newbie like me . i have expalined in EDIT 3 to help anybody who faces this problem . i will let you know openvpn
  • Shantanu Shady
    Shantanu Shady almost 9 years
    hey man i fixed openvpn no internet issue also ... i found threads relating to this matter but never a good solution so i will post it here maybe it shall help someone
  • 2707974
    2707974 almost 9 years
    Great. Will be good to have written solution for this problem
  • SNH
    SNH over 8 years
    This works together with the network-manager-openvpn-gnome package, excellent, thank you!
  • Shantanu Shady
    Shantanu Shady over 8 years
    yup i never found a working thread for this . but nice to know my half assed meddling help somebody . much appreciated man :')
  • Mark
    Mark almost 8 years
    Didn't work for me. Also that file says "DO NOT EDIT THIS FILE BY HAND"
  • ccpizza
    ccpizza almost 8 years
    This is definitely the correct answer.
  • ccpizza
    ccpizza almost 8 years
    If you don't want to route normal traffic through vpn, then there is absolutely no need to install extra ppa's and different builds. The current networkmanager plugin works fine via the GUI: myopenvpn -> Edit -> IPv4 Settings > Routes > enable "Use this connection only for resources on its network". The answer from @Rael should be the accepted one.
  • marts
    marts over 7 years
    This worked for me on 16.04 as well.
  • gammapoint
    gammapoint about 7 years
    While this allows internet access, your internet access won't be encrypted if you do this, correct? I tried this and it was showing my actual IP in browser tests.
  • Rael Gugelmin Cunha
    Rael Gugelmin Cunha about 7 years
    @gammapoint, I'm supposing you're using a VPN to connect to a network that requires a VPN. If this is the case, you're supposed to have your content encrypted only for communications with the VPN network, not for the entire internet. And this should not change your IP with ISP (you'll receive an additional IP for the VPN connection).
  • gammapoint
    gammapoint about 7 years
    Appreciate the response @RaelGugelminCunha. My use of VPN is for personal privacy (using the PIA provider), so having my IP hidden while surfing the web is the primary goal.
  • Gaetano Piazzolla
    Gaetano Piazzolla about 5 years
    worked for me on debian with KDE and default networking GUI, ty very much
  • vipin.huddar
    vipin.huddar almost 5 years
    That checkbox just rescued me from a lot of hassle, even though I'm now on 19.04.
  • Mnemosyne
    Mnemosyne over 4 years
    There is no longer a standalone Network Manager for 18.04. I can only use the default Network Manager interface, and this solution does not work for me. Check that box prohibits me from using the vpn resources but I can go on the normal internet. If I dont check it, I can use the resources behind the vpn but I cant get on the internet.
  • chomp
    chomp about 4 years
    @Mnemosyne same for me, did you find a solution?
  • Mnemosyne
    Mnemosyne about 4 years
    No. As far as I can tell it is an Ubuntu 18.04 issue. There is not one solution for all, Ive tried things that worked for others and didnt work for me.
  • jmon12
    jmon12 over 3 years
    Note that for me it indeed restored the internet connection but broke the domain name resolution of the VPN network (handled by dnsmasq). To solve that I had to explicit the IP of the DNS server of the internal network in the "Other DNS" field of the "IPv4" tab of the VPN connection configuration dialog and restart the connection.
  • NewestStackOverflowUser
    NewestStackOverflowUser over 3 years
    Thank you for the answer!
  • dimisjim
    dimisjim over 3 years
    how can you define this in the .ovpn config file?
  • Emil S.
    Emil S. about 3 years
    @ccpizza The question and OP are deliberately asking for all network traffic to be routed through the VPN. Thus Rael's answer should not be the accepted one here, even if it is what most people who land here are looking for.
  • Musa Haidari
    Musa Haidari almost 3 years
    This works with the default network manager on ubuntu 20.4 as well