Download General Information

Transcript
1
38
75
[admin@MikroTik] >
-
1000
26
13
-
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] >
in=[/interface
find
type=ether
]
\
("+--"
.
[/interface
get
$i
name]);
\
j
in=[/ip
address
find
interface=$i]
("|
`--"
.
[/ip
address
get
$j
address])}}
`--1.1.1.3/24
`--192.168.50.1/24
`--10.0.0.2/24
`--10.10.0.2/24
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] >
>
:global
>
>
>
MyString
:global
:global
"This
is
IPAddr
time
:environment
is
a
a
string"
10.0.0.1
0:10
print
Variables
string
Variables
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] >
:if
([:len
[/ip
firewall
filter
find]]
>
0)
do={:put
true}
false}
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
ping
timeout
1
packets
transmitted,
0
packets
received,
100%
packet
loss
gateway
unreachable
[admin@MikroTik] >
led - allows to control system built-in LEDs (Light Emitting Diodes). This command is available
only on RouterBoard platforms whith the routerboard or rb500 packages installed, depending on the
RouterBoard model. The number of available LEDs varies between different RouterBoard models
(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
Page 558 of 612
Copyright 1999-2005, 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.