Community discussions

MikroTik App
 
DjSam
just joined
Topic Author
Posts: 14
Joined: Mon Mar 07, 2011 8:46 pm

Help needed

Wed Jun 04, 2014 3:44 pm

I'm new to scripting so if anyone could help me I would be very grateful

I am trying to accomplish the following:
run a script that checks if the ip on a pppoe interface changed
if it's the same, nothing to be done
if it is, check the network ip (the gateway) for example if the ip is 93.123.130.155 the network ip is 93.123.130.1
my isp set me on two ip ranges (for example 93.123.130.0/24 and 93.123.131.0/24) so I would like to change static routes accordingly, when the range changes I would like to disable a static route and enable another, and when it changes back, reverse them

I managed to get to this script reading the example scripts so can you please correct it:

:local inetinterface "pppoe isp"
:local sad0 "93.123.130.1
:local sad1 "93.123.131.1;
:if ([/interface get $inetinterface value-name=running]) do={
# Get the current IP on the interface
:local currentIP [/ip address get [find interface="$inetinterface" disabled=no] network]};
:log info $currentIP
:if ($currentIP=$sad1) do={:system script run "isp3"} else={:system script run "isp4"}



Many thanks!!
 
DjSam
just joined
Topic Author
Posts: 14
Joined: Mon Mar 07, 2011 8:46 pm

Re: Help needed

Sat Jun 07, 2014 1:47 pm

bump
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12736
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Help needed

Sat Jun 07, 2014 2:03 pm

I understand what you want, but I want know why you need that, for provide better help.

What rule must be changed / enabled after that?

The rule can not change accordingly with pppoe-out interface?
 
DjSam
just joined
Topic Author
Posts: 14
Joined: Mon Mar 07, 2011 8:46 pm

Re: Help needed

Sat Jun 07, 2014 2:07 pm

I am using load balancing; I have 1 pppoe with fixed ip the other is dynamic
I created two static routes, I enable one and disable the other manually now when the external ip changes (every other day)

Thanks for your help!!
 
DjSam
just joined
Topic Author
Posts: 14
Joined: Mon Mar 07, 2011 8:46 pm

Re: Help needed (SOLVED)

Mon Jun 30, 2014 3:52 pm

/ interface pppoe-client {
:global ExternalIP
:local clientip
:local clientstatus
:while (1 < 2) do={
monitor pppoe2211 once do={:set clientip $"remote-address"; :set clientstatus $status}
:if ($clientstatus="connected" and $ExternalIP!=$clientip) do={
:delay 1
:log info "Sotel Gateway changed from $ExternalIP to $clientip"
:if ($clientip="93.16.130.1") do={ /system script run Sotel4 } else={ /system script run Sotel3 }
:set ExternalIP $clientip
}
:delay 5
}
}
 
mboy
just joined
Posts: 12
Joined: Tue Feb 11, 2014 7:23 pm

Re: Help needed

Mon Jul 07, 2014 2:04 pm

Please help!!
We need to get comments from the ARP and set in ip firewall address-list.
:foreach i in=[/ip firewall address-list find] do={
	:local ipaddress [/ip firewall address-list get $i address];
	:local ipcomment [/ip arp get [find address=$ipaddress] comment];
	/ip firewall address-list set $i comment=$ipcomment
}
What is wrong?