Wireguard is a modern, high-performance VPN that is simpler and faster than traditional VPN protocols. In this guide, we will cover how to set up Wireguard VPN on CentOS 8. These instructions are applicable whether you are using a Windows VPS UK or a CentOS-based system.

Prerequisites

Before beginning, make sure you have a CentOS 8 server ready. This server can be hosted on any UK Windows VPS, Windows Virtual Private Server Hosting, or any other VPS Windows Hosting environment.

Step 1: Update Your System

Start by updating your system’s packages to ensure everything is up-to-date. Run the following commands:

sudo dnf update

Step 2: Enable the EPEL Repository

Wireguard is not included in the default CentOS 8 repositories, so you need to enable the EPEL (Extra Packages for Enterprise Linux) repository:

sudo dnf install epel-release

Step 3: Install Wireguard

Now, install Wireguard and its dependencies by running the following command:

sudo dnf install wireguard-tools

Wireguard is lightweight and installs quickly, making it an excellent choice for VPS UK Windows or Windows Server VPS environments.

Step 4: Generate Server Keys

Next, you will need to generate public and private keys for the server. Run the following commands to create a directory for your Wireguard configuration and generate the keys:

mkdir -p /etc/wireguard
cd /etc/wireguard
wg genkey | tee privatekey | wg pubkey > publickey

These keys are essential for setting up your VPN, whether you're using a UK Windows VPS or Windows VPS Italy.

Step 5: Configure Wireguard

Create the Wireguard configuration file:

sudo nano /etc/wireguard/wg0.conf

Add the following configuration, replacing PrivateKey with the private key you generated earlier and setting your ListenPort and Address:

[Interface]
PrivateKey = YOUR_PRIVATE_KEY
Address = 10.0.0.1/24
ListenPort = 51820

[Peer]
PublicKey = YOUR_PEER_PUBLIC_KEY
AllowedIPs = 10.0.0.2/32

This configuration sets up the VPN server with an internal IP address of 10.0.0.1 and listens on port 51820. You will need to adjust the peer settings based on the client devices you want to connect to the VPN.

Step 6: Start Wireguard

Once configured, start the Wireguard interface:

sudo wg-quick up wg0

You can enable Wireguard to start on boot using the following command:

sudo systemctl enable wg-quick@wg0

Step 7: Configure Firewall

Ensure your firewall allows traffic on the Wireguard port (51820 by default). Run the following commands to open the necessary port:

sudo firewall-cmd --add-port=51820/udp --permanent
sudo firewall-cmd --reload

Configuring the firewall correctly is critical for the VPN to work, especially in environments like Windows VPS Hosting UK or VPS Windows Servers.

Step 8: Add Clients to the VPN

To add clients, such as laptops or mobile devices, you need to generate a public/private key pair for each device and update the Wireguard configuration with their details. For example, on the client device, run:

wg genkey | tee client_privatekey | wg pubkey > client_publickey

Then, update the server configuration to include the new peer with the client's public key and allowed IPs.

Conclusion

Wireguard is an efficient and secure VPN solution, ideal for use on Virtueller Server or Windows Virtual Private Servers. By following these steps, you can set up and configure Wireguard on CentOS 8, enhancing the security and privacy of your server, whether it's a Windows VPS UK or a Windows VPS Italy.

Was this answer helpful? 0 Users Found This Useful (0 Votes)