Skip to content
Home » How to set up WireGuard VPN

How to set up WireGuard VPN

WireGuard is a modern VPN protocol that is known for its speed, security, and ease of use. It is a relatively new protocol, but it has quickly gained popularity due to its many advantages over traditional VPN protocols such as OpenVPN and IPsec.

In this tutorial, we will show you how to set up WireGuard VPN on a Linux server and a Windows client.

Prerequisites:

  • A Linux server with root access
  • A Windows client computer

Instructions:

1. Install WireGuard on the Linux server.

sudo apt update
sudo apt install wireguard

2. Generate a private and public key pair for the server.

wg genkey | tee privatekey | wg pubkey > publickey

3. Create a WireGuard configuration file for the server.

sudo nano /etc/wireguard/wg0.conf

Paste the following configuration into the file:

[Interface]
PrivateKey = /path/to/privatekey
Address = 192.168.1.1/24
ListenPort = 51820

[Peer]
PublicKey = <public_key_of_client>
AllowedIPs = 192.168.1.2/32

Replace <public_key_of_client> with the public key of the Windows client.

4. Save and close the file.

5. Enable WireGuard on the server.

sudo systemctl enable wg-quick@wg0
sudo systemctl start wg-quick@wg0

6. Install WireGuard on the Windows client computer.

Download and install the WireGuard client for Windows from the WireGuard website.

7. Generate a private and public key pair for the client.

Open a PowerShell console and run the following command:

wg genkey | tee privatekey | wg pubkey > publickey

8. Create a WireGuard configuration file for the client.

Open a text editor and create a new file called wg0.conf. Paste the following configuration into the file:

[Interface]
PrivateKey = <path/to/privatekey>
Address = 192.168.1.2/32
DNS = 1.1.1.1

[Peer]
PublicKey = <public_key_of_server>
AllowedIPs = 192.168.1.1/24
Endpoint = <IP_address_of_server>:51820

Replace <path/to/privatekey> with the path to the private key file that was generated in step 7. Replace <public_key_of_server> with the public key of the Linux server. Replace <IP_address_of_server> with the IP address of the Linux server.

9. Save and close the file.

10. Import the WireGuard configuration file into the WireGuard client.

Open the WireGuard client and click the + button to add a new tunnel. Click Import tunnel from file and select the wg0.conf file that you created in step 8.

11. Enable the WireGuard tunnel.

Click the toggle switch next to the tunnel name to enable it.

Once you have completed these steps, you should be able to connect to the WireGuard VPN from the Windows client computer.

Tags: