Setup Open VPN Server on Google Cloud Platform

In this article will cover how to install VPN Server on Google Cloud Platform. Since nowadays kids jaman now understand vpn and the related things why they use VPN.

In this tutorial will show you how to setup and how to use your vpn server in cool ways. Rather than using free vpn with spyware inside your free vpn apps.

I was using GCP Trial (Free $300 that can be used for 1 years) when creating this machine. It’s really usefull since i dont need to pay my bill to learn GCP environtment. But you still need to put credit card in earlier when you submit register. Dont worry, they will not charge you until the rest of trial expired.

Creating an Instance Debian / Ubuntu

You need to have an Instance First via Compute Engine -> VM Instance. You can put the rest information on there as you like. In here i was using Debian 9 or you can use Ubuntu if you like. In my case, i already have my instance so i just need bit modification.

In Security firewall selection, write network tags “dns”. This tag will later be used to bind firewall rules to the instance.

Also you need to add your public ssh key to the box, we will use that for transfering openvpn server config to our PC.

Firewall Rules

Just type firewall on Search Column and Select Firewall (VPC network) in first selection. After that Create Firewall Rule and fill with following parameters.

Above rule is used for our open vpn client communicate to GCP instance, since by default all communication from public is not permitted.

OpenVPN Configuration

After we setup the instance, we can continue to install openvpn server. You can configure instance using built in web browser remote ssh.

Download following script and configure to your instance using root

sudo su
wget -O
chmod +x

Upon running the script asks us about the ip address of the machine. We select the number corresponding to the Public IP address of the machine.

Next we choose to use TCP as the base connection type for our VPN.

Now we will set the port that we added an Inbound rule for so that the OpenVPN server can listen for incoming connections on that port.

The DNS option can be set as preferred. You can use first option, but you will get same DNS as GCP instance. In some case you would not access to internet, since internal dns instance is not public. Your PC will not be able to communicate with internal GCP instance. Thats why i prefer to use google dns.

Finally we give a name that will be used to create a certificate for a user to be allowed to connect. The script will create the required files that a user will need to be able to connect to the server.

.ovpn files under your directory need to be transfered to your PC. You can use winscp or filezilla to remote to your instance. But you need to use your private key which the public key registered in the instance.

After that you can use that files .ovpn to be used in OpenVPN Client.

Also in this script can be used to remove users created for openvpn.

Credit :

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.