Skip to content

Instantly share code, notes, and snippets.

@jjangga0214
Last active February 21, 2019 09:30
Show Gist options
  • Save jjangga0214/59b788f7a369c56cae72a1abffa353b1 to your computer and use it in GitHub Desktop.
Save jjangga0214/59b788f7a369c56cae72a1abffa353b1 to your computer and use it in GitHub Desktop.
tutorial for setting openvpn server and connecting to it through a client program

Use Your Own VPN with OpenVPN

This let you know how to run your own vpn server and connect client to it.

install OpenVPN on your server (ON SERVER)

I use ubuntu as a server here, but expect it to work on other distros as well.

# let us assume username is ubuntu
mdkir /home/ubuntu/ov
cd /home/ubuntu/ov
curl -O https://raw.githubusercontent.com/Angristan/openvpn-install/master/openvpn-install.sh
chmod +x openvpn-install.sh
./openvpn-install.sh

Then you will find *.ovpn file on ~, where * would be what you configured as name. I am going to refer it ov.ovpn as an example. Copy this file(FTP or just copy content to clipboard on ssh terminal), and place it on your client's local directory

firewall

Enable inbound port 1194 for both UDP and TCP.

refs

For detail instruction, you can visit angristan/openvpn-install.

connect to your vpn server through a client program (ON CLIENT)

Let us assume you placed ov.ovpn file on ~/ov directory. Then, just sudo openvpn --config ~/ov/ov.ovpn should work. However, it causes DNS resolution problem, which is a problem that can't find ip by domain name. So, for example, ping google.com would fail.

Therefore, additional steps are needed.

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

Then, open setting -> Network -> VPN -> import from file -> choose ov.ovpn file -> click Add button. However, now password problem occurs. What's more, it's hard to detect as it doesn't notify you, but just doesn't work. To solve it,

# if you don't set vpn name as ov, then use that name instead of ov
sudo vi /etc/NetworkManager/system-connections/ov

And on the [vpn] section, set password-flags=0, then add a new section [vpn-secrets] like below

[vpn]
... some pre-existing parameters
password-flags=0

[vpn-secrets]
password="your-password"

Where "your-password" is your vpn password, which you chose while installing openVPN on server. If you haven't, this value can be any string.

refs

For detail instruction, you can visit necromuralist's blog.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment