Prerequisites
You should have a remote OpenVPN server running
You should have an openVPN client config
Install OpenVPN client packages
apt update
apt install openvpn -y
Copy your client configuration to as client.conf
/etc/openvpn/client/client.conf
If you want a sample client.conf , you might be able to find it on /usr/share/doc/ . If you don’t know about the location of this sample file , you can search for it:
find / -name client.conf
So if you want to use this file , you can copy it to /etc/openvpn/client/
To start the openvpn client :
systemctl start openvpn@openvpn.service or service openvpn start
Or if you are getting error with the above command, you can start it manually by using the script below :
/usr/local/sbin/openvpn --cd /usr/local/etc/openvpn --daemon openvpn --config /usr/local/etc/openvpn/client/client.conf --script-security 2
The script will work for all major versions of Linux and FreeBSD but you need to make sure the file locations are all correct for the specific distro you are using . If you want to write the openvpn process id along with this you can use :
/usr/local/sbin/openvpn --daemon --writepid /var/run/openvpn/client.pid --cd /usr/local/etc/openvpn/client/ --config client.conf --script-security 2
So with the above oneliner script, when starting the openvpn gives me the error:
Options error: --writepid fails with '/var/run/openvpn/client.pid': No such file or directory (errno=2)
So the issue here its not seeing openvpn directory in /var/run to create a process id (pid) when the process starts , so just go to that folder /var/run and create a folder called openvpn there
The logs can be found on : depends upon how you configure it in client .conf
/var/log/openvpn.log
Leave a Reply