I'm trying to use Google Compute Engine server as VPN server for all my traffic (I'm living in Russia, we have some issues with censorship here).
There is mini-tutorial about VPN on GCE, but it's about network between 2 servers inside GCE and not with OpenVPN.
I've made all steps from another tutorial, about setting up VPN with OpenVPN on Debian, I can connect to VPN from client, but then I can't open connections (can't even ping google). On the server I can ping and download everything as usual.
I have VPN on Linode with same setup and it works fine. So issue is in GCE network routing or firewall rules.
I've tried a lot of variants but nothing works. Please, look at settings and tell me what should I change.
// config lines removed, because issue is solved //
You can solve the issue of not being able to browse the web through the VPN despite being able to ping, traceroute... by one of the two following ways:
First, you can use TCP protocol instead of UDP, by changing 'proto udp' to 'proto tcp' in both client and server conf files.
Second, you can use tap device instead of tun, by changing 'dev tun' to 'dev tap' in both client and server conf files.
Not sure what the issue is though, it seems it's a problem from Google's end.
First of all, thanks to @Shivox for his answer.
And here is the quick how-to:
sudo su
apt-key update && apt-get update && apt-get -y upgrade && apt-get -y install python-software-properties && apt-get -y install software-properties-common && add-apt-repository -y ppa:pritunl && apt-get update && apt-get -y install pritunl
https://instance_ip:9700
pritunl
as username and passwordI use Viscosity for OS X and OpenVPN connect for iOS as clients. In Viscosity, turn on "Send all traffic over VPN connection" option in "Networking" tab.
Please remember that Google VPC is dropping packets that has
source_ip
other than an internal IP of a VM having external IP.This doc https://cloud.google.com/compute/docs/vpc/advanced-vpc states:
So if your openVPN is just forwarding packets from the other network, then the packets to public internal will be dropped as
source_ip
does not match any existing VM's internal IP. For this reason you need to NAT the packets leaving your local network, e.g on your VPN node."Pritunl" mentioned in the OZ_ answer works, because it configures the NAT automatically.
This is not really an answer, but the site didn't allow me to add it as a comment to your question.
Nevertheless, I have almost the exact same configuration you detailed above (I didn't configure the dnsmaq on the server tough)
Unfortunately, The VPN is not working as expected. I can resolve an address, ping some Internet hosts and even make a complete trace while connected to the VPN. However when I open the browser and navigate to a site, the connection is really slow. I don't know what can be affecting the connection, but is really a strange problem.
Maybe someone from Google can help us know what is going on.
PS 1. As other people has suggested before, can you verify if ip forwarding is enable? For me, the only way to ensure the value for net.ipv4.ip_forward was properly restored after a reboot was after I used a custom rule on /etc/sysctl.d
For example, you can add the rule using the following command:
PS 2. If the forward works for you, can you test a trace route to a external host while connected to the VPN?. The output I got when I do this is a bit strange (Why there are multiple hops on the same IP ????):
PS 3. The only thing that seems to work properly is the VPN is using the external IP from my host to access the Internet
Edit
/etc/sysctl.conf
by uncommenting#net.ipv4.ip_forward=1
That should allow OpenVPN to direct your traffic.
You need IP forwarding enabled for your VM instance in google cloud, otherwise packets won't reach your VM. Note, this is separate from
net.ipv4.ip_forward = 1
that you can set in your VM.IP forwarding can only be set once before you create a VM, and cannot be modified afterwards. To enable it for a new VM click
Management, security, disks, networking, sole tenancy
:Then, in
Networking
tab click onNetwork Interface
and set IP Forwarding toON
:You need to add rule that allow traffic for OpenVPN itself:
About the Network.
1) Enable all traffic from OpenVPN Subnet (e.g. 10.8.0.0/24) at Console
2) I would strongly suggest You to add Masquerade to Your network
3) Do not forget to enable packet routing in the kernel
a) once
b) forever in /etc/sysctl.conf: