How to Set Up OpenVPN with NordVPN on CentOS Stream 9, Fedora, RHEL 9
Last Updated: April 28, 2024
Introduction
OpenVPN is a versatile and powerful open-source VPN solution favored for its flexibility and security features. It is widely used in the Linux community for its robust support and compatibility. This guide will detail how to install and configure OpenVPN on CentOS Stream 9, Fedora, and RHEL 9 using NordVPN’s configurations, emphasizing the use of UDP for better performance in high-bandwidth applications like streaming, torrenting, and large file transfers.
Step 1: Install OpenVPN and Unzip Configuration Files
Begin by installing OpenVPN and the necessary utilities to handle NordVPN’s configuration files:
1
2
3
4
sudo dnf install openvpn unzip -y
sudo wget https://downloads.nordcdn.com/configs/archives/servers/ovpn.zip
sudo unzip ovpn.zip
sudo rm ovpn.zip
This sequence installs OpenVPN and unzip
, downloads the NordVPN configuration files, and cleans up by removing the zip file.
Step 2: Simplify Configuration Files
OpenVPN configurations can quickly become unwieldy due to the sheer number of server files. Here’s how to streamline this:
1
2
sudo find ovpn_udp/ -type f ! -name '*us*' ! -name '*ca*' -exec rm {} +
sudo rm -r ovpn_tcp/
This command filters out and deletes all UDP configuration files except for those involving servers in the US and Canada, and removes all TCP configurations, as UDP is preferred for its speed in applications requiring high throughput. This optional cleanup step reduces clutter and simplifies selection, especially useful for users who only need servers from specific regions.
Step 3: Create a Credentials File
Before setting up the OpenVPN service, create a credentials file to automate the VPN login process:
1
2
sudo vi /etc/openvpn/creds.txt'
sudo chmod 600 /etc/openvpn/creds.txt
The cred.txt file should look like this:
1
2
[USERNAME]
[PASSWORD]
Replace USERNAME
and PASSWORD
with your NordVPN Service credentials. This file will store your login information securely and will be read automatically by OpenVPN.
Note: Your NordVPN Service credentials are different than the username and password you use to login to your NordVPN account. You can find your Service credentials in the “Manual setup” section in the NordVPN portal: https://my.nordaccount.com/dashboard/nordvpn/manual-configuration/
Step 4: Set Up OpenVPN Service
To ensure that your VPN connection starts automatically with the system boot, set up a systemd service:
1
sudo vi /etc/systemd/system/openvpn-custom.service
Incorporate the following configuration into your service file:
1
2
3
4
5
6
7
8
9
10
11
[Unit]
Description=Custom OpenVPN service for NordVPN
After=network.target
[Service]
Type=simple
ExecStart=/usr/sbin/openvpn --config /etc/openvpn/ovpn_udp/us6001.nordvpn.com.udp.ovpn --auth-user-pass /etc/openvpn/creds.txt
Restart=on-failure
[Install]
WantedBy=multi-user.target
This service file defines a simple service that starts an OpenVPN process with a specific configuration file and credentials file. The service will restart on failure automatically:
1
2
3
sudo systemctl daemon-reload
sudo systemctl enable openvpn-custom.service
sudo systemctl start openvpn-custom.service
Step 5: Verify VPN Connection
Verifying your VPN connection is crucial to ensure privacy and security:
1
curl ifconfig.me
Use this command to check your public IP address before and after connecting to the VPN to confirm that your traffic is properly routed through the VPN. You should see an IP address different from your original public IP address.
Conclusion
Setting up OpenVPN with NordVPN on CentOS Stream 9, Fedora, and RHEL 9 provides enhanced security, privacy, and performance. This guide helps you install, configure, and manage your VPN connections effectively, ensuring that your online activities are secure and private. Following these steps will optimize your VPN experience, maintaining a clean setup and focusing on efficient UDP connections.
For additional customization and advanced security features, visit NordVPN’s official documentation and explore OpenVPN’s extensive community resources.
Enhance your cybersecurity with OpenVPN and NordVPN on your CentOS, Fedora, or RHEL system today!