This guide describes how to connect to our service using OpenVPN on Linux, via terminal.
First, make sure openvpn is installed by running in terminal: openvpn --version
You can either set a one-time connection, which will be active in the terminal session until you disconnect (CTRL+C) or close the terminal, or you can set an active connection started by the openvpn service on-boot.
Important Notes:
/etc/resolv.conf
(not a statically linked file) such as:nameserver 9.9.9.9
/etc/resolv.conf
systemd-resolved
is recommended (not using localhost as DNS resolver) because it is known to cause trouble with the DNS lookups while using the VPN connection. More info on how to disable it: here.Method 1
This method is for setting up an OpenVPN connection manually (one-time).
sudo
: (sudo) openvpn [path to the .ovpn file]
such as sudo openvpn ./finland-aes256-udp.ovpn
auth.txt
and add your VPN username and password, one per line. Create it either one of the editors like vim, nano or by using echo
:echo "myvpnusername" > auth.txt; echo "myvpnpassword" >> auth.txt
auth-user-pass
, change it to auth-user-pass auth.txt
sed
utility to mass-change the files, such as:sed -i 's,auth-user-pass,auth-user-pass auth.txt,g' *.ovpn
Method 2
This method is for setting up an automatic/permanent OpenVPN connection managed by systemd.
/etc/openvpn/vpnac.conf
vpnacfrance.conf
/etc/openvpn/auth.txt
(see step 2 above) and make the necessary change to the server profile auth-user-pass auth.txt
/etc/default/openvpn
and specify which server profile to use by changing the AUTOSTART=ALL
parameter to AUTOSTART=vpnac
or what server profile you want to use.(sudo) systemctl enable openvpn
(sudo) systemctl start openvpn
/var/log/syslog
(sudo) systemctl stop openvpn
(sudo) systemctl disable openvpn