Remove WireGuard integration from production deployment to simplify infrastructure: - Remove docker-compose-direct-access.yml (VPN-bound services) - Remove VPN-only middlewares from Grafana, Prometheus, Portainer - Remove WireGuard middleware definitions from Traefik - Remove WireGuard IPs (10.8.0.0/24) from Traefik forwarded headers All monitoring services now publicly accessible via subdomains: - grafana.michaelschiemer.de (with Grafana native auth) - prometheus.michaelschiemer.de (with Basic Auth) - portainer.michaelschiemer.de (with Portainer native auth) All services use Let's Encrypt SSL certificates via Traefik.
276 lines
6.0 KiB
Markdown
276 lines
6.0 KiB
Markdown
# WireGuard Installation Log
|
|
|
|
Dokumentation der manuellen WireGuard Installation auf dem Host-System.
|
|
|
|
## Systemumgebung
|
|
|
|
```bash
|
|
# System prüfen
|
|
uname -a
|
|
# Linux hostname 6.6.87.2-microsoft-standard-WSL2 #1 SMP ...
|
|
|
|
# WireGuard Version
|
|
wg --version
|
|
# wireguard-tools v1.0.20210914
|
|
|
|
# Netzwerk Interface
|
|
ip addr show
|
|
# Haupt-Interface für WAN: eth0
|
|
```
|
|
|
|
## Installation durchgeführt am
|
|
|
|
**Datum**: [WIRD BEIM AUSFÜHREN GESETZT]
|
|
**Benutzer**: root (via sudo)
|
|
**Methode**: Manual Setup Script
|
|
|
|
## Installationsschritte
|
|
|
|
### ✅ Schritt 1: Verzeichnis erstellen
|
|
|
|
```bash
|
|
sudo mkdir -p /etc/wireguard
|
|
sudo chmod 700 /etc/wireguard
|
|
```
|
|
|
|
**Status**: Bereit für Ausführung
|
|
**Zweck**: Sicheres Verzeichnis für WireGuard-Konfiguration
|
|
|
|
### ✅ Schritt 2: Server Keys generieren
|
|
|
|
```bash
|
|
cd /etc/wireguard
|
|
sudo wg genkey | sudo tee server_private.key | sudo wg pubkey | sudo tee server_public.key
|
|
sudo chmod 600 server_private.key
|
|
sudo chmod 644 server_public.key
|
|
```
|
|
|
|
**Status**: Bereit für Ausführung
|
|
**Zweck**: Kryptographische Schlüssel für Server generieren
|
|
**Ausgabe**:
|
|
- `server_private.key` - Privater Schlüssel (geheim!)
|
|
- `server_public.key` - Öffentlicher Schlüssel (für Clients)
|
|
|
|
### ✅ Schritt 3: WireGuard Konfiguration erstellen
|
|
|
|
**Datei**: `/etc/wireguard/wg0.conf`
|
|
|
|
```ini
|
|
[Interface]
|
|
# Server Configuration
|
|
PrivateKey = [GENERATED_SERVER_PRIVATE_KEY]
|
|
Address = 10.8.0.1/24
|
|
ListenPort = 51820
|
|
|
|
# Enable IP forwarding
|
|
PostUp = sysctl -w net.ipv4.ip_forward=1
|
|
|
|
# NAT Configuration with nftables
|
|
PostUp = nft add table inet wireguard
|
|
PostUp = nft add chain inet wireguard postrouting { type nat hook postrouting priority srcnat\; }
|
|
PostUp = nft add rule inet wireguard postrouting oifname "eth0" ip saddr 10.8.0.0/24 masquerade
|
|
|
|
# Cleanup on shutdown
|
|
PostDown = nft delete table inet wireguard
|
|
|
|
# Peers will be added here via generate-client-config.sh
|
|
```
|
|
|
|
**Status**: Template erstellt
|
|
**Permissions**: `chmod 600 /etc/wireguard/wg0.conf`
|
|
|
|
### ✅ Schritt 4: nftables Firewall Rules
|
|
|
|
**Datei**: `/etc/nftables.d/wireguard.nft`
|
|
|
|
Features:
|
|
- VPN Network Set: `10.8.0.0/24`
|
|
- Admin Service Ports: `8080, 9090, 3001, 9000, 8001`
|
|
- Public Service Ports: `80, 443, 22`
|
|
- Rate Limiting für SSH: `10/minute`
|
|
- Logging für blockierte Zugriffe
|
|
|
|
**Status**: Template erstellt
|
|
**Anwendung**: `sudo nft -f /etc/nftables.d/wireguard.nft`
|
|
|
|
### ✅ Schritt 5: IP Forwarding aktivieren
|
|
|
|
```bash
|
|
echo "net.ipv4.ip_forward=1" | sudo tee /etc/sysctl.d/99-wireguard.conf
|
|
sudo sysctl -p /etc/sysctl.d/99-wireguard.conf
|
|
```
|
|
|
|
**Status**: Bereit für Ausführung
|
|
**Zweck**: Ermöglicht Paket-Weiterleitung zwischen VPN und Host-Netzwerk
|
|
|
|
### ✅ Schritt 6: WireGuard Service aktivieren
|
|
|
|
```bash
|
|
sudo systemctl enable wg-quick@wg0
|
|
sudo systemctl start wg-quick@wg0
|
|
```
|
|
|
|
**Status**: Bereit für Ausführung
|
|
**Zweck**: WireGuard als systemd Service starten und bei Boot aktivieren
|
|
|
|
## Verifikation
|
|
|
|
### WireGuard Status prüfen
|
|
|
|
```bash
|
|
sudo wg show wg0
|
|
# Erwartete Ausgabe:
|
|
# interface: wg0
|
|
# public key: [SERVER_PUBLIC_KEY]
|
|
# private key: (hidden)
|
|
# listening port: 51820
|
|
```
|
|
|
|
### Service Status prüfen
|
|
|
|
```bash
|
|
sudo systemctl status wg-quick@wg0
|
|
# Erwartete Ausgabe:
|
|
# ● wg-quick@wg0.service - WireGuard via wg-quick(8) for wg0
|
|
# Loaded: loaded
|
|
# Active: active (exited) since ...
|
|
```
|
|
|
|
### nftables Rules prüfen
|
|
|
|
```bash
|
|
sudo nft list table inet wireguard_firewall
|
|
# Sollte alle Rules anzeigen
|
|
```
|
|
|
|
### Netzwerk-Konnektivität prüfen
|
|
|
|
```bash
|
|
# Interface prüfen
|
|
ip addr show wg0
|
|
# Sollte 10.8.0.1/24 zeigen
|
|
|
|
# Routing prüfen
|
|
ip route | grep wg0
|
|
# Sollte Route für 10.8.0.0/24 zeigen
|
|
|
|
# Firewall prüfen
|
|
sudo nft list ruleset | grep wireguard
|
|
```
|
|
|
|
## Nächste Schritte
|
|
|
|
### 1. Client-Konfiguration generieren
|
|
|
|
```bash
|
|
cd /home/michael/dev/michaelschiemer/deployment/scripts
|
|
sudo ./generate-client-config.sh michael-laptop
|
|
```
|
|
|
|
### 2. Client-Config importieren
|
|
|
|
- **Linux/macOS**: Copy `.conf` file to `/etc/wireguard/`
|
|
- **Windows**: Import via WireGuard GUI
|
|
- **iOS/Android**: Scan QR code
|
|
|
|
### 3. Verbindung testen
|
|
|
|
```bash
|
|
# Vom Client aus:
|
|
ping 10.8.0.1
|
|
|
|
# Admin-Services testen:
|
|
curl -k https://10.8.0.1:8080 # Traefik Dashboard
|
|
curl http://10.8.0.1:9090 # Prometheus
|
|
```
|
|
|
|
## Troubleshooting
|
|
|
|
### WireGuard startet nicht
|
|
|
|
```bash
|
|
# Logs prüfen
|
|
sudo journalctl -u wg-quick@wg0 -f
|
|
|
|
# Konfiguration prüfen
|
|
sudo wg-quick up wg0
|
|
```
|
|
|
|
### Keine Verbindung möglich
|
|
|
|
```bash
|
|
# Port prüfen
|
|
sudo ss -ulnp | grep 51820
|
|
|
|
# Firewall prüfen
|
|
sudo nft list ruleset | grep 51820
|
|
|
|
# IP Forwarding prüfen
|
|
cat /proc/sys/net/ipv4/ip_forward
|
|
# Sollte "1" sein
|
|
```
|
|
|
|
### Client kann keine Admin-Services erreichen
|
|
|
|
```bash
|
|
# nftables Rules prüfen
|
|
sudo nft list table inet wireguard_firewall
|
|
|
|
# VPN-Routing prüfen
|
|
ip route show table main | grep wg0
|
|
|
|
# NAT prüfen
|
|
sudo nft list chain inet wireguard postrouting
|
|
```
|
|
|
|
## Rollback-Prozedur
|
|
|
|
Falls etwas schiefgeht:
|
|
|
|
```bash
|
|
# WireGuard stoppen
|
|
sudo systemctl stop wg-quick@wg0
|
|
sudo systemctl disable wg-quick@wg0
|
|
|
|
# nftables Rules entfernen
|
|
sudo nft delete table inet wireguard_firewall
|
|
sudo nft delete table inet wireguard
|
|
|
|
# Konfiguration entfernen
|
|
sudo rm -rf /etc/wireguard/*
|
|
sudo rm /etc/nftables.d/wireguard.nft
|
|
|
|
# IP Forwarding zurücksetzen
|
|
sudo rm /etc/sysctl.d/99-wireguard.conf
|
|
sudo sysctl -p
|
|
```
|
|
|
|
## Sicherheitshinweise
|
|
|
|
- ✅ Private Keys niemals committen oder teilen
|
|
- ✅ Regelmäßige Key-Rotation (empfohlen: jährlich)
|
|
- ✅ Client-Configs nach Generierung sicher speichern
|
|
- ✅ Firewall-Logs regelmäßig überprüfen
|
|
- ✅ VPN-Zugriffe monitoren
|
|
|
|
## Performance-Metriken
|
|
|
|
Nach Installation zu überwachen:
|
|
|
|
- CPU-Auslastung: WireGuard ist sehr effizient (<5% bei normaler Last)
|
|
- Netzwerk-Durchsatz: Nahezu Leitungsgeschwindigkeit
|
|
- Latenz: Minimal (+1-2ms Overhead)
|
|
- Speicher: ~10MB RAM für WireGuard-Prozess
|
|
|
|
## Status
|
|
|
|
**Installation Status**: ⏳ BEREIT FÜR AUSFÜHRUNG
|
|
|
|
**Nächster Schritt**: Script ausführen mit:
|
|
```bash
|
|
cd /home/michael/dev/michaelschiemer/deployment/scripts
|
|
sudo ./manual-wireguard-setup.sh
|
|
```
|
|
|
|
**Oder manuell durchführen**: Jeden Schritt einzeln wie oben dokumentiert ausführen.
|