2009/9/3 David Harrison <[email protected]>:
> Hi all,
>
> I'm setting up a firewall with 2 load-balanced redundant Internet
> links.  To ensure the host itself can load balance its outbound
> connections (and fail-over correctly if one of those links dies) I'm
> configuring ifstated to handle updating the default routes for the
> host based on a simple ping test to assess if I can contact the next
> hop for each interface.
>
> The configuration I've included below works fine if both links are
> active, and in a single link failure on either link it fails over
> correctly and fails back if both links are found to be available
> again.  However there's a worst-case where both links go, for which
> I've included the 'alldown' state to prevent my host flapping, but it
> never manage to reach 'alldown', it just flap back and forth between
> 'link1only' and 'link2only' - note my test situation is included below
> including ifconfig output for the IF's, ping test output, ifstated
> output, and a trascription of my ifstated.conf.
>
> ... <snip> ...

Hi misc,

After some wise advice from Bret Lambert, which in brief was to try
rewriting my conditionals as single clauses, I thought I'd send an
update on my success for anyone interested.

It turned out that because I was including 2 distinct events in my
conditions ( 'if (event1 && event2)' ) the condition could never be
satisfied - there being only one event raised at a time.

The re-written ifstated.conf is included below, and also happens to
read alot more succinctly - at least to me :-)

---

link1 = '( "ping -I 192.168.5.10 -q -c 1 -w 1 192.168.5.2 > /dev/null"
every 20 )'
link2 = '( "ping -I 192.168.6.10 -q -c 1 -w 1 192.168.6.1 > /dev/null"
every 20 )'

init-state "primary"

state primary {
       init {
               run "route add -mpath default 192.168.5.2"
               run "route add -mpath default 192.168.6.1"
       }

   if ! $link1
       set-state link2only

   if ! $link2
       set-state link1only
}

# only link1 is up
state link1only {
       init {
               run "route delete default 192.168.6.1"
               run "route add -mpath default 192.168.5.2"
       }

   if ! $link1
       set-state alldown

   if $link2
       set-state primary
}

# only link2 is up
state link2only {
       init {
               run "route delete default 192.168.5.2"
               run "route add -mpath default 192.168.6.1"
       }

   if $link1
       set-state primary

   if ! $link2
       set-state alldown
}

# all down !
state alldown {
       init {
               run "route add -mpath default 192.168.5.2"
               run "route add -mpath default 192.168.6.1"
       }

   if $link1
       set-state link1only

   if $link2
       set-state link2only

}

---

Reply via email to