blade-router: add keepalived notify script for announcing/withdrawing routes

This commit is contained in:
Luke Granger-Brown 2021-03-29 23:54:26 +00:00
parent 1071202e7f
commit f05a063fce

View file

@ -2,9 +2,26 @@
#
# SPDX-License-Identifier: Apache-2.0
{ lib, config, ... }:
{ lib, config, pkgs, ... }:
with lib;
{
let
notifyBird = pkgs.writeScript "blade-router-vrrp-bird.sh" ''
ENDSTATE=$3
NAME=$2
TYPE=$1
case $ENDSTATE in
"MASTER") birdc enable export4
birdc enable export6
exit 0
;;
*) birdc disable export4
birdc disable export6
exit 0
;;
esac
'';
in {
imports = [
../lib/bgp.nix
];
@ -112,7 +129,7 @@ with lib;
};
in {
enable = true;
vrrpInstances.mgmtGateway = mgmtBase // {
vrrpInstances.mgmtGateway4 = mgmtBase // {
virtualIps = [
{ addr = "10.100.0.1/23"; }
{ addr = "${config.my.blade-router.addresses.br-public-vip.v4.addr}/${toString config.my.blade-router.addresses.br-public-vip.v4.prefixLength}"; dev = "br-public"; }
@ -126,6 +143,15 @@ with lib;
];
virtualRouterId = 2;
};
extraConfig = ''
vrrp_sync_group mgmtGateway {
group {
mgmtGateway4
mgmtGateway6
}
notify ${notifyBird}
}
'';
};
services.radvd = {