WireGuard VPN Integration for EQ Gateway
Overview
This implementation replaces ZeroTier with WireGuard for managed gateway VPN connectivity. WireGuard provides a simpler, more reliable VPN solution with better performance and fewer routing conflicts.
Note: For corporate VPN infrastructure details (network architecture, IP scheme, peer management), see eq-systems/infrastructure/wireguard. This document focuses on gateway deployment to the VPN.
Implementation Details
1. Configuration Generation
- Location:
/etc/wireguard/eq-vpn.conf - Naming: Uses “eq-vpn” prefix for clear identification vs other WG networks
- Dynamic IP Assignment: Gateway IP calculated from device serial (EQG-0001 → 172.20.1.2/32)
- Address Scope: Uses
/32to prevent subnet ownership conflicts
2. Key Management
- Private Key:
/etc/wireguard/eq-vpn.key(0600 permissions) - Public Key:
/etc/wireguard/eq-vpn.pub(0644 permissions) - Generation: Automatic during post-installation if keys don’t exist
- Security: Keys generated using WireGuard’s native tools
3. Service Integration
- Service Name:
wg-quick@eq-vpn - Auto-start: Enabled during installation
- Status Check: Verified during setup with clear logging
4. Network Architecture
Corporate LAN (172.16.0.0/23)
↕
Router (WireGuard Server)
↕
VPN Network (172.20.0.0/23)
↕
Gateways (172.20.1.x/32)
5. IP Assignment Scheme
The VPN IP is derived from the device model and serial number:
| Range | Use | Derivation |
|---|---|---|
| 172.20.0.1-127 | Infrastructure/trusted | Manual assignment |
| 172.20.0.128-255 | RPi devices | 128 + decimal(serial) |
| 172.20.1.x+ | EQG devices | Hex serial → high/low bytes + 1 |
Examples:
| Device | Serial | IP Address | Calculation |
|---|---|---|---|
| Router | - | 172.20.0.1 | Manual |
| RPi-01 | 01 | 172.20.0.129 | 128 + 1 |
| RPi-02 | 02 | 172.20.0.130 | 128 + 2 |
| EQG-0001 | 0001 | 172.20.1.2 | (0x00→1).(0x01→2) |
| EQG-0002 | 0002 | 172.20.1.3 | (0x00→1).(0x02→3) |
| EQG-0102 | 0102 | 172.20.2.3 | (0x01→2).(0x02→3) |
| EQG-00FF | 00FF | 172.20.1.256 | (0x00→1).(0xFF→256) |
Note: RPi serials are decimal (1-127), EQG serials are hex (0000-FFFF).
Fixed Routing Issues
Problem Solved
The original issue was asymmetric routing when gateways had both local LAN and WireGuard connectivity:
- Packet arrives: Corporate LAN → eth0 (172.16.1.50)
- Reply attempts: WireGuard interface (wg0) due to subnet ownership
- Result: Connection failure
Solution: /32 Address Assignment
Using /32 instead of /23 prevents WireGuard from claiming subnet ownership:
# Before (problematic):
Address = 172.20.1.2/23 # Claims entire 172.20.0.0/23 subnet
# After (correct):
Address = 172.20.1.2/32 # Claims only single IP
Installation Flow
1. Package Installation
sudo dpkg -i eq-gateway_0.3.0~rc3_all.deb
2. Post-Installation Configuration
The system automatically:
- Detects device serial from setup.yml
- Calculates appropriate VPN IP
- Generates WireGuard key pair
- Creates configuration file
- Enables and starts service
- Displays public key for server configuration
3. Manual Steps
On router: Add the displayed public key to WireGuard server configuration.
Configuration Files
Gateway WireGuard Config (/etc/wireguard/eq-vpn.conf)
[Interface]
PrivateKey = <generated_private_key>
Address = 172.20.1.2/32
[Peer]
PublicKey = 9NEiqfcLdEX5HoyfmNgfjgNfJ5CjxGM6SYR3/ll6x20=
Endpoint = vpn.eq.systems:51820
AllowedIPs = 172.20.0.0/24
PersistentKeepalive = 25
Router Static Route
Target: 172.16.0.0/23 Interface: WG_VPN Purpose: Bridge VPN users to corporate LAN
Deployment Scenarios
Corporate LAN Testing
- Local Access: 172.16.1.50 (direct corporate network)
- VPN Access: 172.20.1.2 (via WireGuard tunnel)
- Both work simultaneously without routing conflicts
Field Deployment
- Only VPN Access: 172.20.1.2
- No corporate LAN: Clean, simple configuration
- Remote management: Full access via VPN tunnel
Dependencies
Package Dependencies
wireguard # WireGuard kernel module and tools
System Requirements
- Linux kernel with WireGuard support
wgcommand-line tools- systemd for service management
Testing
Verify Installation
# Check service status
sudo systemctl status wg-quick@eq-vpn
# Check interface status
sudo wg show
# Test connectivity
ping 172.20.0.1 # Router
Key Files to Check
ls -la /etc/wireguard/eq-vpn.*
# Should show:
# -rw------- eq-vpn.conf
# -rw------- eq-vpn.key
# -rw-r--r-- eq-vpn.pub
Advantages Over ZeroTier
- Simpler Routing: Point-to-point, no broadcast/ARP complexity
- Better Performance: Kernel-level vs userspace
- Fewer Conflicts: Minimal protocol, predictable behavior
- Easier Debugging: Standard networking tools work
- Corporate Friendly: No “shitstorm of ARP” issues
Troubleshooting
Common Issues
- Keys not generated: Check wireguard package installation
- Service fails: Check configuration syntax with
wg-quick up eq-vpn - No connectivity: Verify router has matching public key
- Routing loops: Ensure
/32address assignment
Log Locations
# Service logs
journalctl -u wg-quick@eq-vpn
# Installation logs
journalctl -u eq-gateway.postinst
# WireGuard status
sudo wg show
This implementation provides a clean, maintainable WireGuard VPN solution that works reliably in both corporate and field environments.
© 2026 EQ Systems Inc.