EasyManuals Logo

MikroTik RouterOS v2.9 User Manual

MikroTik RouterOS v2.9
709 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #655 background imageLoading...
Page #655 background image
[admin@MikroTik] > :for i from=1 to=100 step=37 do={:put ($i . " - " . 1000/$i)}
1 - 1000
38 - 26
75 - 13
[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 in=[/interface find type=ether ] \
\... do={:put ("+--" . [/interface get $i name]); \
\... :foreach j in=[/ip address find interface=$i]
\... do={:put ("| `--" . [/ip address get $j address])}}
+--ether1
| `--1.1.1.3/24
| `--192.168.50.1/24
| `--10.0.0.2/24
+--ether2
| `--10.10.0.2/24
[admin@MikroTik] >
global - declares global variable ( name ) - name of the variable ( text ) - value, which should be
assigned to the variable
[admin@MikroTik] > :global MyString "This is a string"
[admin@MikroTik] > :global IPAddr 10.0.0.1
[admin@MikroTik] > :global time 0:10
[admin@MikroTik] > :environment print
Global Variables
IPAddr=10.0.0.1
time=00:10:00
MyString=This is a string
Local Variables
[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] > :if ([:len [/ip firewall filter find]] > 0) do={:put true}
else={:put false}
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 ping timeout
1 packets transmitted, 0 packets received, 100% packet loss
gateway unreachable
[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
Page 641 of 695
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.

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

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

MikroTik RouterOS v2.9 Specifications

General IconGeneral
BrandMikroTik
ModelRouterOS v2.9
CategorySoftware
LanguageEnglish