Community discussions

MikroTik App
 
ksm
just joined
Topic Author
Posts: 5
Joined: Tue Jan 18, 2005 9:36 am

ip-up style scripts

Fri Jul 29, 2005 1:05 pm

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
 
sten
Forum Veteran
Forum Veteran
Posts: 923
Joined: Tue Jun 01, 2004 12:10 pm

Fri Jul 29, 2005 1:24 pm

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
}
}
 
ksm
just joined
Topic Author
Posts: 5
Joined: Tue Jan 18, 2005 9:36 am

Fri Jul 29, 2005 3:03 pm

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).