pve-cluster: Verwaltungsports nur aus IPSET admin (Proxmox ergänzt management stets um das /24); Skript nutzt python auf dem Laptop
ci / test (push) Successful in 25s

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Robert Rapp
2026-10-13 17:08:42 +02:00
co-authored by Claude Fable 5.1
parent 87b678e7a8
commit 47ad1580ff
4 changed files with 14 additions and 6 deletions
@@ -10,3 +10,5 @@ pve_healer_token_file: /root/.config/knaster/healer.env
# Totmannschalter: schaltet die Firewall nach dieser Zeit wieder ab, wenn die Prüfung am Ende
# des Laufs nicht erreicht wird (Lauf abgebrochen, ops ausgesperrt).
pve_firewall_deadman_seconds: 600
# Verwaltungsports der Knoten (SSH, Weboberfläche/API, SPICE-Proxy, VNC-Konsole, Migration)
pve_mgmt_ports: "22,8006,3128,5900:5999,60000:60050"
@@ -1,4 +1,8 @@
# Verwaltet von Ansible (Rolle pve-cluster, Vorlage cluster.fw.j2). Änderungen im Repo, nicht hier.
#
# Proxmox fügt dem eingebauten IPSET "management" immer das lokale Netz (/24) hinzu. Eine Einschränkung
# auf einzelne Adressen geht deshalb nur über eigene Regeln: erst ACCEPT für +admin, dann DROP für das
# restliche LAN auf den Verwaltungsports. Die Standardregeln dahinter werden für das LAN nie erreicht.
[OPTIONS]
enable: {{ 1 if knaster_pve.firewall.enable else 0 }}
@@ -6,7 +10,7 @@ policy_in: DROP
policy_out: ACCEPT
log_ratelimit: enable=1,rate=10/second,burst=5
[IPSET management] # Zugang zu 8006, 22, 5900-5999, 3128, 60000-60050 (Proxmox-Standardregeln)
[IPSET admin] # Nur diese Quellen erreichen 22, 8006, 3128, 5900-5999 und 60000-60050 der Knoten
{% for host in groups['pve_all'] | sort %}
{{ hostvars[host].ansible_host }} # Knoten {{ host }}
@@ -17,4 +21,6 @@ log_ratelimit: enable=1,rate=10/second,burst=5
[RULES]
IN ACCEPT -source +admin -p tcp -dport {{ pve_mgmt_ports }} -log nolog # Verwaltung nur aus +admin
IN DROP -source {{ knaster_pve.firewall.ping_from }} -p tcp -dport {{ pve_mgmt_ports }} -log nolog # restliches LAN
IN ACCEPT -source {{ knaster_pve.firewall.ping_from }} -p icmp -log nolog # Ping aus dem LAN
+1 -1
View File
@@ -50,7 +50,7 @@ o=h[-1]&15
print('%06d'%((struct.unpack('>I',h[o:o+4])[0]&0x7fffffff)%1000000))\"")
run "pvesh create /access/tfa/$userid --type totp --description 'Authenticator-App' --totp '$uri' --value $code" >/dev/null
keys=$(run "pvesh create /access/tfa/$userid --type recovery --description 'Recovery-Keys (offline)' --output-format json" \
| python3 -c 'import json,sys; print("\n".join(json.load(sys.stdin)["recovery"]))')
| python -c 'import json,sys; print("\n".join(json.load(sys.stdin)["recovery"]))')
umask 077
{
echo "Proxmox 2FA für $userid (angelegt $(date +%F))"
+4 -4
View File
@@ -44,8 +44,8 @@ firewall:
# Achtung: Laptop, ops und infra laufen noch per DHCP (D5). Wechselt eine Adresse, sperrt die
# Firewall diese Quelle aus. Rückweg: ssh über eine noch zugelassene Adresse (ops) oder Konsole.
management:
- {ip: 192.168.100.151, comment: Admin-Laptop (WLAN, DHCP)}
- {ip: 192.168.100.29, comment: appsrv08 (LiteLLM mit PSE, n8n-Bruecke)}
- {ip: 192.168.100.173, comment: ops CT 100 (Ansible, tofu; DHCP)}
- {ip: 192.168.100.188, comment: infra CT 101 (pve-exporter; DHCP)}
- {ip: 192.168.100.151, comment: Admin-Laptop WLAN per DHCP}
- {ip: 192.168.100.29, comment: appsrv08 LiteLLM mit PSE und n8n-Bruecke}
- {ip: 192.168.100.173, comment: ops CT 100 Ansible und tofu per DHCP}
- {ip: 192.168.100.188, comment: infra CT 101 pve-exporter per DHCP}
ping_from: 192.168.100.0/24