How to connect to OpenVPN Server via Terminal

It is good to use VPN when we are online on a public internet. VPN will make your online activity and transaction more secure. On my previous tutorial, I have shown how to install and configure OpenVPN Server on CentOS 7.3. Now, I will show you how to connect to the OpenVPN Server from Linux using .ovpn config file. The .ovpn config file must be downloaded from the OpenVPN Server and save it locally. This .ovpn config file contains keys, certificate and some other settings needed to connect to the server.

To connect to OpenVPN file using the config file via Terminal, follow these steps. First cd to the directory where you save the .ovpn file.

cd /home/dhani/Desktop

Now use this command to connect

openvpn --config dhani-openvpn.ovpn

You should see something link this shown

...
Tue Jul 25 22:19:33 2017 OPTIONS IMPORT: timers and/or timeouts modified
Tue Jul 25 22:19:33 2017 OPTIONS IMPORT: --ifconfig/up options modified
Tue Jul 25 22:19:33 2017 OPTIONS IMPORT: route options modified
Tue Jul 25 22:19:33 2017 OPTIONS IMPORT: route-related options modified
Tue Jul 25 22:19:33 2017 OPTIONS IMPORT: --ip-win32 and/or --dhcp-option options modified
Tue Jul 25 22:19:33 2017 OPTIONS IMPORT: peer-id set
Tue Jul 25 22:19:33 2017 OPTIONS IMPORT: adjusting link_mtu to 1605
Tue Jul 25 22:19:33 2017 ROUTE_GATEWAY 192.168.1.1/255.255.255.0 IFACE=wlp3s0 HWADDR=dc:53:60:b5:85:6f
Tue Jul 25 22:19:33 2017 TUN/TAP device tun0 opened
Tue Jul 25 22:19:33 2017 TUN/TAP TX queue length set to 100
Tue Jul 25 22:19:33 2017 do_ifconfig, tt->ipv6=0, tt->did_ifconfig_ipv6_setup=0
Tue Jul 25 22:19:33 2017 /sbin/ip link set dev tun0 up mtu 1500
Tue Jul 25 22:19:33 2017 /sbin/ip addr add dev tun0 10.8.0.2/24 broadcast 10.8.0.255
Tue Jul 25 22:19:33 2017 /sbin/ip route add 139.59.123.13/32 via 192.168.1.1
Tue Jul 25 22:19:33 2017 /sbin/ip route add 0.0.0.0/1 via 10.8.0.1
Tue Jul 25 22:19:33 2017 /sbin/ip route add 128.0.0.0/1 via 10.8.0.1
Tue Jul 25 22:19:33 2017 Initialization Sequence Completed

Now check using whatsmyip.com. Example below:

This is before I connect to the openvpn server.

And after connected, this is the new Ip address

 

Admin

Leave a Reply

Your email address will not be published. Required fields are marked *