Greetings,

I'm trying to use ifstated to determine the state (up or down) of my two ISP
connections.  Currently I'm using ping, which I realize is imperfect, but
I'm getting some odd transitions.

For example, ISP2 is very unreliable and ifstated was in the ISP2down state.
>From there, based on the config below, it transitioned to the IPS1down state
even though ISP2 was also down.  I would have expected it to transition to
the bothdown state.

Any thoughts or pointers would be appreciated.

-Steve S.

--- /etc/ifstated.conf --------------------
init-state bothup

ISP1 = '( "ping -q -c 1 -w 1 10.10.10.1 > /dev/null" every 15)'
ISP2 = '( "ping -q -c 1 -w 2 10.20.20.1 > /dev/null" every 15)'

state bothup {
        init {
                run "pfctl -a outbound -F rules -f /etc/pf.bothup.conf"
                run "mail -s 'FW1 says both ISPs up' root </dev/null"
        }
        if ! $ISP1
                set-state ISP1down
        if ! $ISP2
                set-state ISP2down
}
state ISP1down {
        init {
                run "pfctl -a outbound -F rules -f /etc/pf.ISP1down.conf"
                run "mail -s 'FW1 says ISP1 is down' root </dev/null"
        }
        if $ISP1
                set-state bothup
        if ! ($ISP1 || $ISP2)
                set-state bothdown
        if ! $ISP2
                set-state ISP2down
}
state ISP2down {
        init {
                run "pfctl -a outbound -F rules -f /etc/pf.ISP2down.conf"
                run "mail -s 'FW1 says ISP2 is down' root </dev/null"
        }
        if ! ($ISP1 || $ISP2)
                set-state bothdown
        if ! $ISP1
                set-state ISP1down
        if $ISP2
                set-state bothup
}
state bothdown {
        init {
                run "pfctl -a outbound -F rules"
                run "mail -s 'FW1 says ALL Internet is down' root
</dev/null"
        }
        if $ISP2 && $ISP1
                set-state bothup
        if $ISP1
                set-state ISP2down
        if $ISP2
                set-state ISP1down
}

Reply via email to