/ VPN / 4 min read

Create your own Google VPN

I’ve been playing around with Google Cloud. They offer free 300$ credits which is valid for 1 years for new users. Great deal!

Part 1 – Setting up!

Let’s start. As the first step, you need to login to console and navigate to Compute Engine section. Which I believe this link will redirect you to there: Cloud Compute

Click on create an instance.

  1. Type up a familiar name for your instance or leave it as it is.
  2. Select closest zone to you for a better experience. I’ve selected europe-west-1b since I’m in Europe and that’s the closest zone to me.
  3. You can leave OS as Debian GNU/Linux 9 (stretch). I’ll go with this one. Since we’re going to use Docker, it shouldn’t matter that much.
  4. In the Firewall section do me a favour and select both Allow HTTP traffic and Allow HTTPS traffic then press create.

Congratulations! You’ve created your first VM on Google. Now go back to your VM instances. Then search for firewall rules on the top search box.

  1. Click on create new firewall rule.
  2. Make the name anything you want to, but remember it. I’ll simply use vpn.
  3. Enter vpn in target tags too and make sure that your Source Filter is IP Ranges.
  4. Type in source IP ranges.
  5. On protocols and ports part select allow all. Create.

Now that we’ve opened all the ports on our VM, we need to add these new rules to our VM. Go back to VM instances.

  1. Click on the name of your instance.
  2. Click edit on the top bar.
  3. Under network tags section, you should be seeing http-server and https-server. Type vpn (or the name you gave earlier in firewall settings) then click outside of the text edit box.
  4. Now it should have a shape like the other two, with a small x next to the name.
  5. Scroll to the bottom and click save.

Alright, we’re done with Part 1. Now we’ll connect to our SSH and setup VPN software.

Part 2 – Installing VPN!

In this section we’re going to connect to our VM and install VPN software via docker. Let’s start.

Click on SSH button on the line of your instance, in the VM instances page. New window will pop-up. You can find more information on Google Docs.

  1. Now you’re logged into your SSH, as the first job type sudo passwd.

You should see something similar to this:

Changing password for user root.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

If you’re new to the Linux, don’t worry. While typing password for security reasons, you’ll see nothing. It’ll act like nothing is happening but you’re actually typing your password.

Now type su root.
You’re now swapped to root account which has all the privileges that we need.
Type, OVPN_DATA="ovpn-data-example" in the command line. You can type anything for ovpn-data-example of course or just leave it as it is.

Now we’ll need Docker to continue to following steps, let’s install it.

  1. Type this and press enter.
    sudo curl -sSL https://get.docker.com/ | sh it will automatically install docker for you.
  2. Since we have Docker now, we can continue.
  3. Type following commands, line by line to complete installation.

NOTE: During installation, time to time it’ll ask you password for PEM etc. Just type same password for every each one of them when asked. Such as: +Vu1$740. If it’s not asking for a password but still asking for something else just press enter.

Command block notes: Replace YOURGOOGLEVMIPADDRESS part with your VM instance IP. You can find it on the VM instances page. You can change CLIENTNAME if you’d like you. You don’t have to, but you can.

docker volume create --name $OVPN_DATA
docker run -v $OVPN_DATA:/etc/openvpn --rm kylemanna/openvpn ovpn_genconfig -u udp://VPN.SERVERNAME.COM
docker run -v $OVPN_DATA:/etc/openvpn --rm -it kylemanna/openvpn ovpn_initpki
docker run -v $OVPN_DATA:/etc/openvpn -d -p 1194:1194/udp --cap-add=NET_ADMIN kylemanna/openvpn
docker run -v $OVPN_DATA:/etc/openvpn --rm -it kylemanna/openvpn easyrsa build-client-full CLIENTNAME nopass
docker run -v $OVPN_DATA:/etc/openvpn --rm kylemanna/openvpn ovpn_getclient CLIENTNAME > CLIENTNAME.ovpn

After completing all the steps successfully, we can proceed to Part 3.

Part 3 – Using the VPN!

You need that ovpn file that you’ve generated in the last step. Now, we need to download that file but how, right? Google does something amazing to help us on this.

Type ls in the console if you’re seeing the ovpn file there, type pwd next. It’ll print you your current working directory. Which may look like /root. Take note of it.
Click on the bolt icon on the top right of the console window.
Click download file, it’ll ask you for full path of the file.
Enter the full path, which could be /root/CLIENTNAME.ovpn that’s up to your config, if you’ve entered it correct file will be downloaded to your PC.

Now, to use this file we need OpenVPN application. Go to OpenVPN downloads page and if you’re using Windows download the one which says Installer, Windows Vista and later. Install OpenVPN. After installing it, launch application from your desktop or the installation directory. Small monitor icon with a lock will appear at the system tray.

  1. Right click on the OpenVPN tray icon.
  2. Click on import file.
  3. Select your downloaded CLIENTNAME.ovpn file.
  4. Right click again, hover on CLIENTNAME.ovpn and click on connect.

A new window will pop-up, a lot of text will scroll through the screen and done! Now, tray monitor icon screen should be green. To test if it’s working go to DumanIP. You should see information on the screen which looks like:

ISP: Google Cloud
Organization: Google Cloud
AS number: AS15169 Google LLC
Country: United States
Region name: California, CA
City: Mountain View
Zip code: 94043
Latitude: 37.4192
Longitude: -122.0574
Time zone: America/Los_Angeles

If you’re looking at a page like that, you’re done! You’re now connecting to internet over Google.

Enjoy surfing the web without limits and really fast compared to all other free VPN providers on your very own private server. See you in another post!