OpenVPN is a sophisticated solution for VPN in Linux. With VPN, one can create a VPN server or using a VPN network as a client. A VPN (Virtual Private Network) is very effective to keep our privacy in internet so nobody will sniff our IP address or block our connection to the internet. Internet privacy is crucial and OpenVPN gives us the powerful approach so I write this article. I will show you how to install OpenVPN on Ubuntu and use it with a free VPN provider.
By using OpenVPN connection, you basically "force" all applications to connect to the internet via that connection. It means, different applications such as web browser, IRC client, mail client, torrent, even CLI programs such as apt and wget will automatically "forced" to connect via that OpenVPN connection. The global topology is you connect to the OpenVPN server first, then the server forwards you into the internet. Similar to proxy connection but VPN is encrypted and has more features. It is encrypted securely so basically nobody will spy your connection.
Use this command on the Terminal. Ensure your internet connection is enabled.
sudo apt-get install openvpnYou can apply the same command on Debian or Linux Mint.
Obtain An OpenVPN File
To connect to the internet via OpenVPN connection, you will need a working OpenVPN server. Fortunately, we have many providers provide us free OpenVPN server. In OpenVPN terms, we need the configuration file (.ovpn) to connect to a server. I will use my favorite provider (vpngate.net) as example here. I like vpngate because I don't need to type password to use their files.
- Open vpngate.
- Select one country. For example, see Japan, see OpenVPN column, click the link. A new tab (download page) opened.
- In the new page, select TCP between TCP and UDP selection. You download a file with .ovpn extension. This is your configuration file to connect to Japan OpenVPN server.
- I give TCP option as an example only. You may download the UDP if you need.
Connect with OpenVPN
Make sure you know where you download the file. Open your Terminal and cd to that file directory. Use this command
sudo openvpn --config name_of_openvpn_config_file.ovpnOpenVPN will try to connect to the server and it will output all info messages to the Terminal. Wait until Initialization Sequence Completed message. It means your connection is successfully established. Now you can connect to the internet securely.
Type Ctrl+C on the running OpenVPN Terminal. It will disable your OpenVPN connection and configure back your normal internet connection. Or, simply you can just close that Terminal.
Check Your IP Address
To make sure your VPN connection is established, you need to check it to IP checker service on internet. I give you an example: iplocation.net. Once your OpenVPN connection established, visit this site. If your connection is true, you will see that site shows corresponding country with your OpenVPN server. It shows you current OpenVPN server IP address too not your real IP address. In this case, you selected Japan and you must see Japan in this iplocation website. See picture below.
More Easier Command
Create an alias so you don't need to type long openvpn command again. In this example, add this text line into your .bashrc file to create easy alias. The file path is /home/<yourname>/.bashrc.
Then command source ~/.bashrc in Terminal. This command will apply that change so your Terminal (bash) can use your new alias.