Community discussions

MikroTik App

Search found 10 matches

by berzins
Thu Aug 23, 2018 10:39 am
Forum: Scripting
Topic: Disable/Enable firewall rule based on ping result
Replies: 2
Views: 1789

Re: Disable/Enable firewall rule based on ping result

Here's a base to work on: :local alwaysRun true; :while ($alwaysRun) do={ :if ([ping address=10.155.0.255 count=5] = 0 ) do={ # disable the routes } else={ # enable the routes } } Replace the IP address you want to ping and put the routes you want to enable/disable inside the script. Script will con...
by berzins
Wed Aug 15, 2018 7:55 am
Forum: Scripting
Topic: Get Identity and adrees from neighbor
Replies: 9
Views: 5016

Re: Get Identity and adrees from neighbor

Hello, I think this might work for you, just replace your script with this. You can change the $interfaceParam and $addressParam to anything you like and it should output the correct identity. Feel free to ask any questions if something doesn't work for you. CODE: SELECT ALL # DEFINE YOUR SEARCH PA...
by berzins
Tue Aug 14, 2018 1:47 pm
Forum: Scripting
Topic: disable a default route that have no routing-mark
Replies: 2
Views: 4639

Re: disable a default route that have no routing-mark

This script should disable any route with a routing mark of your choice. Just change the $routing-mark$ parameter. [/ip route disable [/ip route find where dst-address=0.0.0.0/0 gateway=2.2.2.2 routing-mark="main"]]; [/ip route disable [/ip route find where dst-address=0.0.0.0/0 gateway=2....
by berzins
Tue Aug 14, 2018 11:36 am
Forum: Scripting
Topic: can not get netmask from /ip address get number=0 value-name=netmask
Replies: 0
Views: 1282

Re: can not get netmask from /ip address get number=0 value-name=netmask

You can strip the IP address manually and only leave netmask with this one line. :local a [:pick [/ip address get 0 address] ([:find [/ip address get 0 address] "/"] +1) [:len [/ip address get 0 address] ]];:put $a Cleaner way ( in a script ): :local address [/ip address get 0 address]; :l...
by berzins
Mon Aug 13, 2018 3:22 pm
Forum: Scripting
Topic: Get Identity and adrees from neighbor
Replies: 9
Views: 5016

Re: Get Identity and adrees from neighbor

Nice discussion , I want to display only the identity of the device , i do many tries to get the result but No success ... /ip neighbor print where interface=bridge1 address~"^192.168" i did a script to detect the rogue dhcp server and it must show the damaged devices identity .. here is ...
by berzins
Fri Aug 03, 2018 1:17 pm
Forum: Scripting
Topic: Commands run perfect in terminal, run perfectly as a script. But refuse to run as a .rsc startup script. [SOLVED]
Replies: 2
Views: 10756

Re: Commands run perfect in terminal, run perfectly as a script. But refuse to run as a .rsc startup script. [SOLVED]

I've had issues with scripts starting too fast and then not executing at all. You could modify the script with a couple of "log warning "failed at 1,2,3 etc" to see where exactly it stops by checking the log. If it doesn't execute at all on startup, try adding a delay at the start of ...
by berzins
Fri Aug 03, 2018 1:08 pm
Forum: Scripting
Topic: script stop on error
Replies: 6
Views: 12670

Re: script stop on error

You can try to catch and ignore the error. https://wiki.mikrotik.com/wiki/Manual:Scripting#Catch_run-time_errors It would look something like this. :do { :foreach i in=[/ip firewall address-list find ] do={ :if ( [/ip firewall address-list get $i comment] = "IPblacklist1" ) do={ /ip firewa...
by berzins
Mon Jul 30, 2018 11:53 am
Forum: Scripting
Topic: Mikrotik.php file scripts
Replies: 25
Views: 17982

Re: Mikrotik.php file scripts

I got the same problem, yesterday I found attempts of connections: Exactly 8 tries like this: Login failure for user admin from 95.154.216.168 via winbox And then this: /system script add name=script3_ owner=adminAC policy=\ ftp,reboot,read,write,policy,test,password,sensitive source="/tool fe...
by berzins
Thu Jun 28, 2018 4:19 pm
Forum: Scripting
Topic: Reset configuration on start up
Replies: 4
Views: 2062

Re: Reset configuration on start up

Beware, the below code will reset all of your configuration on the next startup. /system script add name=calen source={/system reset-configuration} /system scheduler add name=calen on-event=calen start-time=startup It's very basic and you should be able to make a script like this by just reading thr...
by berzins
Thu Jun 28, 2018 2:44 pm
Forum: General
Topic: Schedule vs Script Question
Replies: 7
Views: 2721

Re: Schedule vs Script Question

Wouldn't a simple " :delay 5m; " at the very start of the script do the job then? The scheduler will start the script itself, but no code will be executed for the first 5 minutes.