How to Set Up WireGuard VPN: A Step-by-Step Guide for Beginners

WireGuard is a fast, secure VPN that’s easier to configure than OpenVPN. This tutorial covers server and client setup on Ubuntu.

You’ll need a Linux VPS and basic terminal skills. Let’s get started.

Article illustration

1. Install WireGuard

SSH into your server and run:

  • sudo apt update && sudo apt install wireguard -y

2. Generate Keys

Create a private key for the server and derive its public key:

  • wg genkey | sudo tee /etc/wireguard/server.key
  • sudo cat /etc/wireguard/server.key | wg pubkey | sudo tee /etc/wireguard/server.pub

Repeat for the client: wg genkey | tee client.key && cat client.key | wg pubkey | tee client.pub

3. Configure Server

Edit /etc/wireguard/wg0.conf:

[Interface]
Address = 10.0.0.1/24
ListenPort = 51820
PrivateKey = <server-private-key>

[Peer]
PublicKey = <client-public-key>
AllowedIPs = 10.0.0.2/32

4. Start and Verify

Enable and start the interface:

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

Check status: sudo wg show

5. Client Setup

Create a client config file with your private key, server public key, server IP, and AllowedIPs = 0.0.0.0/0. Import it into the WireGuard app and activate.

Conclusion: You now have a working WireGuard VPN. Ensure UDP port 51820 is open in your firewall. Enjoy fast, encrypted tunnels.

sarah antaboga
Author: sarah antaboga

Leave a Reply

Your email address will not be published. Required fields are marked *