Exclusive Metin2 game shield on FreeBSD: Automatic siege mode, VIP list, and whitelist from your dashboard. See how it works
Create a server

Guide

How to Set Up a WireGuard VPN on a VPS

WireGuard is a modern, fast VPN with a small config. On a VPS it lets you reach internal services or egress with the server IP.

Steps

  1. Install WireGuard and tools:

    sudo apt update
    sudo apt install -y wireguard wireguard-tools
  2. Generate server keys (keep the private key secret):

    umask 077
    wg genkey | tee /etc/wireguard/server_private.key | wg pubkey > /etc/wireguard/server_public.key
    sudo chmod 600 /etc/wireguard/server_private.key
  3. Create /etc/wireguard/wg0.conf (adjust IP and key):

    sudo tee /etc/wireguard/wg0.conf >/dev/null <<'EOF'[Interface]Address = 10.8.0.1/24ListenPort = 51820PrivateKey = SERVER_PRIVATE_KEY# [Peer]# PublicKey = CLIENT_PUBLIC_KEY# AllowedIPs = 10.8.0.2/32EOF
  4. Open UDP, enable IP forwarding and start the interface:

    sudo ufw allow 51820/udp
    echo 'net.ipv4.ip_forward=1' | sudo tee /etc/sysctl.d/99-wireguard.conf
    sudo sysctl --system
    sudo systemctl enable --now wg-quick@wg0
    sudo wg show

Tips

  • Add each client as a [Peer] with its public key and a 10.8.0.x/32 address.
  • For NAT to the internet, add PostUp/PostDown iptables rules on the public NIC.

ext step

Fixed IP and solid uplink for your VPN: Deploy your Cloud VPS.

Related guides