Major additions: - Storage abstraction layer with filesystem and in-memory implementations - Gitea API integration with MCP tools for repository management - Console dialog mode with interactive command execution - WireGuard VPN DNS fix implementation and documentation - HTTP client streaming response support - Router generic result type - Parameter type validator for framework core Framework enhancements: - Console command registry improvements - Console dialog components - Method signature analyzer updates - Route mapper refinements - MCP server and tool mapper updates - Queue job chain and dependency commands - Discovery tokenizer improvements Infrastructure: - Deployment architecture documentation - Ansible playbook updates for WireGuard client regeneration - Production environment configuration updates - Docker Compose local configuration updates - Remove obsolete docker-compose.yml (replaced by environment-specific configs) Documentation: - PERMISSIONS.md for access control guidelines - WireGuard DNS fix implementation details - Console dialog mode usage guide - Deployment architecture overview Testing: - Multi-purpose attribute tests - Gitea Actions integration tests (typed and untyped)
29 KiB
WireGuard VPN Implementation Plan
Ziel: Funktionsfähiges WireGuard VPN für sicheren Zugriff auf interne Services (Grafana, Traefik Dashboard)
Status: Analysephase abgeschlossen, Implementierungsplan erstellt
Datum: 2025-11-04
1. Current State Assessment
Server Configuration
- Host: michaelschiemer.de (94.16.110.151)
- Port: 51820/udp
- VPN Network: 10.8.0.0/24
- Server IP (VPN): 10.8.0.1
- Server Public Key: hT3OCWZ6ElX79YdAdexSsZnbWLzRM/5szk+XNEBUaS8=
Existing Infrastructure
✅ Ansible Automation (vollständig vorhanden):
setup-wireguard.yml- Server Installationadd-wireguard-client.yml- Client Creation mit Auto-IPregenerate-wireguard-client.yml- Client Regenerationtest-wireguard-docker-container.yml- Docker Testing
✅ Documentation (umfassend):
- WIREGUARD-SETUP.md - Komplette Setup-Dokumentation
- WIREGUARD-WINDOWS-ROUTING-FINAL-ANALYSIS.md - Windows Routing Problem
- WIREGUARD-WINDOWS-DNS-FIX.md - DNS Konfiguration
- WIREGUARD-RECREATE-AND-TEST.md - Troubleshooting Strategy
✅ Existing Clients (4 Konfigurationen):
grafana-latest.conftest-client.confmikepc.confgrafana-test.conf
Protected Services
- Traefik Dashboard: VPN-only + BasicAuth
- Grafana: VPN-only middleware
- Main App: Bleibt öffentlich (michaelschiemer.de)
2. Root Cause Analysis
Primary Issue: Windows Routing Problem
Symptome:
- WireGuard verbindet erfolgreich ✅
- Route vorhanden:
10.8.0.0/24✅ - Ping zu 10.8.0.1 funktioniert ✅
- ABER: HTTP/HTTPS Traffic kommt von Public IP (89.246.96.244) ❌
- Erwartet: Traffic sollte von VPN IP (10.8.0.7) kommen ❌
Diagnose (aus WIREGUARD-WINDOWS-ROUTING-FINAL-ANALYSIS.md):
Traefik Access Log zeigt:
89.246.96.244 - - [Date] "GET /grafana HTTP/2.0" 404
↑ Public IP statt 10.8.0.7
Root Causes (Priorisiert):
-
DNS fehlt in Client Config (Höchste Wahrscheinlichkeit):
- Windows nutzt Standard-DNS statt VPN-DNS
- Auflösung von
grafana.michaelschiemer.degeht über Public DNS - Traffic wird entsprechend über Public Interface geroutet
-
Windows Interface Metric Prioritization:
- Standard-Netzwerk hat niedrigeren Metric (höhere Priorität)
- WireGuard-Interface wird für HTTP/HTTPS-Traffic ignoriert
-
Split Tunneling Configuration:
AllowedIPs = 10.8.0.0/24limitiert VPN auf internes Netz- Windows könnte HTTP/HTTPS als "nicht-VPN" klassifizieren
Versuchte Lösungen (bisher erfolglos):
- ❌ Interface Metric Adjustment:
Set-NetIPInterface -InterfaceMetric 1 - ❌ Explicit Route mit Gateway:
route add 10.8.0.0 ... IF 18 - ❌ Windows Firewall Check
- ❌ WireGuard Reinstallation
Fehlende Lösung: DNS Configuration in Client Config
3. Implementation Strategy
OPTION A: DNS Fix (EMPFOHLEN) 🎯
Warum diese Option:
- Einfachste Lösung (eine Zeile in Config)
- Dokumentiert in WIREGUARD-WINDOWS-DNS-FIX.md
- Adressiert wahrscheinlichste Root Cause
- Keine Server-Änderungen nötig
- Geringe Auswirkung auf existierende Clients
Implementierung:
Schritt 1: Server Status verifizieren
# SSH zum Server
ssh deploy@michaelschiemer.de
# WireGuard Service prüfen
sudo systemctl status wg-quick@wg0
# Erwartete Ausgabe:
# ● wg-quick@wg0.service - WireGuard via wg-quick(8) for wg0
# Loaded: loaded
# Active: active (exited)
# Interface prüfen
sudo wg show
# Erwartete Ausgabe:
# interface: wg0
# public key: hT3OCWZ6ElX79YdAdexSsZnbWLzRM/5szk+XNEBUaS8=
# private key: (hidden)
# listening port: 51820
Schritt 2: Client Config mit DNS regenerieren
Ansible Template Update (wireguard-client.conf.j2):
[Interface]
PrivateKey = {{ client_private_key.stdout }}
Address = {{ client_ip }}/24
DNS = 10.8.0.1 # ← NEU: VPN-DNS Server
[Peer]
PublicKey = {{ server_public_key_cmd.stdout }}
Endpoint = {{ server_external_ip_content }}:{{ wireguard_port }}
AllowedIPs = {{ allowed_ips }}
PersistentKeepalive = 25
Playbook Ausführen:
cd /home/michael/dev/michaelschiemer/deployment/ansible
# Client Config regenerieren (mit DNS)
ansible-playbook -i inventory/production.yml \
playbooks/regenerate-wireguard-client.yml \
-e "client_name=mikepc" \
-e "client_ip=10.8.0.5"
Schritt 3: Mit Docker Container testen
# Container-Test für Baseline
ansible-playbook -i inventory/production.yml \
playbooks/test-wireguard-docker-container.yml \
-e "client_name=mikepc"
# Erwartete Ausgabe:
# ✓ Container gestartet
# ✓ WireGuard verbunden
# ✓ Ping zu 10.8.0.1 erfolgreich
# ✓ HTTP Request zu Grafana zeigt VPN IP im Log
Schritt 4: Windows Client Setup
Config herunterladen:
# Config wird automatisch heruntergeladen nach:
# /home/michael/dev/michaelschiemer/deployment/ansible/wireguard-clients/mikepc.conf
Windows Installation:
- WireGuard GUI öffnen
- "Import tunnel(s) from file"
mikepc.confauswählen- Tunnel aktivieren
Verification (PowerShell als Admin):
# 1. DNS Check - WICHTIG!
Get-DnsClientServerAddress | Select-Object InterfaceAlias, ServerAddresses
# Erwartete Ausgabe:
# InterfaceAlias ServerAddresses
# -------------- ---------------
# WireGuard Tunnel {10.8.0.1} ← VPN DNS!
# 2. DNS Resolution Test
Resolve-DnsName grafana.michaelschiemer.de | Select-Object Name, IPAddress
# Erwartete Ausgabe:
# Name IPAddress
# ---- ---------
# grafana.michaelschiemer.de 10.8.0.1 ← VPN IP, NICHT Public IP!
# 3. Ping Test
ping 10.8.0.1
# Erwartete Ausgabe:
# Reply from 10.8.0.1: bytes=32 time=25ms TTL=64
# 4. HTTP Test (via Browser)
# https://grafana.michaelschiemer.de
# Sollte funktionieren und Traefik Log sollte 10.8.0.5 zeigen
Schritt 5: Traefik Log Verification
# SSH zum Server
ssh deploy@michaelschiemer.de
# Traefik Access Log live anzeigen
docker logs -f traefik 2>&1 | grep grafana
# VORHER (falsch):
# 89.246.96.244 - - [Date] "GET /grafana HTTP/2.0" 404
# NACHHER (korrekt):
# 10.8.0.5 - - [Date] "GET /grafana HTTP/2.0" 200
# ↑ VPN IP des Windows Client!
SUCCESS CRITERIA:
- ✅ DNS resolves
grafana.michaelschiemer.dezu10.8.0.1 - ✅ Traefik Log zeigt VPN IP (
10.8.0.5) statt Public IP - ✅ Grafana Dashboard erreichbar ohne 404
- ✅ Ping zu 10.8.0.1 erfolgreich
OPTION B: Full Tunnel VPN (Fallback)
Nur verwenden wenn Option A fehlschlägt!
Änderungen:
[Peer]
AllowedIPs = 0.0.0.0/0 # ← Ändere von 10.8.0.0/24
# Routet ALLE Traffic durch VPN
Vorteile:
- Erzwingt VPN-Routing für alle Verbindungen
- Umgeht Windows Routing-Probleme
Nachteile:
- ❌ Alle Traffic über VPN (Performance-Impact)
- ❌ Lokales Netzwerk (Drucker, etc.) nicht erreichbar
- ❌ SSH zu Server über Public IP funktioniert nicht mehr
- ❌ Komplexere Firewall-Konfiguration nötig
Implementierung (nur wenn nötig):
- Template
wireguard-client.conf.j2ändern - Server-Firewall für NAT konfigurieren
- Client regenerieren und testen
OPTION C: Alternative VPN Software (Letzte Option)
Nur wenn Option A und B fehlschlagen!
Alternativen:
- OpenVPN: Mature, Windows-freundlich, mehr Overhead
- Tailscale: Mesh VPN, einfacher Setup, closed source
- ZeroTier: Ähnlich zu Tailscale, eigenes Netzwerk-Paradigma
Nicht empfohlen weil:
- WireGuard ist moderner und schneller
- Existing Infrastructure ist gut aufgebaut
- Problem ist wahrscheinlich nur DNS-Konfiguration
- Ansible Automation müsste neu geschrieben werden
4. Step-by-Step Implementation Guide
Phase 1: Preparation (5 Minuten)
# 1. Zum Ansible Verzeichnis navigieren
cd /home/michael/dev/michaelschiemer/deployment/ansible
# 2. Inventory prüfen
cat inventory/production.yml
# 3. Ansible Connectivity Test
ansible -i inventory/production.yml production -m ping
# Erwartete Ausgabe:
# michaelschiemer.de | SUCCESS => {
# "changed": false,
# "ping": "pong"
# }
Phase 2: Template Update (2 Minuten)
# DNS Zeile zu Client Template hinzufügen
# templates/wireguard-client.conf.j2
# Öffne Template:
nano templates/wireguard-client.conf.j2
# Füge unter [Interface] hinzu:
# DNS = {{ wireguard_server_ip }}
Template-Inhalt (complete):
[Interface]
PrivateKey = {{ client_private_key.stdout }}
Address = {{ client_ip }}/24
DNS = {{ wireguard_server_ip }} # ← HINZUFÜGEN
[Peer]
PublicKey = {{ server_public_key_cmd.stdout }}
Endpoint = {{ server_external_ip_content }}:{{ wireguard_port }}
AllowedIPs = {{ allowed_ips }}
PersistentKeepalive = 25
Phase 3: Client Regeneration (3 Minuten)
# Windows Client neu generieren
ansible-playbook -i inventory/production.yml \
playbooks/regenerate-wireguard-client.yml \
-e "client_name=mikepc" \
-e "client_ip=10.8.0.5"
# Config wird automatisch heruntergeladen nach:
# wireguard-clients/mikepc.conf
# Verify DNS in Config:
cat wireguard-clients/mikepc.conf | grep DNS
# Erwartete Ausgabe:
# DNS = 10.8.0.1
Phase 4: Docker Container Test (5 Minuten)
# Container-Test durchführen
ansible-playbook -i inventory/production.yml \
playbooks/test-wireguard-docker-container.yml \
-e "client_name=mikepc"
# Playbook führt aus:
# 1. Container Start mit WireGuard
# 2. Ping zu 10.8.0.1
# 3. HTTP Test zu Grafana
# 4. Log Verification
# Check Container Logs:
docker logs wireguard-test-mikepc
# Erwartete Ausgabe:
# [cont-init.d] 10-adduser: exited 0.
# [cont-init.d] 30-config: executing...
# [cont-init.d] 30-config: exited 0.
# [cont-init.d] 99-custom-scripts: executing...
# [cont-init.d] done.
# [services.d] starting services
# [services.d] done.
Phase 5: Windows Client Import (3 Minuten)
Schritte:
-
Alte WireGuard Konfiguration entfernen:
- WireGuard GUI öffnen
- Rechtsklick auf "mikepc" Tunnel
- "Remove" auswählen
-
Neue Konfiguration importieren:
- "Import tunnel(s) from file"
- Navigation zu:
\\wsl$\Ubuntu\home\michael\dev\michaelschiemer\deployment\ansible\wireguard-clients\mikepc.conf - Import bestätigen
-
Tunnel aktivieren:
- Klick auf "Activate"
Phase 6: Verification (5 Minuten)
PowerShell Tests (als Administrator):
# 1. Interface Check
Get-NetAdapter | Where-Object {$_.InterfaceDescription -like "*WireGuard*"}
# Erwartete Ausgabe:
# Name Status MacAddress LinkSpeed
# ---- ------ ---------- ---------
# WireGuard Up 00-00-00-00-00 Gbps
# 2. DNS Configuration Check
Get-DnsClientServerAddress | Where-Object {$_.InterfaceAlias -like "*WireGuard*"}
# Erwartete Ausgabe:
# InterfaceAlias ServerAddresses
# -------------- ---------------
# WireGuard {10.8.0.1}
# 3. DNS Resolution Test
Resolve-DnsName grafana.michaelschiemer.de
# Erwartete Ausgabe:
# Name IPAddress
# ---- ---------
# grafana.michaelschiemer.de 10.8.0.1
# 4. Connectivity Test
Test-NetConnection 10.8.0.1 -Port 443
# Erwartete Ausgabe:
# ComputerName : 10.8.0.1
# RemoteAddress : 10.8.0.1
# RemotePort : 443
# TcpTestSucceeded : True
# 5. Traefik Dashboard Test (Browser)
# https://traefik.michaelschiemer.de
# Username: admin
# Password: [aus .env]
Server-Side Verification:
# SSH zum Server
ssh deploy@michaelschiemer.de
# 1. WireGuard Status
sudo wg show
# Erwartete Ausgabe:
# interface: wg0
# public key: hT3OCWZ6ElX79YdAdexSsZnbWLzRM/5szk+XNEBUaS8=
# private key: (hidden)
# listening port: 51820
#
# peer: [mikepc public key]
# endpoint: 89.246.96.244:xxxxx
# allowed ips: 10.8.0.5/32
# latest handshake: X seconds ago
# transfer: X.XX GiB received, X.XX GiB sent
# 2. Traefik Access Log (live)
docker logs -f traefik 2>&1 | grep -E "10\.8\.0\.[0-9]+"
# Erwartete Ausgabe:
# 10.8.0.5 - - [Date] "GET /grafana HTTP/2.0" 200 ...
# ↑ VPN IP sichtbar!
# 3. CoreDNS Logs (falls DNS problematisch)
docker logs coredns 2>&1 | tail -20
Phase 7: Troubleshooting (falls nötig)
Problem: DNS nicht gesetzt
# Manual DNS Override
Set-DnsClientServerAddress -InterfaceAlias "WireGuard" -ServerAddresses "10.8.0.1"
# Verify
Get-DnsClientServerAddress | Where-Object {$_.InterfaceAlias -like "*WireGuard*"}
Problem: Route nicht aktiv
# Check Routing Table
route print | findstr "10.8.0.0"
# Erwartete Ausgabe:
# 10.8.0.0 255.255.255.0 On-link 10.8.0.5 281
# Falls fehlt, manuell hinzufügen:
route add 10.8.0.0 MASK 255.255.255.0 10.8.0.1 IF [Interface-Index]
Problem: Traffic kommt weiterhin von Public IP
# Server: tcpdump auf WireGuard Interface
ssh deploy@michaelschiemer.de
sudo tcpdump -i wg0 -n
# Erwartete Ausgabe beim Browser-Zugriff:
# IP 10.8.0.5.xxxxx > 10.8.0.1.443: Flags [S], seq ...
# ↑ Client IP ↑ Server IP
5. Testing Checklist
✅ Server-Side Tests
# Test 1: Service Running
sudo systemctl status wg-quick@wg0
# Expected: active (exited)
# Test 2: Interface Up
ip addr show wg0
# Expected: inet 10.8.0.1/24 scope global wg0
# Test 3: Firewall Rule
sudo ufw status | grep 51820
# Expected: 51820/udp ALLOW Anywhere
# Test 4: Peer Connected
sudo wg show
# Expected: peer: [client public key]
# latest handshake: < 3 minutes ago
# Test 5: IP Forwarding Enabled
sysctl net.ipv4.ip_forward
# Expected: net.ipv4.ip_forward = 1
# Test 6: NAT Masquerading Active
sudo iptables -t nat -L POSTROUTING -n -v
# Expected: MASQUERADE all -- 0.0.0.0/0 0.0.0.0/0
✅ Client-Side Tests (Windows)
# Test 1: WireGuard Connected
Get-NetAdapter | Where-Object {$_.InterfaceDescription -like "*WireGuard*"}
# Expected: Status = Up
# Test 2: DNS Configured
Get-DnsClientServerAddress -InterfaceAlias "WireGuard"
# Expected: ServerAddresses = {10.8.0.1}
# Test 3: Ping VPN Gateway
ping 10.8.0.1
# Expected: Reply from 10.8.0.1: bytes=32 time<50ms
# Test 4: DNS Resolution
Resolve-DnsName grafana.michaelschiemer.de
# Expected: IPAddress = 10.8.0.1
# Test 5: HTTPS Connectivity
Test-NetConnection 10.8.0.1 -Port 443
# Expected: TcpTestSucceeded = True
# Test 6: Browser Access
# https://grafana.michaelschiemer.de
# Expected: Grafana Dashboard loads (no 404)
# Test 7: Traefik Dashboard Access
# https://traefik.michaelschiemer.de
# Expected: Traefik Dashboard loads (BasicAuth prompt)
✅ Log Verification
# Test 1: Traefik Access Log shows VPN IP
ssh deploy@michaelschiemer.de
docker logs traefik 2>&1 | grep -E "10\.8\.0\.[0-9]+" | tail -5
# Expected:
# 10.8.0.5 - - [Date] "GET /grafana HTTP/2.0" 200 ...
# Test 2: CoreDNS Resolution Log
docker logs coredns 2>&1 | grep grafana | tail -5
# Expected:
# [INFO] 10.8.0.5:xxxxx - "A IN grafana.michaelschiemer.de udp 45 false 512"
6. Client Setup Instructions
Windows Client
Prerequisites:
- Windows 10/11
- Administrator Rechte
- WireGuard for Windows installiert
Setup:
- Config generieren lassen (siehe Phase 3)
- Config importieren (siehe Phase 5)
- Tunnel aktivieren
- Tests durchführen (siehe Phase 6)
Config Location: C:\Program Files\WireGuard\Data\Configurations\mikepc.conf
Linux Client
Prerequisites:
sudo apt update
sudo apt install wireguard wireguard-tools
Setup:
# 1. Config generieren
ansible-playbook -i inventory/production.yml \
playbooks/add-wireguard-client.yml \
-e "client_name=linux-laptop" \
-e "client_ip=10.8.0.10"
# 2. Config kopieren
sudo cp wireguard-clients/linux-laptop.conf /etc/wireguard/wg0.conf
sudo chmod 600 /etc/wireguard/wg0.conf
# 3. Interface starten
sudo wg-quick up wg0
# 4. Bei Bedarf: Auto-Start bei Boot
sudo systemctl enable wg-quick@wg0
# 5. Status prüfen
sudo wg show
# 6. Test
ping 10.8.0.1
curl -k https://grafana.michaelschiemer.de
macOS Client
Prerequisites:
brew install wireguard-tools
Setup:
- WireGuard App aus App Store installieren
- Config importieren (wie Windows)
- Tunnel aktivieren
Android/iOS Client
Setup:
- WireGuard App installieren (Play Store/App Store)
- QR Code scannen:
# QR Code für mobilen Import generieren ansible-playbook -i inventory/production.yml \ playbooks/add-wireguard-client.yml \ -e "client_name=android-phone" \ -e "client_ip=10.8.0.15" # QR Code wird automatisch generiert: # wireguard-clients/android-phone.conf.png - In App: "Add Tunnel" → "Create from QR Code"
- Scannen und aktivieren
7. Monitoring & Maintenance
Daily Checks
# Server Health Check
ssh deploy@michaelschiemer.de 'sudo wg show | grep "latest handshake"'
# Erwartete Ausgabe:
# latest handshake: 2 minutes 30 seconds ago
# latest handshake: 5 minutes 10 seconds ago
Weekly Maintenance
# 1. Check for security updates
ssh deploy@michaelschiemer.de 'sudo apt update && sudo apt list --upgradable | grep wireguard'
# 2. Review Traefik Logs für VPN Traffic
ssh deploy@michaelschiemer.de \
'docker logs traefik 2>&1 | grep -E "10\.8\.0\.[0-9]+" | wc -l'
# 3. Unused Clients entfernen
# Liste aller Clients mit letztem Handshake
sudo wg show | grep -E "(peer|latest handshake)"
Backup Strategy
# 1. Server Config Backup
ssh deploy@michaelschiemer.de 'sudo cat /etc/wireguard/wg0.conf' > backup-wg0.conf-$(date +%F)
# 2. Client Configs Backup
tar -czf wireguard-clients-backup-$(date +%F).tar.gz wireguard-clients/
# 3. Ansible Playbooks Backup (via git)
cd /home/michael/dev/michaelschiemer/deployment/ansible
git add playbooks/ templates/ group_vars/
git commit -m "backup: WireGuard configuration $(date +%F)"
8. Troubleshooting Guide
Problem: Client verbindet nicht
Symptome:
- WireGuard Status: "Disconnected"
- Keine Handshake im Server Log
Diagnose:
# Server: Check Firewall
ssh deploy@michaelschiemer.de 'sudo ufw status | grep 51820'
# Server: Check Service
ssh deploy@michaelschiemer.de 'sudo systemctl status wg-quick@wg0'
# Client: Check Config Syntax
# Windows: C:\Program Files\WireGuard\log.txt
# Linux: journalctl -u wg-quick@wg0
Lösungen:
- Firewall öffnen:
sudo ufw allow 51820/udp - Service neu starten:
sudo systemctl restart wg-quick@wg0 - Config-Syntax prüfen:
sudo wg-quick up wg0(zeigt Fehler)
Problem: DNS Resolution schlägt fehl
Symptome:
- Ping zu 10.8.0.1 funktioniert ✅
Resolve-DnsName grafana.michaelschiemer.dezeigt Public IP ❌
Diagnose:
# Check DNS Server
Get-DnsClientServerAddress -InterfaceAlias "WireGuard"
# Expected: ServerAddresses = {10.8.0.1}
# Actual: ServerAddresses = {} (leer)
Lösung:
# Manual DNS Set
Set-DnsClientServerAddress -InterfaceAlias "WireGuard" -ServerAddresses "10.8.0.1"
# Persistent DNS (in Config):
# [Interface]
# DNS = 10.8.0.1 ← Diese Zeile muss vorhanden sein!
Problem: Traefik zeigt weiterhin Public IP
Symptome:
- WireGuard verbunden ✅
- DNS resolved zu 10.8.0.1 ✅
- Traefik Log zeigt:
89.246.96.244 - - "GET /grafana ..."❌
Diagnose:
# Routing Table Check
route print | findstr "10.8.0.0"
# Interface Metric Check
Get-NetIPInterface | Where-Object {$_.AddressFamily -eq "IPv4"} | Sort-Object InterfaceMetric
Lösung:
# Option 1: Interface Metric senken
$WgIndex = (Get-NetAdapter | Where-Object {$_.InterfaceDescription -like "*WireGuard*"}).ifIndex
Set-NetIPInterface -InterfaceIndex $WgIndex -InterfaceMetric 1
# Option 2: Explicit Route mit niedrigem Metric
route add 10.8.0.0 MASK 255.255.255.0 10.8.0.1 METRIC 1 IF $WgIndex
# Verify
route print | findstr "10.8.0.0"
Problem: Handshake schlägt fehl
Symptome:
- Server Log:
latest handshake: never - Client bleibt auf "Connecting"
Diagnose:
# Server: tcpdump auf Port 51820
ssh deploy@michaelschiemer.de
sudo tcpdump -i any -n port 51820
# Erwartete Ausgabe:
# IP [client-public-ip].xxxxx > 94.16.110.151.51820: UDP
Lösungen:
-
Firewall Issue:
sudo ufw allow 51820/udp sudo ufw reload -
NAT Issue (Client hinter Router):
- Router-Firewall prüfen
- Port Forwarding nicht nötig (ausgehend)
- PersistentKeepalive erhöhen:
PersistentKeepalive = 25
-
Clock Skew Issue:
# Server: Zeit prüfen ssh deploy@michaelschiemer.de 'date' # Client: Zeit prüfen date # Linux/macOS Get-Date # Windows # Bei Abweichung: NTP sync sudo ntpdate pool.ntp.org
Problem: Peer-to-Peer nicht möglich
Symptome:
- Ping zu 10.8.0.1 funktioniert ✅
- Ping zu anderem Client (z.B. 10.8.0.10) schlägt fehl ❌
Root Cause:
- AllowedIPs limitiert auf Server IP nur
Lösung:
# Server Config ändern (/etc/wireguard/wg0.conf)
[Peer]
# For client 10.8.0.5
PublicKey = [client-public-key]
AllowedIPs = 10.8.0.5/32, 10.8.0.0/24 # ← Network hinzufügen
# Restart
sudo wg-quick down wg0
sudo wg-quick up wg0
9. Performance Optimization
Server-Side Tuning
# /etc/sysctl.conf
net.ipv4.ip_forward = 1
net.core.default_qdisc = fq
net.ipv4.tcp_congestion_control = bbr
net.core.rmem_max = 2500000
net.core.wmem_max = 2500000
# Apply
sudo sysctl -p
Client-Side Tuning (Windows)
# MTU Optimization
netsh interface ipv4 set subinterface "WireGuard" mtu=1420 store=persistent
# Registry Tweaks (optional)
# HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
# - TcpAckFrequency = 1
# - TCPNoDelay = 1
10. Security Hardening
Key Rotation Policy
Empfehlung: Keys alle 6 Monate rotieren
# 1. Neuen Client mit neuen Keys generieren
ansible-playbook -i inventory/production.yml \
playbooks/regenerate-wireguard-client.yml \
-e "client_name=mikepc" \
-e "client_ip=10.8.0.5"
# 2. Alte Config entfernen (nach Verification)
# Server: /etc/wireguard/wg0.conf - alten Peer-Block löschen
# 3. Server neu starten
ssh deploy@michaelschiemer.de 'sudo wg-quick down wg0 && sudo wg-quick up wg0'
Access Logging
Traefik Access Log für VPN-Only Services:
# docker-compose.yml (bereits konfiguriert)
services:
traefik:
command:
- --accesslog=true
- --accesslog.filepath=/var/log/traefik/access.log
- --accesslog.filters.statusCodes=200,404,403
Log Analysis:
# Daily Report: VPN Zugriffe
ssh deploy@michaelschiemer.de \
'docker exec traefik cat /var/log/traefik/access.log | grep -E "10\.8\.0\.[0-9]+" | tail -20'
# Weekly Report: Failed Auth Attempts
ssh deploy@michaelschiemer.de \
'docker exec traefik cat /var/log/traefik/access.log | grep "401\|403" | wc -l'
Fail2Ban Integration (Optional)
# /etc/fail2ban/filter.d/wireguard.conf
[Definition]
failregex = Invalid handshake from <HOST>
ignoreregex =
# /etc/fail2ban/jail.local
[wireguard]
enabled = true
port = 51820
protocol = udp
filter = wireguard
logpath = /var/log/syslog
maxretry = 5
bantime = 3600
11. Migration Path (Falls Option A fehlschlägt)
Plan B: Full Tunnel VPN
Nur wenn DNS-Fix nicht funktioniert!
Changes Required:
- Client Config Template Update:
[Peer]
AllowedIPs = 0.0.0.0/0, ::/0 # ← Ändere von 10.8.0.0/24
- Server NAT Configuration:
# /etc/wireguard/wg0.conf
PostUp = iptables -A FORWARD -i %i -j ACCEPT; \
iptables -A FORWARD -o %i -j ACCEPT; \
iptables -t nat -A POSTROUTING -o ens3 -j MASQUERADE
PostDown = iptables -D FORWARD -i %i -j ACCEPT; \
iptables -D FORWARD -o %i -j ACCEPT; \
iptables -t nat -D POSTROUTING -o ens3 -j MASQUERADE
- Split Tunneling Exceptions (für lokales Netzwerk):
# Windows: Route für lokales Netz außerhalb VPN
route add 192.168.0.0 MASK 255.255.255.0 192.168.0.1 METRIC 1
Trade-offs:
- ✅ Pro: Forciert VPN für alle Verbindungen
- ❌ Con: Performance-Impact (alle Traffic durch VPN)
- ❌ Con: Lokales Netzwerk (Drucker, NAS) nicht direkt erreichbar
- ❌ Con: SSH zu Server nur über VPN möglich
12. Next Steps
Immediate Actions (Nächste 30 Minuten)
-
✅ Template Update:
nano /home/michael/dev/michaelschiemer/deployment/ansible/templates/wireguard-client.conf.j2 # DNS = {{ wireguard_server_ip }} hinzufügen -
✅ Client Regeneration:
cd /home/michael/dev/michaelschiemer/deployment/ansible ansible-playbook -i inventory/production.yml \ playbooks/regenerate-wireguard-client.yml \ -e "client_name=mikepc" \ -e "client_ip=10.8.0.5" -
✅ Docker Test:
ansible-playbook -i inventory/production.yml \ playbooks/test-wireguard-docker-container.yml \ -e "client_name=mikepc" -
✅ Windows Import:
- Config importieren
- Tunnel aktivieren
- Tests durchführen
Short-Term (Nächste Woche)
- ✅ Alle existierenden Clients mit DNS-Config aktualisieren
- ✅ Monitoring Setup für WireGuard Handshakes
- ✅ Backup-Strategie implementieren
- ✅ Dokumentation in Wiki übertragen
Long-Term (Nächster Monat)
- ✅ Key Rotation Policy dokumentieren und schedulen
- ✅ Fail2Ban Integration evaluieren
- ✅ Performance Tuning basierend auf Logs
- ✅ Mobile Clients für Admin Team einrichten
13. Success Metrics
KPIs für erfolgreiche Implementation
| Metric | Target | Current | Status |
|---|---|---|---|
| VPN Handshake Success Rate | >99% | TBD | 🟡 |
| DNS Resolution zu VPN IP | 100% | TBD | 🟡 |
| Traefik Log zeigt VPN IP | 100% | 0% | 🔴 |
| Grafana Erreichbarkeit | 100% | TBD | 🟡 |
| Latenz zu 10.8.0.1 | <50ms | TBD | 🟡 |
| Client Setup Time | <10min | TBD | 🟡 |
Update nach Implementation: Metrics werden nach Phase 6 aktualisiert.
14. Risk Assessment
Risks & Mitigation
| Risk | Probability | Impact | Mitigation |
|---|---|---|---|
| DNS-Fix löst Problem nicht | Low | Medium | Plan B: Full Tunnel VPN |
| Windows Routing weiterhin problematisch | Medium | High | Plan C: OpenVPN als Fallback |
| Existing Clients brechen | Low | Low | Backup Configs vorhanden |
| Performance Degradation | Low | Medium | Performance Monitoring, Tuning |
| Security Incident | Very Low | High | Key Rotation, Access Logging, Fail2Ban |
Rollback Plan
Falls Implementation fehlschlägt:
-
Clients zurücksetzen:
# Restore old config cp wireguard-clients/mikepc.conf.backup-[timestamp] \ wireguard-clients/mikepc.conf -
Template zurücksetzen:
git checkout templates/wireguard-client.conf.j2 -
Server unverändert: Keine Server-Änderungen nötig für Option A
Rollback Time: <5 Minuten
15. Contacts & Support
Internal Contacts
Primary Admin: michael@michaelschiemer.de
Server: michaelschiemer.de (94.16.110.151)
SSH User: deploy
Ansible Location: /home/michael/dev/michaelschiemer/deployment/ansible
External Resources
- WireGuard Docs: https://www.wireguard.com/quickstart/
- Ansible WireGuard Module: https://galaxy.ansible.com/githubixx/ansible_role_wireguard
- Windows Troubleshooting: https://www.wireguard.com/known-limitations/
Support Channels
- GitHub Issues: (Falls applicable)
- WireGuard Mailing List: wireguard@lists.zx2c4.com
Appendix: Quick Reference
Useful Commands
# Server Status
ssh deploy@michaelschiemer.de 'sudo wg show'
# Client Generation
ansible-playbook -i inventory/production.yml playbooks/add-wireguard-client.yml \
-e "client_name=NEW_CLIENT" -e "client_ip=10.8.0.X"
# Container Test
ansible-playbook -i inventory/production.yml playbooks/test-wireguard-docker-container.yml \
-e "client_name=CLIENT"
# Log Monitoring
ssh deploy@michaelschiemer.de 'docker logs -f traefik 2>&1 | grep -E "10\.8\.0\.[0-9]+"'
# Client Regeneration
ansible-playbook -i inventory/production.yml playbooks/regenerate-wireguard-client.yml \
-e "client_name=CLIENT" -e "client_ip=10.8.0.X"
Config Locations
- Server Config:
/etc/wireguard/wg0.conf - Client Configs:
/home/michael/dev/michaelschiemer/deployment/ansible/wireguard-clients/ - Templates:
/home/michael/dev/michaelschiemer/deployment/ansible/templates/ - Windows Config:
C:\Program Files\WireGuard\Data\Configurations\ - Linux Config:
/etc/wireguard/wg0.conf
IP Allocation
| IP Address | Hostname | Client | Status |
|---|---|---|---|
| 10.8.0.1 | michaelschiemer.de | Server | Active |
| 10.8.0.5 | mikepc | Windows Client | Pending |
| 10.8.0.7 | grafana-test | Test Client | Unknown |
| 10.8.0.10-254 | - | Available | Free |
Plan Status: ✅ READY FOR IMPLEMENTATION Empfohlene Option: Option A (DNS Fix) Estimated Implementation Time: 30 Minuten Rollback Risk: LOW Success Probability: HIGH (>80%)
Ende des Implementierungsplans
Nächster Schritt: Template Update (Phase 2) durchführen und Client regenerieren (Phase 3).