Konstantinos Antoniou.

← Projects

WireGuard VPN – Secure Remote Access Enablement for My Infrastructure

Overview

To unlock secure, low-latency, and operationally lightweight remote access into my distributed home lab stack, I implemented WireGuard as my first production-grade VPN entrypoint. This initiative established a scalable, cloud-agnostic remote connectivity layer that supports day-zero developer productivity, fleet management, and multi-site orchestration. Running WireGuard in a containerized footprint allowed me to maximize portability, standardize configuration, and converge all network access paths under a consistent IaC-driven workflow.

This project served as a foundational connectivity milestone, enabling me to remotely administer my Proxmox hypervisor, MikroTik routers, and Docker services with enterprise-level reliability.


Architecture Overview

The solution leverages a containerized WireGuard instance deployed through Docker Compose and exposed via targeted router-level UDP port forwarding. The deployment runs on my internal Apps-Network overlay, ensuring seamless east-west service access and full integration with my network automation stack.

The architecture pillars:

• Containerized WireGuard node for predictable lifecycle management
• UDP port forwarding at the router edge to expose the service to public networks
• Kernel module passthrough via /lib/modules to ensure performance-optimized operation
• Config externalization for clean separation of state and compute
• Peer automation leveraging environment-driven dynamic provisioning

This design reduced operational overhead while establishing a network access standard


Deployment Blueprint

Below is the Docker Compose specification powering the deployment. Its footprint is intentionally lean, while still hitting all the operational KPIs—observability, resilience, and portability.

services:
  wireguard:
    image: lscr.io/linuxserver/wireguard:latest
    container_name: Wireguard
    cap_add:
      - NET_ADMIN
      - SYS_MODULE
    environment:
      - PUID=${PUID}
      - PGID=${PGID}
      - TZ=${TZ}
      - SERVERURL=${SERVERURL}
      - SERVERPORT=${SERVERPORT}
      - PEERS=${PEERS}
      - PEERDNS=${PEERDNS}
      - INTERNAL_SUBNET=${INTERNAL_SUBNET}
      - ALLOWEDIPS=${ALLOWEDIPS}
      - PERSISTENTKEEPALIVE_PEERS=${PERSISTENTKEEPALIVE_PEERS}
      - LOG_CONFS=${LOG_CONFS}
    volumes:
      - config:/config
      - /lib/modules:/lib/modules
    ports:
      - ${HOST_PORT}:${CONTAINER_PORT}/udp
    sysctls:
      - net.ipv4.conf.all.src_valid_mark=1
    restart: unless-stopped

networks:
  default:
    external: true
    name: Apps-Network

volumes:
  config:

And the .env file.

# User and group IDs for file permissions
PUID=1000
PGID=1000

# Timezone
TZ=Europe/Athens

# Optional: Server URL and port
SERVERURL=your_server_url
SERVERPORT=your_server_port

# Optional: Peer configuration and DNS
PEERS=peer1,peer2
PEERDNS=auto

# Optional: Internal subnet and allowed IPs
INTERNAL_SUBNET=203.0.113.0
ALLOWEDIPS=0.0.0.0/0

# Optional: Persistent keepalive peers
PERSISTENTKEEPALIVE_PEERS= 35

# Optional: Log configurations
LOG_CONFS=true

# Host and container port for UDP
HOST_PORT=51820
CONTAINER_PORT=51820

This configuration delivers a clean abstraction layer where all operational settings—peer creation, listening ports, DNS, allowed IPs—are driven through environment variables, aligning the deployment with modern GitOps best practices.


Some deployment outpus

docker container logs Wireguard

───────────────────────────────────────

      ██╗     ███████╗██╗ ██████╗
      ██║     ██╔════╝██║██╔═══██╗
      ██║     ███████╗██║██║   ██║
      ██║     ╚════██║██║██║   ██║
      ███████╗███████║██║╚██████╔╝
      ╚══════╝╚══════╝╚═╝ ╚═════╝

   Brought to you by linuxserver.io
───────────────────────────────────────

To support the app dev(s) visit:
WireGuard: https://www.wireguard.com/donations/

To support LSIO projects visit:
https://www.linuxserver.io/donate/

───────────────────────────────────────
GID/UID
───────────────────────────────────────

User UID:    1000
User GID:    1000
───────────────────────────────────────
Linuxserver.io version: 1.0.20250521-r0-ls90
Build-date: 2025-10-23T11:28:27+00:00
───────────────────────────────────────
    
Uname info: Linux 159264ddd016 6.12.48+deb13-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.12.48-1 (2025-09-20) x86_64 GNU/Linux
**** As the wireguard module is already active you can remove the SYS_MODULE capability from your container run/compose. ****
****     If your host does not automatically load the iptables module, you may still need the SYS_MODULE capability.     ****
**** Server mode is selected ****
**** PersistentKeepalive will be set for: 35 ****
**** External server address is set to vpn.example.com ****
**** External server port is set to 51820. Make sure that port is properly forwarded to port 51820 inside this container ****
**** Internal subnet is set to 203.0.113.0 ****
**** AllowedIPs for peers 0.0.0.0/0 ****
**** PEERDNS var is either not set or is set to "auto", setting peer DNS to 203.0.113.1 to use wireguard docker host's DNS. ****
**** No wg0.conf found (maybe an initial install), generating 1 server and cellphone, laptop peer/client confs ****
PEER cellphone QR code (conf file is saved under /config/peer_cellphone):
(QR code removed)
**** Peer  laptop contains non-alphanumeric characters and thus will be skipped. No config for peer  laptop will be generated. ****
[custom-init] No custom files found, skipping...
maxprocs: Leaving GOMAXPROCS=4: CPU quota undefined
.:53
CoreDNS-1.12.1
linux/amd64, go1.24.1, 
**** Found WG conf /config/wg_confs/wg0.conf, adding to list ****
**** Activating tunnel /config/wg_confs/wg0.conf ****
**** All tunnels are now active ****
[ls.io-init] done.

To extract the .conf file from the volune to use it in my device i run:

docker volume inspect wireguard_config

Screenshot 1: Some deployment outpus

And then:

cp /var/lib/docker/volumes/config/_data/peer1/peer1.conf .

peer1.conf is the file i used to connect to my Wireguard server.


Router Port Forwarding Integration

To operationalize the VPN externally, I performed a targeted UDP port forward on my MikroTik router. That uplifted WireGuard to a first-class citizen in my perimeter architecture, enabling secure inbound tunnels from laptops, mobile devices, and remote workstations.

The end-state architecture delivers:

• Direct access into internal Subnets (Admin, Devices, Guest—as permitted)
• End-to-end encryption with negligible performance overhead
• A unified remote operations plane across both of my sites (A/B)

This approach guarantees a streamlined operator experience no matter where I am.


Key Outcomes & Business Value

Deploying WireGuard as the remote-access backbone unlocked a step-change in operational maturity:

• Accelerated remote lifecycle operations across Proxmox, Docke, and MikroTik
• Reduced cognitive load through a clean, declarative configuration footprint
• Improved security posture, replacing legacy tunnel solutions with a modern crypto suite
• Standardized access patterns for future scaling, including role-based peers and multi-device onboarding

This VPN stack is now a strategic enabler for my entire infrastructure portfolio.


Pros & Cons

A balanced view of the deployment:

Advantages
• Extremely lightweight footprint
• Enterprise-grade encryption with minimal compute overhead
• Containerized deployment eliminates configuration drift
• One-click peer onboarding through environment-driven automation

Limitations
• Requires port forwarding (not ideal for CGNAT environments)
• No built-in authentication beyond keypairs
• Monitoring metrics are minimal compared to heavier VPN solutions

These constraints open opportunities for upstream enhancements, such as Cloudflare Tunnels integration or SSO-based access gateways.


Conclusion

WireGuard served as the pivotal first step in unifying my distributed infrastructure footprint. It established the baseline connectivity layer that allowed my two sites to communicate securely, consistently, and with minimal operational overhead. Standing up this lightweight VPN created the initial bridge between Site A and Site B, enabling remote administration, automated workflows, and cross-site service integrations.

As my network strategy matured, I transitioned toward ZeroTier to unlock a more software-defined, mesh-based connectivity model. ZeroTier now provides a frictionless overlay that abstracts routing complexity, simplifies multi-site orchestration, and scales more naturally with my evolving DevOps environment. WireGuard laid the groundwork; ZeroTier is accelerating the next phase of my network modernization roadmap, positioning the entire stack for more dynamic, policy-driven connectivity in the future.