Page 1 of 1

ip-up style scripts

Posted: Fri Jul 29, 2005 1:05 pm
by ksm
Hi Everyone,

Is it possible to set a script to execute when the status of an interface changes?

I need to be able to add/delete routes from the routing table when a pppoe-client interface comes up/goes down.

I cannot use Netwatch to do it, because there is already a route in place that will make everything reachable. Thus I will always be able to ping an IP, whether the pppoe interface is up or down.

Any suggestions?

Thanks

Posted: Fri Jul 29, 2005 1:24 pm
by sten
That would be a neat feature (async trigger for if-up/if-down!)

Write a script that runs every X seconds monitoring if a certain interface is up or down ("find" is your friend).

I havent tested my example but it should give you an idea.

----[ written from memory ]----

:global luserflag
:if ( $luserflag = "" ) do={ :set luserflag no }
:if ( [ / interface find name="<pppoe-luser>" ] != "" && !$luserflag) do={
:log message="warning, luser is online!"
:set luserflag yes
} else={
:if ( [ / interface find name="<pppoe-luser>" ] = "" && $luserflag) do={
:log message="warning, luser is offline!"
:set luserflag no
}
}

Posted: Fri Jul 29, 2005 3:03 pm
by ksm
This could work.
My only concern, is that the pppoe interface drops and redials in between checks.
The pppoe session is set to reset every 24 hours (I have no control over this).