- Joined
- Jul 7, 2016
- Messages
- 609
- 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:
Install WireGuard and its dependencies:
Step 2: Generate WireGuard Keys
Create the public and private keys for the server
Create the public and private keys for each client:
Copy the public keys for each client and add them to the server's configuration file:
Step 3: Configure WireGuard
Create the WireGuard configuration file
Add the following configuration to the file:
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
Check the status of the WireGuard interface:
Step 5: Connect to the VPN
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
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
Code:
sudo wg genkey | tee privatekey_client1 | wg pubkey > publickey_client1
sudo wg genkey | tee privatekey_client2 | wg pubkey > publickey_client2
Code:
cat /etc/wireguard/publickey_client1 >> /etc/wireguard/clients.list
cat /etc/wireguard/publickey_client2 >> /etc/wireguard/clients.list
Create the WireGuard configuration file
Code:
sudo nano /etc/wireguard/wg0.conf
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
Save and close the file.
Step 4: Start WireGuard
Start the WireGuard interface
Code:
sudo systemctl enable --now wg-quick@wg0
Code:
sudo wg show
- On Windows, download and install the WireGuard client from the official website.
- On mobile devices, download and install the WireGuard app from the app store.
- Import the configuration file you created in Step 3 into the client.
- Connect to the VPN.