How to Setup WireGuard VPN on CentoOS 8 & Access it via Windows 10/7/Mobile

Kaz Wolfe

Well-known member
Registered
Joined
Jul 7, 2016
Messages
604
Points
28
WireGuard is a modern VPN protocol that provides a simple, fast, and secure way to establish a virtual private network. Here's how to set up a WireGuard VPN on CentOS 8 and access it via Windows 10/7 and mobile devices:

Step 1: Install WireGuard on CentOS 8

Connect to your CentOS 8 server via SSH.
Install the EPEL repository:

Code:
sudo dnf install epel-release
Install WireGuard and its dependencies:

Step 2: Generate WireGuard Keys

Create the public and private keys for the server
Code:
sudo mkdir /etc/wireguard && cd /etc/wireguard
sudo umask 077
sudo wg genkey | tee privatekey | wg pubkey > publickey
Create the public and private keys for each client:

Code:
sudo wg genkey | tee privatekey_client1 | wg pubkey > publickey_client1
sudo wg genkey | tee privatekey_client2 | wg pubkey > publickey_client2
Copy the public keys for each client and add them to the server's configuration file:

Code:
cat /etc/wireguard/publickey_client1 >> /etc/wireguard/clients.list
cat /etc/wireguard/publickey_client2 >> /etc/wireguard/clients.list
Step 3: Configure WireGuard

Create the WireGuard configuration file

Code:
sudo nano /etc/wireguard/wg0.conf
Add the following configuration to the file:

Code:
[Interface]
Address = 10.0.0.1/24
SaveConfig = true
PrivateKey = SERVER_PRIVATE_KEY
ListenPort = 51820

[Peer]
PublicKey = CLIENT_PUBLIC_KEY
AllowedIPs = 10.0.0.2/32
Replace SERVER_PRIVATE_KEY with the server's private key, and CLIENT_PUBLIC_KEY with the client's public key.
Save and close the file.

Step 4: Start WireGuard

Start the WireGuard interface

Code:
sudo systemctl enable --now wg-quick@wg0
Check the status of the WireGuard interface:


Code:
sudo wg show
Step 5: Connect to the VPN
  1. On Windows, download and install the WireGuard client from the official website.
  2. On mobile devices, download and install the WireGuard app from the app store.
  3. Import the configuration file you created in Step 3 into the client.
  4. Connect to the VPN.
That's it! You should now be able to access your CentOS 8 server via the WireGuard VPN from your Windows and mobile devices.
 
Recommended Threads
Replies
6
Views
2,549
Replies
24
Views
10,977
Replies
5
Views
3,943

Latest Hosting OffersNew Reviews

Sponsors

Tag Cloud

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top