Connected to openvpn, but no Internet connection

Solution 1:

I checked your logs and haven't find any problems. But you said that there is No firewall on the server. It could cause problems, because you should enable forwarding for working NAT. Here is output from guide.


In order to configure your ufw settings for VPN traffic first add the following to /etc/default/ufw:


Now change /etc/ufw/before.rules, and add the following code after the header and before the "*filter" line. Do not forget to change the IP/subnet mask to match the one in /etc/openvpn/server/server.conf. The adapter ID in the example is generically called eth0 so edit it for your system accordingly.


# NAT (Network Address Translation) table rules

# Allow traffic from clients to eth0

# do not delete the "COMMIT" line or the NAT table rules above will not be processed

Open OpenVPN port 1194:

# ufw allow 1194

Lastly, reload UFW:

# ufw reload


In order to allow VPN traffic through your iptables firewall of your server, first create an iptables rule for NAT forwarding [3] on the server, assuming the interface you want to forward to is named eth0:

iptables -t nat -A POSTROUTING -s -o eth0 -j MASQUERADE

And don't forget to enable forwarding in sysctl

sysctl -w net.ipv4.ip_forward=1

Solution 2:

When you create a VPN connection between your client and VPN server, a private network is formed between the two, with address starting with 192.168.x.x, 10.x.x.x or 172.16.x.x.

When you want to route traffic from the VPN client to the global Internet, you must use NAT on the server so that it translates the VPN client's private network address to the server's public IP address.

This is independent of the fact that your client's connection is behind NAT or not.

So, in addition to installing the VPN software, you need to add firewall rules for NAT in your server.