To install OpenVPN on AlmaLinux 9.5, you can follow these steps:
1. Update the System:
Before installing any software, it's a good idea to update your system:
2. Install EPEL Repository:
OpenVPN is available in the EPEL (Extra Packages for Enterprise Linux) repository. First, install the EPEL repository:
3. Install OpenVPN:
After enabling the EPEL repository, install OpenVPN:
4. Install NetworkManager (Optional):
If you are using NetworkManager for managing network connections, you can install the OpenVPN plugin for NetworkManager:
5. Configure OpenVPN:
Once installed, you need to configure OpenVPN by copying your .ovpn configuration file to the /etc/openvpn/ directory:
6. Start OpenVPN:
You can start OpenVPN by specifying the configuration file directly:
If you want OpenVPN to run as a service, you can create a systemd service file as described in previous steps, or use the provided openvpn-client service unit with a slight modification to ensure it starts with the correct .ovpn file.
sudo chmod 644 /etc/openvpn/your_config.ovpn
In the [Install] section, add the WantedBy directive to ensure the service is started on boot. You can use multi-user.target, which is commonly used for services that should be started after the network is up.
Here's what the updated service file should look like:
sudo nano /etc/systemd/system/openvpn.service
[Unit]
Description=OpenVPN connection to %i
After=network.target
[Service]
Type=simple
ExecStart=/usr/sbin/openvpn --config /etc/openvpn/your_config.ovpn
Restart=on-failure
User=root
Group=root
[Install]
WantedBy=multi-user.target
Save and exit
This configuration ensures that OpenVPN starts when the system reaches the multi-user.target, which is the normal operating state for most systems.
Reload Systemd and Enable the Service:
After modifying the service file, reload the systemd configuration and enable the service to start at boot:
sudo systemctl daemon-reload
sudo systemctl enable openvpn.service
Start the Service:
If you haven't already started the service, use the following command to start it:
sudo systemctl start openvpn.service
Verify the Service is Enabled:
To confirm that the service is now enabled and will start on boot, run:
sudo systemctl is-enabled openvpn.service
7. Verify Connection:
You can verify if OpenVPN is running by checking the status:
If you used a service file, make sure to reload systemd and restart the service:
8. Troubleshooting:
If the OpenVPN service is not starting, you can check logs for any issues:
You can also check /var/log/messages or /var/log/openvpn.log (if logging is enabled in the configuration) for more detailed error information.
By following these steps, you should be able to install and configure OpenVPN on AlmaLinux 9.5. If you encounter any issues, let me know, and I'll help you troubleshoot further.
======================================================
OFFICIAL & RELIABLE UPGRADE METHOD (Source Build)
Because:
Rocky 8 repos stop at 2.4
OpenVPN repo URLs change
Source build always works and is stable
This is the most future-proof method.
π’ Step 1 — Install build dependencies (one time)dnf groupinstall -y "Development Tools"
dnf install -y \
openssl-devel \
lzo-devel \
lz4-devel \
pam-devel \
systemd-devel \
libcap-ng-devel \
iproute \
pkgconfig
π’ Step 2 — Download OpenVPN 2.6 source (official)cd /usr/srcVerify size (must be several MB):
curl -LO https://swupdate.openvpn.org/community/releases/openvpn-2.6.10.tar.gzls -lh openvpn-2.6.10.tar.gz
π’ Step 3 — Compile and installtar -xzf openvpn-2.6.10.tar.gzThis installs OpenVPN here:
cd openvpn-2.6.10
./configure \
--prefix=/usr/local \
--enable-systemd \
--enable-iproute2
make -j$(nproc)
make install/usr/local/sbin/openvpn
π’ Step 4 — Verify new OpenVPN (MANDATORY)/usr/local/sbin/openvpn --versionYou must see:OpenVPN 2.6.xIf not → stop here.
π’ Step 5 — Switch systemd to new OpenVPN
Edit the service file:nano /etc/systemd/system/openvpn.serviceChange ExecStart from:/usr/sbin/openvpnto:/usr/local/sbin/openvpnSave and reload:systemctl daemon-reload
π’ Step 6 — Test manually (IMPORTANT)
Before systemd:/usr/local/sbin/openvpn --config /etc/openvpn/client.ovpnYou should see:VERIFY OKIf manual works → systemd will work.
Peer Connection Initiated
Initialization Sequence Completed
π’ Step 7 — Start OpenVPN servicesystemctl enable openvpn
systemctl restart openvpn
systemctl status openvpn
✅ Expected SUCCESS logsControl Channel: TLSv1.3
Peer Connection Initiated
PUSH_REPLY
Initialization Sequence Completed
π§° Maintenance & Future Use
π Upgrade later (example: 2.6.11)
Just repeat:cd /usr/srcNo config changes needed.
curl -LO https://swupdate.openvpn.org/community/releases/openvpn-2.6.11.tar.gz
tar -xzf openvpn-2.6.11.tar.gz
cd openvpn-2.6.11
./configure --prefix=/usr/local --enable-systemd --enable-iproute2
make -j$(nproc)
make install
systemctl restart openvpn
Comments
Post a Comment