Traditional corporate VPN protocols like OpenVPN and IPsec are notoriously heavy. Their codebases span hundreds of thousands of lines, negotiation handshakes introduce latency, and client connections drop abruptly when transitioning between Wi-Fi and mobile networks.
WireGuard operates directly inside the Linux kernel using state-of-the-art cryptography (Noise protocol framework, Curve25519, ChaCha20-Poly1305, BLAKE2s). With fewer than 4,000 lines of code, it delivers near line-speed throughput, instant reconnections, and a minimal attack surface.
Server Gateway Setup (Ubuntu / Debian / Alpine)
1. Kernel Module Installation & Forwarding
sudo apt update && sudo apt install -y wireguard iptables qrencode
# Enable IPv4 packet forwarding
echo "net.ipv4.ip_forward=1" | sudo tee -a /etc/sysctl.d/99-wireguard.conf
sudo sysctl -p /etc/sysctl.d/99-wireguard.conf2. Keypair Generation
Generate high-entropy private and public keypairs for the server and client:
umask 077
wg genkey | tee server_private.key | wg pubkey > server_public.key
wg genkey | tee client_private.key | wg pubkey > client_public.key3. Gateway Configuration (/etc/wireguard/wg0.conf)
[Interface]
Address = 10.200.0.1/24
ListenPort = 51820
PrivateKey = <CONTENTS_OF_server_private.key>
# Firewall rules to masquerade traffic outbound to the internet
PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
# Client Peer (Engineer Workstation)
[Peer]
PublicKey = <CONTENTS_OF_client_public.key>
AllowedIPs = 10.200.0.2/32Enable and start the service:
sudo systemctl enable --now wg-quick@wg0Engineer Client Configuration
Create the client configuration profile (engineer-laptop.conf):
[Interface]
Address = 10.200.0.2/24
PrivateKey = <CONTENTS_OF_client_private.key>
DNS = 1.1.1.1, 8.8.8.8
[Peer]
PublicKey = <CONTENTS_OF_server_public.key>
Endpoint = vpn.aebibtech.com:51820
# Split Tunneling: Only route private office subnets through the VPN
AllowedIPs = 10.200.0.0/24, 10.10.10.0/24
PersistentKeepalive = 25Split Tunneling vs. Full Tunneling
Quick Mobile Pairing via QR Code
Generate an instant terminal QR code to import configuration onto an iOS or Android device:
qrencode -t ansiutf8 < engineer-laptop.confScan the terminal screen with the official WireGuard mobile app to establish an encrypted link within seconds.