Ursache der „WireGuard reißt immer wieder ab"-Abrisse war NICHT die UniFi, sondern keepalived-Flapping im HA-Cluster: die VIP 89.163.205.100 (an der die UniFi-Site-to-Site hängt) wanderte bei ~17 VRRP-Wahlen/Tag zwischen utm-1/utm-2 → Tunnel-Abriss bei jeder Wahl. Drei Bugs: 1) Firewall ließ VRRP (IP-Proto 112) zwischen den Cluster-Peers NICHT zu (policy drop). Adverts überlebten nur via conntrack-Reverse-Matching → bei conntrack-Ablauf gedroppt → Peer promotet sich → Split-Brain. Fix: ruleset.nft.tpl erlaubt `ip/ip6 ... vrrp saddr @peer_ipv4/6`; firewall.go nimmt zusätzlich hb_src_ip/hb_peer_ip aus cluster_settings ins Peer-Set (deckt den Heartbeat-Pfad 169.254.0.x ab). 2) Kein nopreempt → erholter Node riss die VIP sofort zurück (Flap-Back); aggressiver gw-Check (fall 2 → 10s-Blip = Failover). Fix: keepalived.conf.tpl mit `nopreempt` in VI_1+VI_HB, chk_gateway fall 2→5; keepalived.go setzt State immer BACKUP (nopreempt wirkt nur in BACKUP), Priorität 200/100 aus pg_role bleibt → deckt sich mit „manuelles Promote". 3) keepalived-Boot-Race: Unit startete vor vlan500 (nur After=network-online) → „interface vlan500 doesn't exist" → permanenter CONFIG-Crash ohne Recovery (keepalived nach Reboot tot). Fix: postinst legt Drop-in mit After=/Wants=edgeguard-interfaces.service + Restart=on-failure an. Neuer Test internal/keepalived/keepalived_test.go (nopreempt/BACKUP/fall). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
75 lines
1.6 KiB
Smarty
75 lines
1.6 KiB
Smarty
global_defs {
|
|
router_id {{ .RouterID }}
|
|
script_user root
|
|
enable_script_security
|
|
}
|
|
|
|
vrrp_script chk_edgeguard {
|
|
script "/usr/lib/edgeguard/keepalived-check.sh"
|
|
interval 2
|
|
weight -50
|
|
fall 3
|
|
rise 2
|
|
}
|
|
{{ if .GWCheckIP }}
|
|
vrrp_script chk_gateway {
|
|
script "/usr/lib/edgeguard/keepalived-gw-check.sh {{ .GWCheckIP }}"
|
|
interval 5
|
|
weight -110
|
|
fall 5
|
|
rise 2
|
|
}
|
|
{{ end }}
|
|
{{ if .HBInterface }}
|
|
vrrp_sync_group VG_1 {
|
|
group {
|
|
VI_1
|
|
VI_HB
|
|
}
|
|
}
|
|
{{ end }}
|
|
vrrp_instance VI_1 {
|
|
state {{ .State }}
|
|
interface {{ .Interface }}
|
|
virtual_router_id {{ .RouterID }}
|
|
priority {{ .Priority }}
|
|
advert_int 1
|
|
nopreempt
|
|
{{ if .SrcIP }} unicast_src_ip {{ .SrcIP }}
|
|
unicast_peer {
|
|
{{ .PeerIP }}
|
|
}
|
|
{{ end }} authentication {
|
|
auth_type PASS
|
|
auth_pass {{ .AuthPass }}
|
|
}
|
|
virtual_ipaddress {
|
|
{{ range .VIPs }} {{ .Address }}/{{ .Prefix }} dev {{ .Device }}
|
|
{{ end }} }
|
|
track_script {
|
|
chk_edgeguard
|
|
{{ if .GWCheckIP }} chk_gateway
|
|
{{ end }} }
|
|
notify_master "/usr/lib/edgeguard/keepalived-master.sh"
|
|
notify_backup "/usr/lib/edgeguard/keepalived-backup.sh"
|
|
notify_fault "/usr/lib/edgeguard/keepalived-backup.sh"
|
|
}
|
|
{{ if .HBInterface }}
|
|
vrrp_instance VI_HB {
|
|
state {{ .State }}
|
|
interface {{ .HBInterface }}
|
|
virtual_router_id {{ .HBRouterID }}
|
|
priority {{ .Priority }}
|
|
advert_int 1
|
|
nopreempt
|
|
{{ if .HBSrcIP }} unicast_src_ip {{ .HBSrcIP }}
|
|
unicast_peer {
|
|
{{ .HBPeerIP }}
|
|
}
|
|
{{ end }} authentication {
|
|
auth_type PASS
|
|
auth_pass {{ .AuthPass }}
|
|
}
|
|
}
|
|
{{ end }}
|