router(*): VRRP the admin interface

Now, the Proxmox can be accessed while redeploying one of the router!
This commit is contained in:
Raito Bezarius 2024-01-12 04:36:15 +01:00
parent bcbfc91a11
commit dfeeb1c4ea
3 changed files with 18 additions and 10 deletions

View file

@ -4,7 +4,6 @@
enable = true; enable = true;
enablePrimary = true; enablePrimary = true;
routerId = 1; routerId = 1;
virtualRouterId = 51;
vip = "129.199.146.230"; vip = "129.199.146.230";
rip = "129.199.146.231"; rip = "129.199.146.231";
trunkPort.macAddress = "92:E3:9C:CE:EF:14"; trunkPort.macAddress = "92:E3:9C:CE:EF:14";

View file

@ -4,7 +4,6 @@
enable = true; enable = true;
enablePrimary = false; enablePrimary = false;
routerId = 2; routerId = 2;
virtualRouterId = 51;
vip = "129.199.146.230"; vip = "129.199.146.230";
rip = "129.199.146.232"; rip = "129.199.146.232";
trunkPort.macAddress = "92:E3:9C:CE:EF:15"; trunkPort.macAddress = "92:E3:9C:CE:EF:15";

View file

@ -46,10 +46,6 @@ in
type = types.int; type = types.int;
description = "Router ID for computing automatic IPs"; description = "Router ID for computing automatic IPs";
}; };
virtualRouterId = mkOption {
type = types.int;
description = "Virtual router ID for VRRP";
};
virtualPriority = mkOption { virtualPriority = mkOption {
type = types.int; type = types.int;
description = "Virtual router priority in the election"; description = "Virtual router priority in the election";
@ -136,7 +132,7 @@ in
matchConfig.Name = "wgadmin"; matchConfig.Name = "wgadmin";
networkConfig = { networkConfig = {
Description = "VPN d'administration système de l'infrastructure"; Description = "VPN d'administration système de l'infrastructure";
Address = [ "fd81:fb3a:50cc::${toString cfg.routerId}/64" ]; Address = [ "fd81:fb3a:50cc::${toString (cfg.routerId + 1)}/64" ];
# Give access to the rest of the network. # Give access to the rest of the network.
IPForward = "ipv6"; IPForward = "ipv6";
ConfigureWithoutCarrier = true; ConfigureWithoutCarrier = true;
@ -147,7 +143,7 @@ in
matchConfig.Name = "admin"; matchConfig.Name = "admin";
networkConfig = { networkConfig = {
Description = "VLAN d'administration système de l'infrastructure"; Description = "VLAN d'administration système de l'infrastructure";
Address = [ "fd81:fb3a:50cc:1::${toString cfg.routerId}/48" ]; Address = [ "fd81:fb3a:50cc:1::${toString (cfg.routerId + 1)}/48" ];
# Give access to the rest of the network. # Give access to the rest of the network.
IPForward = "ipv6"; IPForward = "ipv6";
IPv6ProxyNDP = true; IPv6ProxyNDP = true;
@ -341,7 +337,7 @@ in
matchConfig.Name = "vrrp-router"; matchConfig.Name = "vrrp-router";
networkConfig = { networkConfig = {
Description = "VRRP router health network"; Description = "VRRP router health network";
Address = [ "10.0.0.${toString cfg.routerId}/24" ]; Address = [ "10.0.0.${toString cfg.routerId}/24" "fe80::${toString cfg.routerId}/64" ];
KeepConfiguration = true; KeepConfiguration = true;
}; };
}; };
@ -356,10 +352,24 @@ in
# We want to start in a stable state. # We want to start in a stable state.
priority = cfg.virtualPriority; priority = cfg.virtualPriority;
virtualIps = [{ addr = "${cfg.vip}/24"; dev = "swp"; scope = "global"; }]; virtualIps = [{ addr = "${cfg.vip}/24"; dev = "swp"; scope = "global"; }];
inherit (cfg) virtualRouterId; virtualRouterId = 50;
noPreempt = !cfg.enablePrimary; noPreempt = !cfg.enablePrimary;
unicastPeers = map (n: "10.0.0.${toString n}") cfg.virtualNeighbors; unicastPeers = map (n: "10.0.0.${toString n}") cfg.virtualNeighbors;
}; };
vrrpInstances.admin = {
interface = "vrrp-router";
state = if cfg.enablePrimary then "MASTER" else "BACKUP";
# We want to start in a stable state.
priority = cfg.virtualPriority;
virtualIps = [
{ addr = "fd81:fb3a:50cc::1/64"; dev = "wgadmin"; }
{ addr = "fd81:fb3a:50cc:1::1/48"; dev = "admin"; }
];
virtualRouterId = 51;
noPreempt = !cfg.enablePrimary;
unicastPeers = map (n: "fe80::${toString n}") cfg.virtualNeighbors;
unicastSrcIp = "fe80::${toString cfg.routerId}";
};
}; };
}; };
} }