Community discussions

MikroTik App
 
dangucci
just joined
Topic Author
Posts: 18
Joined: Sun Aug 31, 2014 10:30 pm

Interface Checking Script

Sun Aug 31, 2014 10:47 pm

Hi guys, I would like to know how to make a script to check if ppp-out1 interfaces's ip falls in an ip range which is, the first octet
must be 10, second octet 43 , third octet greater than 128 .. eg 10.43.129.23

If ip addres of ppp-out1 falls within the range then

script should exit

but if ip addres of ppp-out1 doesnt fall within the range then script should execute the command

interface ppp-client disable ppp-out1
interface ppp-client enable ppp-out1

this would be on a scheduled task to be run every 10 seconds

Thank you so much for all your help!!!!!
 
User avatar
cdiedrich
Forum Veteran
Forum Veteran
Posts: 997
Joined: Thu Feb 13, 2014 2:03 pm
Location: Basel, Switzerland // Bremen, Germany
Contact:

Re: Interface Checking Script

Tue Sep 02, 2014 10:41 am

Take a look at this Return IP octet function.
With this you should be able to easily compare the octets you need.
The rest should be pretty easy.
And have a look at this script.
I love the way it is implemented, as it will only trigger on a change of your public IP - no need to be run every 10 seconds.

Cheers
-Chris
 
nonac
newbie
Posts: 27
Joined: Tue Sep 02, 2014 7:36 pm

Re: Interface Checking Script

Tue Sep 02, 2014 7:51 pm

can you check all interface with script?
 
dangucci
just joined
Topic Author
Posts: 18
Joined: Sun Aug 31, 2014 10:30 pm

Re: Interface Checking Script

Wed Sep 03, 2014 8:59 pm

Thank for the reply but im a complete noob now learning mikrotik scripting and will be happy if i can be assisted on this please
Thanks once again
 
dangucci
just joined
Topic Author
Posts: 18
Joined: Sun Aug 31, 2014 10:30 pm

Re: Interface Checking Script

Thu Sep 04, 2014 8:43 am

can you check all interface with script?
just a single interface like ppp-out1 and checks if its ip is in the range 10.43... with the 3rd octet greater than 128
and will execute a command if its in the range or isnt
Thanks