Skip to content

OpenVPN client on FreeBSD

To set up an OpenVPN client on FreeBSD, follow these steps:

Install OpenVPN: First, update the package repository and install OpenVPN using the following commands:

pkg update
pkg install openvpn
Obtain the OpenVPN configuration file: Obtain the OpenVPN configuration file (.ovpn) from your VPN provider or create one if you have your own VPN server. You'll also need any associated certificate and key files provided by your VPN provider or generated by you.

Copy configuration files to the OpenVPN directory: Create the OpenVPN directory and copy the configuration files to it:

mkdir /usr/local/etc/openvpn
nano /usr/local/etc/openvpn/client.conf

Update the configuration file (if needed): If your configuration file requires a username and password for authentication, you'll need to create a separate file containing these credentials. Create a new file called auth.txt in the OpenVPN directory:

nano /usr/local/etc/openvpn/auth.txt
Add your username and password to the file, separated by a newline:

your_username
your_password
Save and close the file. Then, open the client.conf file:

nano /usr/local/etc/openvpn/client.conf
Add or modify the following line to reference the auth.txt file:

auth-user-pass /usr/local/etc/openvpn/auth.txt
Save and close the file.

Enable OpenVPN at startup: To enable OpenVPN to start automatically at system boot, edit the /etc/rc.conf file:

nano /etc/rc.conf
Add the following line:

openvpn_enable="YES"
openvpn_configfile="/usr/local/etc/openvpn/client.conf"
Save and close the file.

Start the OpenVPN service:

service openvpn start
Check the connection: Verify that the OpenVPN connection is established by checking the logs:

tail -f /var/log/messages
Or by checking the network interfaces and routing table:

ifconfig
netstat -rn

check your new ip address with an external service:

curl api.ipify.org

After completing these steps, your FreeBSD system should be connected to the VPN server using OpenVPN. If you experience any issues, review the logs or check the configuration files for errors.