187 lines
6.4 KiB
Markdown
187 lines
6.4 KiB
Markdown
# WireGuard Windows Firewall - Pr?fung und Fix
|
|
|
|
## Problem
|
|
|
|
Traffic kommt NICHT ?ber VPN, obwohl WireGuard verbunden ist. Windows Firewall k?nnte VPN-Traffic blockieren.
|
|
|
|
## Schritt 1: Aktuelle Firewall-Regeln pr?fen
|
|
|
|
**Als Administrator in PowerShell:**
|
|
|
|
```powershell
|
|
# Pr?fe ob WireGuard-Regeln vorhanden sind
|
|
Get-NetFirewallRule | Where-Object {$_.DisplayName -like "*WireGuard*" -or $_.DisplayName -like "*VPN*"} | Select-Object DisplayName, Enabled, Direction, Action
|
|
|
|
# Pr?fe alle ausgehenden Regeln
|
|
Get-NetFirewallRule -Direction Outbound | Where-Object {$_.Enabled -eq $true} | Select-Object DisplayName, Direction, Action | Format-Table -AutoSize
|
|
|
|
# Pr?fe Firewall-Status
|
|
Get-NetFirewallProfile | Select-Object Name, Enabled
|
|
```
|
|
|
|
## Schritt 2: Pr?fe ob WireGuard-Programm-Regeln vorhanden sind
|
|
|
|
```powershell
|
|
# Suche nach WireGuard-Programm-Regeln
|
|
Get-NetFirewallApplicationFilter | Where-Object {$_.Program -like "*WireGuard*"} | Select-Object Program
|
|
|
|
# Oder pr?fe alle Programm-Regeln
|
|
Get-NetFirewallRule | Where-Object {$_.Program -like "*WireGuard*"} | Select-Object DisplayName, Enabled, Direction, Action, Program
|
|
```
|
|
|
|
## Schritt 3: Erstelle Firewall-Regeln f?r WireGuard
|
|
|
|
**Falls keine Regeln vorhanden sind:**
|
|
|
|
```powershell
|
|
# Als Administrator
|
|
|
|
# Erlaube WireGuard-Programm (TCP und UDP)
|
|
$wgPath = "C:\Program Files\WireGuard\wireguard.exe"
|
|
if (Test-Path $wgPath) {
|
|
New-NetFirewallRule -DisplayName "WireGuard VPN - Allow TCP" -Direction Outbound -Program $wgPath -Protocol TCP -Action Allow -Enabled True
|
|
New-NetFirewallRule -DisplayName "WireGuard VPN - Allow UDP" -Direction Outbound -Program $wgPath -Protocol UDP -Action Allow -Enabled True
|
|
New-NetFirewallRule -DisplayName "WireGuard VPN - Allow Inbound TCP" -Direction Inbound -Program $wgPath -Protocol TCP -Action Allow -Enabled True
|
|
New-NetFirewallRule -DisplayName "WireGuard VPN - Allow Inbound UDP" -Direction Inbound -Program $wgPath -Protocol UDP -Action Allow -Enabled True
|
|
Write-Host "WireGuard Firewall-Regeln erstellt"
|
|
} else {
|
|
Write-Host "WireGuard-Programm nicht gefunden in: $wgPath"
|
|
Write-Host "Bitte pr?fe den Pfad und passe ihn an"
|
|
}
|
|
|
|
# Alternative: Erlaube WireGuard-Interface (falls bekannt)
|
|
# Get-NetAdapter | Where-Object {$_.Name -like "*WireGuard*" -or $_.Name -like "*grafana-test*"} | ForEach-Object {
|
|
# $ifIndex = $_.InterfaceIndex
|
|
# New-NetFirewallRule -DisplayName "WireGuard Interface $($_.Name) - Allow Outbound" -Direction Outbound -InterfaceIndex $ifIndex -Action Allow -Enabled True
|
|
# New-NetFirewallRule -DisplayName "WireGuard Interface $($_.Name) - Allow Inbound" -Direction Inbound -InterfaceIndex $ifIndex -Action Allow -Enabled True
|
|
# }
|
|
```
|
|
|
|
## Schritt 4: Pr?fe Interface-basierte Regeln
|
|
|
|
```powershell
|
|
# Finde WireGuard Interface
|
|
$wgInterface = Get-NetAdapter | Where-Object {$_.Name -like "*grafana-test*" -or $_.Name -like "*WireGuard*"}
|
|
if ($wgInterface) {
|
|
Write-Host "WireGuard Interface gefunden: $($wgInterface.Name), Index: $($wgInterface.InterfaceIndex)"
|
|
|
|
# Pr?fe Interface-basierte Firewall-Regeln
|
|
Get-NetFirewallRule | Where-Object {$_.InterfaceIndex -eq $wgInterface.InterfaceIndex} | Select-Object DisplayName, Enabled, Direction, Action
|
|
}
|
|
```
|
|
|
|
## Schritt 5: Erlaube Traffic f?r VPN-Netzwerk
|
|
|
|
```powershell
|
|
# Als Administrator
|
|
|
|
# Erlaube ausgehenden Traffic zu VPN-Netzwerk (10.8.0.0/24)
|
|
New-NetFirewallRule -DisplayName "WireGuard VPN Network - Allow Outbound" `
|
|
-Direction Outbound `
|
|
-RemoteAddress "10.8.0.0/24" `
|
|
-Protocol TCP `
|
|
-Action Allow `
|
|
-Enabled True
|
|
|
|
New-NetFirewallRule -DisplayName "WireGuard VPN Network - Allow Outbound UDP" `
|
|
-Direction Outbound `
|
|
-RemoteAddress "10.8.0.0/24" `
|
|
-Protocol UDP `
|
|
-Action Allow `
|
|
-Enabled True
|
|
|
|
New-NetFirewallRule -DisplayName "WireGuard VPN Network - Allow Inbound" `
|
|
-Direction Inbound `
|
|
-RemoteAddress "10.8.0.0/24" `
|
|
-Protocol TCP `
|
|
-Action Allow `
|
|
-Enabled True
|
|
|
|
New-NetFirewallRule -DisplayName "WireGuard VPN Network - Allow Inbound UDP" `
|
|
-Direction Inbound `
|
|
-RemoteAddress "10.8.0.0/24" `
|
|
-Protocol UDP `
|
|
-Action Allow `
|
|
-Enabled True
|
|
|
|
Write-Host "VPN-Netzwerk Firewall-Regeln erstellt"
|
|
```
|
|
|
|
## Schritt 6: Teste nach Firewall-?nderungen
|
|
|
|
```powershell
|
|
# Pr?fe Route
|
|
route print | findstr "10.8"
|
|
|
|
# Teste Ping
|
|
ping 10.8.0.1
|
|
|
|
# Teste Grafana (im Browser)
|
|
# https://grafana.michaelschiemer.de
|
|
```
|
|
|
|
## Schritt 7: Pr?fe Logs
|
|
|
|
Nach den ?nderungen:
|
|
1. **WireGuard neu verbinden** (Disconnect ? Connect)
|
|
2. **Teste Grafana**: `https://grafana.michaelschiemer.de`
|
|
3. **Warte 5 Sekunden**
|
|
4. Dann pr?fe ich die Traefik-Logs, ob `ClientHost: 10.8.0.7` erscheint
|
|
|
|
## Troubleshooting
|
|
|
|
### Firewall-Regeln werden nicht angewendet
|
|
|
|
```powershell
|
|
# Pr?fe ob Firewall aktiv ist
|
|
Get-NetFirewallProfile | Select-Object Name, Enabled
|
|
|
|
# Falls Firewall deaktiviert ist, aktiviere sie (falls gew?nscht)
|
|
# Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled True
|
|
```
|
|
|
|
### WireGuard-Programm-Pfad ist anders
|
|
|
|
```powershell
|
|
# Finde WireGuard-Installationspfad
|
|
Get-ChildItem "C:\Program Files" -Recurse -Filter "wireguard.exe" -ErrorAction SilentlyContinue
|
|
Get-ChildItem "C:\Program Files (x86)" -Recurse -Filter "wireguard.exe" -ErrorAction SilentlyContinue
|
|
|
|
# Oder suche in allen Programmen
|
|
Get-ChildItem "C:\" -Recurse -Filter "wireguard.exe" -ErrorAction SilentlyContinue | Select-Object FullName
|
|
```
|
|
|
|
### Tempor?re Firewall-Regeln zum Testen
|
|
|
|
Falls du schnell testen m?chtest, ohne spezifische Regeln:
|
|
|
|
```powershell
|
|
# Als Administrator - ERLAUBE ALLEN AUSGEHENDEN TRAFFIC TEMPOR?R (NUR ZUM TESTEN!)
|
|
# WARNUNG: Diese Regel erlaubt ALLEN ausgehenden Traffic - nur zum Testen verwenden!
|
|
|
|
New-NetFirewallRule -DisplayName "TEST - Allow All Outbound (TEMPORARY)" `
|
|
-Direction Outbound `
|
|
-Action Allow `
|
|
-Enabled True
|
|
|
|
# Teste dann Grafana
|
|
# Falls es funktioniert: L?sche diese Regel und erstelle spezifische Regeln
|
|
# Remove-NetFirewallRule -DisplayName "TEST - Allow All Outbound (TEMPORARY)"
|
|
```
|
|
|
|
## N?chste Schritte
|
|
|
|
Nach dem Erstellen der Firewall-Regeln:
|
|
|
|
1. ? Firewall-Regeln erstellt
|
|
2. ? WireGuard neu verbinden
|
|
3. ? Teste Grafana-Zugriff
|
|
4. ? Pr?fe Traefik-Logs (ich pr?fe dann, ob `ClientHost: 10.8.0.7` erscheint)
|
|
|
|
## Wichtige Hinweise
|
|
|
|
- **Firewall-Regeln sollten spezifisch sein** (nicht "Allow All")
|
|
- **Programm-Regeln sind sicherer** als allgemeine Regeln
|
|
- **Interface-Regeln k?nnen helfen**, wenn Programm-Regeln nicht funktionieren
|
|
- **VPN-Netzwerk-Regeln** sind am spezifischsten
|