FedoraRHEL Based

How To Install OpenVPN on Fedora 40

Install OpenVPN on Fedora 40

OpenVPN is a widely-used, open-source virtual private network (VPN) solution that provides secure and encrypted connections between remote clients and servers. It is known for its reliability, flexibility, and strong security features. Fedora 40, a popular Linux distribution, offers a stable and user-friendly environment for setting up OpenVPN. In this comprehensive guide, we will walk you through the step-by-step process of installing and configuring OpenVPN on Fedora 40, enabling you to create a secure and private network connection.

Prerequisites

System Requirements

Before proceeding with the OpenVPN installation on Fedora 40, ensure that your system meets the following requirements:

  • A Fedora 40 system with root or sudo privileges.
  • A stable internet connection.
  • Basic knowledge of Linux command line and networking concepts.

Step-by-Step Installation Guide

1. Update System Packages

Before installing OpenVPN, it’s crucial to ensure that your Fedora 40 system is up to date with the latest packages and security patches. Open a terminal and run the following command to update the package index and upgrade installed packages:

sudo dnf update -y

This command will download and install any available updates, keeping your system secure and optimized.

2. Install OpenVPN and Easy-RSA

To install OpenVPN and its dependencies on Fedora 40, execute the following command in the terminal:

sudo dnf install -y openvpn easy-rsa

This command will install the OpenVPN package along with Easy-RSA, a utility for managing SSL/TLS certificates. Easy-RSA simplifies the process of generating and managing certificates required for OpenVPN authentication.

3. Configure Easy-RSA for Certificate Management

To set up Easy-RSA for certificate management, follow these steps:

a. Copy the Easy-RSA template directory to the OpenVPN configuration directory:

sudo cp -a /usr/share/easy-rsa/ /etc/openvpn/

b. Navigate to the Easy-RSA directory:

cd /etc/openvpn/easy-rsa/3.0/

c. Initialize the PKI (Public Key Infrastructure) environment:

sudo ./easyrsa init-pki

d. Build the Certificate Authority (CA):

sudo ./easyrsa build-ca

Follow the prompts and provide the necessary information to generate the CA certificate and key.

4. Create Server and Client Certificates

With the CA certificate and key generated, you can now create certificates for the OpenVPN server and clients.

a. Generate the server key and certificate:

sudo ./easyrsa build-server-full server nopass

b. Create client certificates. Replace “client1” with a unique name for each client:

sudo ./easyrsa build-client-full client1 nopass

Repeat this step for each client that will connect to the OpenVPN server.

5. Generate Diffie-Hellman Parameters

Diffie-Hellman parameters are used for key exchange and provide an additional layer of security. Generate the parameters by running the following command:

sudo ./easyrsa gen-dh

This process may take some time to complete, depending on your system’s performance.

6. Server Configuration

With the necessary certificates and keys generated, you can now configure the OpenVPN server.

Copy the sample server configuration file to the OpenVPN directory:

sudo cp /usr/share/doc/openvpn/sample/sample-config-files/server.conf /etc/openvpn/

Open the server configuration file for editing:

sudo nano /etc/openvpn/server.conf

Modify the configuration file according to your requirements. Some common settings to consider include:

  • Specifying the server’s IP address and port.
  • Configuring the VPN network and subnet mask.
  • Specifying the paths to the server certificate, key, and CA certificate.
  • Configuring authentication and encryption settings.

Save the changes and exit the text editor.

7. Start OpenVPN Server

With the server configuration in place, you can now start the OpenVPN service.

a. Enable and start the OpenVPN server:

sudo systemctl enable --now openvpn@server

b. Verify the status of the OpenVPN service:

sudo systemctl status openvpn@server

If the service is running correctly, you should see an “active (running)” status.

8. Configure Firewall

To allow VPN traffic through the firewall and enable IP forwarding, follow these steps:

a. Allow OpenVPN traffic through the firewall:

sudo firewall-cmd --add-service=openvpn --permanent

b. Enable IP masquerading:

sudo firewall-cmd --add-masquerade --permanent

c. Reload the firewall rules:

sudo firewall-cmd --reload

d. Enable IP forwarding:

echo 'net.ipv4.ip_forward = 1' | sudo tee -a /etc/sysctl.conf
sudo sysctl -p

Testing the OpenVPN Setup

Verification Steps

To verify that your OpenVPN setup is working correctly, follow these steps:

  • Configure an OpenVPN client on a remote device using the generated client certificate and configuration file.
  • Attempt to connect to the OpenVPN server from the client device.
  • Once connected, check the client’s assigned IP address and ensure it belongs to the VPN network.
  • Test the connection by accessing resources on the VPN network or performing network connectivity tests.

If the connection is successful and you can access resources securely, your OpenVPN setup is functioning correctly.

Troubleshooting Common Issues

Common Errors and Solutions

If you encounter any issues during the OpenVPN installation or connection process, consider the following troubleshooting tips:

  • Connection Timeout: Ensure that the OpenVPN server is running and accessible from the client device. Check firewall settings and network connectivity.
  • TLS Handshake Failed: Verify that the client and server certificates are correctly configured and valid. Ensure that the client is using the correct CA certificate.
  • No Route to Host: Check the server’s IP address and port settings in the configuration files. Ensure that the client is using the correct server address.
  • Authentication Failed: Double-check the client certificate and key files. Ensure that they are properly generated and configured on both the server and client.

Congratulations! You have successfully installed OpenVPN. Thanks for using this tutorial for installing the OpenVPN server on your Fedora 40 system. For additional help or useful information, we recommend you check the official OpenVPN website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to idroot.us, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button