Summary of OpenVPN Installation and Configuration on FreeBSD
1. Installing OpenVPN
Install OpenVPN on FreeBSD:
sudo pkg install openvpn
or, if you want a more fine-tuned installation:
cd /usr/ports/security/openvpn
sudo make install clean
2. Preparing the Configuration
DOWNLOAD YOUR .OVPN CONFIG FILE OR GET ONE FROM protonvpn.com FOR FREE
Navigate to the OpenVPN config folder:
cd /usr/local/etc/openvpn/
Place your client configuration file here.
Example: client.conf
Rename client.conf
to openvpn.conf
:
sudo cp client.conf openvpn.conf
(because the default service expects openvpn.conf
)
3. Ensuring the TUN/TAP Kernel Module is Loaded
OpenVPN requires a TUN interface.
Load the TUN module:
sudo kldload if_tun
If it is already active, you will see:
kldload: can't load if_tun: module already loaded or in kernel
To automatically load the module at boot:
sudo sh -c 'echo if_tun_load="YES" >> /boot/loader.conf'
4. Creating the tun0 Interface (if it doesn't exist)
If /dev/tun0
does not exist:
sudo ifconfig tun create
Check if tun0
has been created:
ifconfig tun0
5. Running OpenVPN Manually
To test if the configuration is valid:
sudo openvpn --config /usr/local/etc/openvpn/openvpn.conf
If successful, OpenVPN will display a log message like:
Initialization Sequence Completed
and tun0
will receive an IP address.
6. Configuring OpenVPN as a Service (Optional)
If you want OpenVPN to start automatically via the service system, edit /etc/rc.conf
:
sudo ee /etc/rc.conf
Add the following line:
openvpn_enable="YES"
If your config file has a different name (not openvpn.conf
), you will need to manually set up an instance.
To start the service:
sudo service openvpn start
If you encounter an error related to if_tun0
, it's better to continue running OpenVPN manually using openvpn --config
(as you did before).
7. Checking VPN Status
To make sure you are connected through the VPN:
- Open https://whatismyipaddress.com/
- Compare your IP address before and after connecting.
Additional Notes
-
Check OpenVPN logs in
/var/log/
if there are any errors. -
Use
ps aux | grep openvpn
to see active OpenVPN processes. - To manually kill the OpenVPN process:
sudo killall openvpn
0 Comments