diff --git a/platform/proxmox/ansible/roles/pve-cluster/defaults/main.yml b/platform/proxmox/ansible/roles/pve-cluster/defaults/main.yml index 6201456..b790db0 100644 --- a/platform/proxmox/ansible/roles/pve-cluster/defaults/main.yml +++ b/platform/proxmox/ansible/roles/pve-cluster/defaults/main.yml @@ -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" diff --git a/platform/proxmox/ansible/roles/pve-cluster/templates/cluster.fw.j2 b/platform/proxmox/ansible/roles/pve-cluster/templates/cluster.fw.j2 index d0a4845..11f20fe 100644 --- a/platform/proxmox/ansible/roles/pve-cluster/templates/cluster.fw.j2 +++ b/platform/proxmox/ansible/roles/pve-cluster/templates/cluster.fw.j2 @@ -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 diff --git a/platform/proxmox/scripts/pve-admin-user.sh b/platform/proxmox/scripts/pve-admin-user.sh index 2fb5647..27cfa93 100644 --- a/platform/proxmox/scripts/pve-admin-user.sh +++ b/platform/proxmox/scripts/pve-admin-user.sh @@ -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))" diff --git a/sites/knaster/proxmox.yaml b/sites/knaster/proxmox.yaml index 6918a7a..d85c03c 100644 --- a/sites/knaster/proxmox.yaml +++ b/sites/knaster/proxmox.yaml @@ -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