Files
infrastructure/docs/GNAI-006-SEC_VPN_Clients_Linux.md
T

106 lines
4.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# GNAI-006-SEC – VPN-Client-Einrichtung: Linux (KDE Plasma)
**Bezug:** GNAI-006-SEC_VPN.md (WireGuard-VPN-Gateway LXC 105)
**Zielgruppe:** Benutzer (Laptop, z. B. CachyOS mit KDE Plasma)
**Version:** 1.0 · 2026-09-09
---
## 1. Voraussetzungen
* WireGuard-Client-Paket installiert
* Das eigene wg-easy-Profil (`.conf`) – s. Abschnitt 2
## 2. Profil aus der wg-easy-UI beziehen (einmalig)
> ⚠️ Die UI ist **nur aus dem LAN** erreichbar (nftables). Beim ersten Setup also im Heimnetz (WLAN/LAN) bleiben.
1. Browser öffnen → `http://10.0.0.15:51821`
2. Passwort eingeben
3. In der Client-Liste den eigenen Eintrag wählen (z. B. `Laptop-FullAdmin`)
4. **`Download`** klicken → Datei `Laptop-FullAdmin.conf` wird heruntergeladen
*(Alternativ: QR-Code auf dem Display mit dem Smartphone scannen – Android/KDE-kompatibel.)*
Die Datei enthält alles Notwendige:
```ini
[Interface]
PrivateKey = … # nur die eigenen – NICHT weitergeben
Address = 10.8.0.2/32
DNS = 10.0.0.1 # Fritzbox als Resolver
[Peer]
PublicKey = …
PresharedKey = …
Endpoint = vpn.ghostnet.selfhost.eu:51820
AllowedIPs = 10.0.0.0/24, 10.8.0.0/24, …
```
**Nur der Abschnitt `[Interface]` (PrivateKey!) ist privat** – `PublicKey`/`PresharedKey` dürfen geteilt werden, `PrivateKey` niemals.
## 3. WireGuard installieren (CachyOS)
```bash
sudo pacman -S wireguard-dkms wireguard-tools
```
* DKMS baut das WireGuard-Kernelmodul für den jeweils laufenden Kernel (CachyOS wechselt Kernel häufig – DKMS verhindert, dass nach einem Kernel-Update das Modul fehlt).
* Prüfen: `lsmod | grep wireguard`
## 4. Profil importieren
### Variante A – KDE-Systemtray (empfohlen)
1. Oben rechts in der Taskleiste → **Systemtray-Icon** (kleines WLAN/Schild-Symbol) – erscheint nach Installation von `wireguard-tools` + `plasma-workspace` (bzw. `plasma-vault`-unabhängig, Teil der Standard-KDE-Pakete).
2. Rechtsklick auf das Icon → **„New from file…“** → die `.conf` wählen.
3. Eintrag erscheint in der Liste → Rechtsklick → **„Connect“**.
### Variante B – `wg-quick` (Konsole / Autostart)
```bash
# Profil in das Konfigurationsverzeichnis legen
install -m 600 ~/Downloads/Laptop-FullAdmin.conf /etc/wireguard/
# Verbindung starten (ohne root)
sudo wg-quick up wg0
# Status
wg show wg0
# Verbinden getrennt
sudo wg-quick down wg0
```
**Autostart (optional):** `/etc/wireguard/wg0.conf` mit `[Interface] PrivateKey=…` vorhanden → `sudo systemctl enable wg-quick@wg0`.
## 5. Verifikation
```bash
ip -br addr show wg0 # wg0 UP, 10.8.0.2/32
ping -c 3 10.8.0.1 # VPN-Gateway (muss funktionieren)
ping -c 3 10.0.0.2 # Proxmox – LAN via Tunnel
ping -c 3 10.0.0.90 # LLM-Server – LAN via Tunnel
curl -s ifconfig.co # eigene ÖFFENTLICHE IP (Nicht-LAN: muss die WAN-IP des Providers sein, NIE 10.0.0.x)
```
**Erwartet (Split-Tunneling):**
* LAN-Hosts (`10.0.0.0/24`) → **über den VPN-Tunnel**
* Alles andere (Internet) → **direkt** (Nicht-LAN: Provider-NAT)
* `curl ifconfig.co` zeigt deine **normale** Außen-IP – **nicht** eine VPN-IP
## 6. Fehlersuche
| Symptom | Ursache / Lösung |
| --- | --- |
| „No handshake yet“ nach 30 s | (1) LAN: `http://10.0.0.15:51821` erreichbar? (2) Nicht-LAN: DNS von `vpn.ghostnet.selfhost.eu` auflösen (`nslookup vpn.ghostnet.selfhost.eu` → muss `93.208.161.126` zeigen); Fritzbox-Portforward UDP 51820 aktiv? |
| `wg-quick` meldet `WireGuard kernel module not loaded` | `sudo modprobe wireguard` (DKMS nicht installiert oder Kernel-Update → `sudo pacman -S wireguard-dkms`) |
| LAN-Ping funktioniert, `curl ifconfig.co` zeigt VPN-IP | Client ist (fälschlich) im Full-Tunnel-Modus → `AllowedIPs` in der `.conf` prüfen – muss **nur** `10.0.0.0/24,10.8.0.0/24,…` sein, **nicht** `0.0.0.0/0` |
| `Permission denied` bei `wg-quick up` | `sudo` vergessen (oder: `sudo usermod -aG wheel $USER` + `sudo /usr/bin/setfacl -m u:$USER:rw /etc/wireguard/wg0.conf` für rootless) |
| KDE-Icon fehlt | `plasma-workspace`-Paket installiert; Systemtray neu starten: `plasmashell --replace` |
## 7. Sicherheitshinweise
* **Niemals** den PrivateKey aus der `.conf` in einen Chat/Die-Cloud/Chat-Verlauf stellen.
* `.conf` mit `chmod 600` (`install -m 600` s. oben) – kein World-Readable.
* Bei Verdacht auf Kompromittierung: in der wg-easy-UI Client **deaktivieren** (Toggle) oder **delete** – der Server erkennt den Key nicht mehr an.