MikroTik RouterOS v2.9 Reference Manual page 655

Reference manual
Table of Contents

Advertisement

[admin@MikroTik] > :for i from=1 to=100 step=37
1
38
75
[admin@MikroTik] >
foreach - executes supplied commands for each element in list ( name ) - the name of the loop
counter variable ( ) - list of values over which to iterate ( text ) - contains the command to be
executed repeatedly
Printing a list of available interfaces with their respective IP addresses
:foreach
i
\...
do={:put
\...
:foreach
\...
do={:put
+--ether1
|
|
|
+--ether2
|
[admin@MikroTik] >
global - declares global variable ( name ) - name of the variable ( text ) - value, which should be
assigned to the variable
[admin@MikroTik]
[admin@MikroTik]
[admin@MikroTik]
[admin@MikroTik]
Global
IPAddr=10.0.0.1
time=00:10:00
MyString=This
Local
[admin@MikroTik] >
if - conditional statement. If a given logical condition evaluates to true then the do block of
commands is executed. Otherwice an optional else block is executed. ( yes | no ) - logical condition,
which is evaluated once before the execution of enclosed statements ( text ) - this block of
commands is executed if the logical condition evaluates to true ( text ) - this block of commands is
executed if the logical condition evaluates to false
Check if the firewall has any rules added
[admin@MikroTik]
else={:put
true
[admin@MikroTik] >
Check whether the gateway is reachable. In this example, the IP address of the gateway is
10.0.0.254
[admin@MikroTik] > :if ([/ping 10.0.0.254 count=1] = 0) do {:put "gateway unreachable"}
10.0.0.254
1
packets
gateway
[admin@MikroTik] >
led - allows to control the LEDs (Light Emitting Diodes) of the RouterBOARD 200 series
embedded boards. This command is available only on RouterBoard 200 platform with the
routerboard package installed ( yes | no ) - controls first LED ( yes | no ) - controls second LED (
yes | no ) - controls third LED ( yes | no ) - controls fourth LED ( time ) - specifies the length of the
action
Copyright 1999-2007, MikroTik. All rights reserved. Mikrotik, RouterOS and RouterBOARD are trademarks of Mikrotikls SIA.
Other trademarks and registred trademarks mentioned herein are properties of their respective owners.
in=[/interface
("+--"
.
j
in=[/ip
("|
`--"
>
:global
>
>
>
is
>
:if
([:len
[/ip
transmitted,
0
do={:put ($i . " - " . 1000/$i)}
-
-
-
find
[/interface
get
address
.
[/ip
address
MyString
"This
:global
:global
:environment
firewall
filter
ping
packets
received,
type=ether
$i
name]);
find
interface=$i]
get
$j
`--1.1.1.3/24
`--192.168.50.1/24
`--10.0.0.2/24
`--10.10.0.2/24
is
a
IPAddr
time
a
find]]
>
0)
do={:put
100%
packet
1000
26
13
]
\
\
address])}}
string"
10.0.0.1
0:10
print
Variables
string
Variables
true}
false}
timeout
loss
unreachable
Page 641 of 695

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the RouterOS v2.9 and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

Table of Contents

Save PDF