ifstated: Use templating for ifstated configurations

This commit is contained in:
Timo Makinen 2021-03-26 16:45:26 +00:00
parent baa768fe53
commit e31769a606
4 changed files with 1 additions and 1 deletions

View file

@ -0,0 +1,33 @@
init-state auto
carp_up = "carp145.link.up"
state auto {
run "pfctl -f /etc/pf.conf"
if $carp_up {
set-state master
}
if ! $carp_up {
set-state backup
}
}
state backup {
init {
run "/usr/local/sbin/birdc disable ospf1"
}
if $carp_up {
set-state master
}
}
state master {
init {
run "/usr/local/sbin/birdc enable ospf1"
}
if !$carp_up {
set-state backup
}
}

View file

@ -0,0 +1,32 @@
init-state auto
if_carp_up="carp157.link.up"
if_carp_down="carp157.link.down"
state auto {
if $if_carp_up {
set-state master
}
if $if_carp_down {
set-state backup
}
}
state master {
init {
run "route delete default && route add default 37.16.96.145"
}
if $if_carp_down {
set-state backup
}
}
state backup {
init {
run "route delete default && route add default 172.20.20.1"
}
if $if_carp_up {
set-state master
}
}

View file

@ -0,0 +1,6 @@
# flush routes when external carp goes up
if carp153.link.up
run 'route -q flush ; route add default $(cat /etc/mygate)'
if carp154.link.up
run 'route -q flush ; route add default $(cat /etc/mygate)'