Mikrotik Manual
Mikrotik Manual
Mikrotik Manual
Manual:CD Install
Applies to RouterOS: 2.9, v3, v4
CD Install Description
CD-Install allows to install MikroTik RouterOS to x86 boxes, which do not support Netinstall (all the
RouterBOARDs should be reinstalled with Netinstall).
CD Install Requirements
Router
• x86 box with hard drive
• CD-ROM
Additional PC
• CD-ROM
• CD burning application
• MikroTik RouterOS CD installation ISO image
Manual:CD Install 2
CD Install Example
Prepare MikroTik RouterOS CD Installation Disk
1. Download CD installation Image from MikroTik download page [1],
2. Burn ISO image to disk, you need PC with CD-ROM and application to write ISO files to CD. For Linux (the
latest Ubuntu release) you can use built-in application. Mouse right-click on the .iso file and specify 'Write to Disk'.
You got MikroTik RouterOS installation disk after process is finished.
Manual:CD Install 3
Router Preconfiguration
3. Switch on the x86 box, where you want to install MikroTik RouterOS, it should be with CD-ROM as well. Put
MikroTik RouterOS installation disk to CD-ROM and set to boot from CD-ROM in BIOS settings,
4. x86 will boot from MikroTik RouterOS installation disk and should offer you to select the RouterOS Packages to
install,
Manual:CD Install 4
Package Selection
5. Select the packages you want to install, it is possible to select all packages with a or minimum with m, then Press i
to install the RouterOS.
Installation
6. If you have previous installation of the RouterOS and want to reset the configuration, then answer no for the
question 'Do you want to keep old configuration ?' and click y to proceed,
7. You will the process of the packages installation. Router will ask for the reboot after installation is finished,
Manual:CD Install 5
9. MikroTik RouterOS is booted and you are ready to login. Default login is admin without any password,
10. The last of the installation to license the router, use the software-id to purchase the license,
Manual:CD Install 6
References
[1] http:/ / www. mikrotik. com/ download. html
Manual:Interface/PPPoE 7
Manual:Interface/PPPoE
Applies to RouterOS: v3, v4
Summary
The PPPoE (Point to Point Protocol over Ethernet) protocol provides extensive user management, network
management and accounting benefits to ISPs and network administrators. Currently PPPoE is used mainly by ISPs to
control client connections for xDSL and cable modems as well as plain Ethernet networks. PPPoE is an extension of
the standard Point to Point Protocol (PPP). The difference between them is expressed in transport method: PPPoE
employs Ethernet instead of serial modem connection.
Generally speaking, PPPoE is used to hand out IP addresses to clients based on the username (and workstation, if
desired) authentication as opposed to workstation only authentication, when static IP addresses or DHCP are used. It
is adviced not to use static IP addresses or DHCP on the same interfaces as PPPoE for obvious security reasons.
The PPPoE client and server work over any Ethernet level interface on the router - wireless 802.11 (Aironet, Cisco,
WaveLan, Prism, Atheros), 10/100/1000 Mbit/s Ethernet, RadioLan and EoIP (Ethernet over IP tunnel).
Feature list
• PPPoE server and client support;
• Multilink PPP (MLPPP);
• MLPPP over single link (ability to transmit full-sized frames);
• BCP (Bridge Control Protocol) support - allows to send raw Ethernet frames over PPP links;
• MPPE 40bit and MPPE 128bit RSA encryption;
• pap, chap, mschap v1/v2 authentication;
• RADIUS support for client authentication and accounting.
Note that when RADIUS server is authenticating a user with CHAP, MS-CHAPv1 or MS-CHAPv2, the RADIUS
protocol does not use shared secret, it is used only in authentication reply. So if you have a wrong shared secret,
RADIUS server will accept the request. You can use /radius monitor command to see bad-replies parameter. This
value should increase whenever a client tries to connect.
Supported connections:
• MikroTik RouterOS PPPoE client to any PPPoE server (access concentrator)
• MikroTik RouterOS server (access concentrator) to multiple PPPoE clients (clients are avaliable for almost all
operating systems and most routers)
Manual:Interface/PPPoE 8
Specifications
• Packages required: ppp
• License required: Level1 (limited to 1 interface) , Level3 (limited to 200 interfaces) , Level4 (limited to 200
interfaces) , Level5 (limited to 500 interfaces) , Level6 (unlimited)
• Submenu level: /interface pppoe-server, /interface pppoe-client
• Standards and Technologies: PPPoE (RFC 2516)
• Hardware usage: PPPoE server may require additional RAM (uses approx. 9KiB (plus extra 10KiB for packet
queue, if data rate limitation is used) for each connection) and CPU power. Maximum of 65535 connections is
supported.
/interface pppoe-client
add name=pppoe-user-mike user=user password=passwd interface=wlan1 \
service-name=internet disabled=no
/ip pool
add name="pppoe-pool" ranges=10.1.1.62-10.1.1.72
/ppp profile
add name="pppoe-profile" local-address=10.1.1.1 remote-address=pppoe-pool
/ppp secret
add name=user password=passwd service=pppoe profile=pppoe-profile
PPPoE Operation
Stages
PPPoE has two stages:
• Discovery stage - a client discovers all available access concentrators and selects one of them to establish PPPoE
session.This stage has four steps: initialization, offer, request and session confirmation . PPPoE Discovery uses
special Ethernet frames with their own Ethernet frame type 0x8863.
To initiate discovery, PPPoE client sends PADI frame to the broadcast Ethernet address (FF:FF:FF:FF:FF:FF) and
may specify particular service name.
When server receives PADI frame, it responds with PADO frame to Client's unicast Ethernet address. There can be
more than one server in broadcast range of the client. In such case client collects PADO frames and picks one (in
most cases it picks the server which responded first) to start session.
Client sends PADR frame to unicast Ethernet address of the server it chose. If server agrees to set up a session with
this particular client, it allocates resources to set up PPP session and assigns Session ID number. This number is sent
back to client in PADS frame. When client receives PADS frame, it knows servers mac address and Session ID, it
allocates resources and session can begin.
• Session - When discovery stage is completed, both peers know PPPoE Session ID and other peer's Etehrnet
(MAC) address which together defines PPPoE session. PPP frames are encapsulated in PPPoE session frames,
which have Ethernet frame type 0x8864.
When server sends confirmation and client receives it, PPP Session stage is started that consists of following
steps:
• LCP negotiation
• Authentication
• IPCP negotiation - client is assigned with an IP address.
PPPoE server sends Echo-Request packets to the client to determine the state of the session, otherwise server will not
be able to determine that session is terminated in cases when client terminates session without sending
Manual:Interface/PPPoE 10
Terminate-Request packet.
More detailed description of PPPoE protocol can be found in RFC 2516
Packet Description
MTU
Typically largest Ethernet frame that can be transmitted without fragmentation is 1500 bytes. PPPoE adds another 6
bytes of overhead and PPP field adds two more bytes, leaving 1492 bytes for IP datagram. Therefore max PPPoE
MRU and MTU values must not be larger than 1492.
TCP stacks try to avoid fragmentation, os they use an MSS (Maximum Segment Size). By default MSS is chosen as
MTU of the outgoing interface minus the usual size of the TCP and IP headers (40 bytes), which results in 1460
bytes for an Eternet interface. Unfortunately there may be intermediate links with lower MTU which will cause
fragmentation. In such case TCP stack performs path MTU discovery. Routers which cannot forward the datagram
without fragmentation are supposed to drop packet and send ICMP-Fragmentation-Required to originating host.
When host receives such ICMP, it tries lower MTU. This should work in ideal world, however in real world many
routers do not generate fragmentation-required datagrams, also many firewalls drop all ICMP datagrams.
Workaround for this problem is to adjust MSS if it is too big. By default RouterOS adds mangle rules to intercept
TCP SYN packets and silently adjust any advertised MSS option so they will be appropriate for the PPPoE link.
Additional information on maximum supported MTUs for routerboards are listed here.
Manual:Interface/PPPoE 11
PPPoE Client
Sub-menu: /interface pppoe-client
Properties
Property Description
ac-name (string; Default: "") Access Concentrator name, this may ne left blank and the client will connect to any access
concentrator on the broadcast domain
add-default-route (yes|no; Default: no) Enable/Disable whether to add default route automatically
allow (mschap2|mschap1|chap|pap; Default: allowed authentication methods, by default all methods are allowed
mschap2,mschap1,chap,pap)
dial-on-demand (yes|no; Default: no) connects to AC only when outbound traffic is generated
mrru (integer: 512..65535|disabled; Default: maximum packet size that can be received on the link. If a packet is bigger than tunnel MTU, it
disabled) will be split into multiple packets, allowing full size IP or Ethernet packets to be sent over the
tunnel
name (string; Default: pppoe-out[i]) name of the PPPoE interface, generated by ROuterOS if not specified
profile (string; Default: default) default profile for the connection defined in /ppp profiles
service-name (string; Default: "") specifies the service name set on the access concentrator, can be left blank to connect to any
PPPoE server
use-peer-dns (yes|no; Default: no) enable/disable getting DNS settings from the peer
Status
Command /interface pppoe-client monitor will display current PPPoE status.
Available read only properties:
Property Description
ac-mac (MAC address) MAC address of the access concentrator (AC) the client is connected to
encoding (string) encryption and encoding (if asymmetric, separated with '/') being used in this connection
uptime (time) connection time displayed in days, hours, minutes and seconds
Manual:Interface/PPPoE 12
Scanner
Starting from v3.21 RouterOS has new tool - PPPoE Scanner. It allows you to scan all active PPPoE servers in
broadcast domain. Command to run scanner is as follows/interface pppoe-client scan <interface>
Available read only properties:
Property Description
Notes
Note for Windows. Some connection instructions may use the form where the "phone number", such as
"MikroTik_AC\mt1", is specified to indicate that "MikroTik_AC" is the access concentrator name and "mt1" is the
service name.
Specifying MRRU means enabling MP (Multilink PPP) over single link. This protocol is used to split big packets
into smaller ones. Under Windows it can be enabled in Networking tag, Settings button, "Negotiate multi-link for
single link connections". Their MRRU is hardcoded to 1614. This setting is usefull to overcome PathMTU discovery
failures. The MP should be enabled on both peers.
Example
To add and enable PPPoE client on the ether1 interface connecting to the AC that provides testSN service using user
name user with the password passwd:
[admin@RemoteOffice] interface pppoe-client> add interface=ether1 service-name=testSN user=user
password=passwd disabled=no
[admin@RemoteOffice] interface pppoe-client> print
Flags: X - disabled, R - running
0 R name="pppoe-out1" max-mtu=1480 max-mru=1480 mrru=disabled interface=ether1
user="user" password="passwd" profile=default service-name="testSN"
ac-name="" add-default-route=no dial-on-demand=no use-peer-dns=no
allow=pap,chap,mschap1,mschap2
Additional Resources
PPPoE Clients:
• RASPPPoE [1]for Windows 95, 98, 98SE, ME, NT4, 2000, XP, .NET
Properties
Property Description
interface (string; Default: "") Interface, which the clients are connected to
keepalive-timeout (time; Default: "10") Defines the time period (in seconds) after which the router is starting to send keepalive packets
every second. If no traffic and no keepalive responses came for that period of time (i.e. 2 *
keepalive-timeout), not responding client is proclaimed disconnected.
max-mru (integer; Default: "1480") Maximum Receive Unit. The optimal value is the MTU of the interface the tunnel is working over
decreased by 20 (so, for 1500-byte Ethernet link, set the MTU to 1480 to avoid fragmentation of
packets)
max-mtu (integer; Default: "1480") Maximum Transmission Unit. The optimal value is the MTU of the interface the tunnel is working
over decreased by 20 (so, for 1500-byte Ethernet link, set the MTU to 1480 to avoid fragmentation
of packets)
max-sessions (integer; Default: "0") Maximum number of clients that the AC can serve. '0'- no limitations.
mrru (integer: 512..65535 | disabled; Maximum packet size that can be received on the link. If a packet is bigger than tunnel MTU, it
Default: "disabled") will be split into multiple packets, allowing full size IP or Ethernet packets to be sent over the
tunnel.
one-session-per-host (yes | no; Default: Allow only one session per host (determined by MAC address). If a host will try to establish a new
"no") session, the old one will be closed
Notes
The default keepalive-timeout value of 10 is OK in most cases. If you set it to 0, the router will not disconnect clients
until they explicitly log out or the router is restarted. To resolve this problem, the one-session-per-host property can
be used.
Security issue: do not assign an IP address to the interface you will be receiving the PPPoE requests on.
Specifying MRRU means enabling MP (Multilink PPP) over single link. This protocol is used to split big packets
into smaller ones. Under Windows it can be enabled in Networking tag, Settings button, "Negotiate multi-link for
single link connections". Their MRRU is hardcoded to 1614. This setting is usefull to overcome PathMTU discovery
failures. The MP should be enabled on both peers.
Example
To add PPPoE server on ether1 interface providing ex service and allowing only one connection per host:
PPPoE Server
Sub-menu: /interface pppoe-server
There are two types of interface (tunnel) items in PPTP server configuration - static users and dynamic connections.
An interface is created for each tunnel established to the given server. Static interfaces are added administratively if
there is a need to reference the particular interface name (in firewall rules or elsewhere) created for the particular
user. Dynamic interfaces are added to this list automatically whenever a user is connected and its username does not
match any existing static entry (or in case the entry is active already, as there can not be two separate tunnel
interfaces referenced by the same name). Dynamic interfaces appear when a user connects and disappear once the
user disconnects, so it is impossible to reference the tunnel created for that use in router configuration (for example,
in firewall), so if you need a persistent rules for that user, create a static entry for him/her. Otherwise it is safe to use
dynamic configuration. Note that in both cases PPP users must be configured properly - static entries do not replace
PPP configuration.
Property Description
• encoding (read-only: text) - encryption and encoding (if asymmetric, separated with '/') being used in this
connection
• mru (read-only: integer) - client's MRU
• mtu (read-only: integer) - client's MTU
• name (name) - interface name
• remote-address (read-only: MAC address) - MAC address of the connected client
• service (name) - name of the service the user is connected to
• uptime (read-only: time) - shows how long the client is connected
• user (name) - the name of the connected user (must be present in the user darabase anyway)
Manual:Interface/PPPoE 15
Example
To view the currently connected users:
Application Examples
Now, configure the Ethernet interface, add the IP address and set the default route:
1 * name="default-encryption" use-compression=default
use-vj-compression=default use-encryption=yes only-one=default
change-tcp-mss=default
[admin@PPPoE-Server] ppp profile> .. secret
[admin@PPPoE-Server] ppp secret> add name=w password=wkst service=pppoe
[admin@PPPoE-Server] ppp secret> add name=l password=ltp service=pppoe
[admin@PPPoE-Server] ppp secret> print
Flags: X - disabled
# NAME SERVICE CALLER-ID PASSWORD PROFILE REMOTE-ADDRESS
0 w pppoe wkst default 0.0.0.0
1 l pppoe ltp default 0.0.0.0
[admin@PPPoE-Server] ppp secret>
Thus we have completed the configuration and added two users: w and l who are able to connect to Internet, using
PPPoE client software.
Note that Windows XP built-in client supports encryption, but RASPPPOE does not. So, if it is planned not to
support Windows clients older than Windows XP, it is recommended not to require encryption. In other case, the
server will accept clients that do not encrypt data.
Troubleshooting
• I can connect to my PPPoE server. The ping goes even through it, but I still cannot open web pages
Make sure that you have specified a valid DNS server in the router (in /ip dns or in /ppp profile the dns-server
parameter).
• The PPPoE server shows more than one active user entry for one client, when the clients disconnect, they
are still shown and active
Set the keepalive-timeout parameter (in the PPPoE server configuration) to 10 if You want clients to be considered
logged off if they do not respond for 10 seconds.
Note that if the keepalive-timeout parameter is set to 0 and the only-one parameter (in PPP profile settings) is set to
yes then the clients might be able to connect only once. To resolve this problem one-session-per-host parameter in
PPPoE server configuration should be set to yes
• My Windows XP client cannot connect to the PPPoE server
You have to specify the "Service Name" in the properties of the XP PPPoE client. If the service name is not set, or it
does not match the service name of the MikroTik PPPoE server, you get the "line is busy" errors, or the system
Manual:Interface/PPPoE 18
References
[1] http:/ / www. raspppoe. com/
Manual:Interface/VLAN
Applies to RouterOS: v3, v4+
Summary
Sub-menu: /interface vlan
Standards: IEEE 802.1Q [1]
Virtual Local Area Network (VLAN) is layer 2 method that allows you to have multiple Virtual LANs on a single
physical interface (ethernet, wireless, etc.), giving the ability to segregate LANs efficiently.
You can use MikroTik RouterOS (as well as Cisco IOS, Linux and other router systems) to mark these packets as
well as to accept and route marked ones.
As VLAN works on OSI Layer 2, it can be used just as any other network interface without any restrictions. VLAN
successfully passes through regular Ethernet bridges.
You can also transport VLANs over wireless links and put multiple VLAN interfaces on a single wireless interface.
Note that as VLAN is not a full tunnel protocol (i.e., it does not have additional fields to transport MAC addresses of
sender and recipient), the same limitation applies to bridging over VLAN as to bridging plain wireless interfaces. In
other words, while wireless clients may participate in VLANs put on wireless interfaces, it is not possible to have
VLAN put on a wireless interface in station mode bridged with any other interface.
Manual:Interface/VLAN 19
802.1Q
The most commonly used protocol for Virtual LANs (VLANs) is IEEE 802.1Q. It is standardized encapsulation
protocol that defines how to insert a four-byte VLAN identifier into Ethernet header. (see Figure 12.1.)
Each VLAN is treated as separate subnet. It means that, by default, host in specific VLAN cannot communicate with
host that is member of another VLAN, although they are connected in the same switch. So if you want inter-VLAN
communication you need a router. RouterOS supports up to 4095 VLAN interfaces, each with a unique VLAN ID,
per interface. VLAN priorites may also be used and manipulated.
When the VLAN extends over more than one switch, the inter-switch link have to become trunk, where packets are
tagged to indicate which VLAN they belong to. A trunk carries the traffic of multiple VLANs, it is like a
point-to-point link that carries tagged packets between switches or between a switch and router.
Manual:Interface/VLAN 20
Q-in-Q
Original 802.1Q allows only one vlan header, Q-in-Q in the other hand allows two or more vlan headers. In
RouterOS Q-in-Q can be configured by adding one vlan interface over another. Example:
/interface vlan
add name=vlan1 vlan-id=11 interface=ether1
add name=vlan2 vlan-id=12 interface=vlan1
If any packet is sent over "vlan2" interface, two vlan tags will be added to ethernet header - "11" and "12".
Properties
Property Description
interface (name; Default: ) Name of physical interface on top of which VLAN will work
l2mtu (integer; Default: ) Layer2 MTU. For VLANS this value is not configurable. Read more>>
vlan-id (integer: 4095; Default: 1) Virtual LAN identifier or tag that is used to distinguish VLANs. Must be equal for all
computers that belong to the same VLAN.
Note: MTU should be set to 1500 bytes as on Ethernet interfaces. But this may not work with some Ethernet
cards that do not support receiving/transmitting of full size Ethernet packets with VLAN header added (1500
bytes data + 4 bytes VLAN header + 14 bytes Ethernet header). In this situation MTU 1496 can be used, but
note that this will cause packet fragmentation if larger packets have to be sent over interface. At the same
time remember that MTU 1496 may cause problems if path MTU discovery is not working properly between
source and destination.
Setup examples
Simple Example
Lets assume that we have several MikroTik routers connected to a hub. Remember that hub is OSI physical layer
device (if there is a hub between routers, then from L3 point of view it is the same as Ethernet cable connection
between them). For simplification assume that all routers are connected to the hub using ether1 interface and has
assigned IP addresses as illustrated in figure below. Then on each of them the VLAN interface should be created.
Manual:Interface/VLAN 21
R4:
[admin@MikroTik] ip address>
R4:
Manual:Interface/VLAN 22
[admin@MikroTik] ip address>
At this point it should be possible to ping router R4 from router R2 and vice versa:
'''From R4 to R2:'''
To make sure if VLAN setup is working properly, try to ping R1 from R2. If pings are timing out then VLANs are
successfully isolated.
'''From R2 to R1:'''
Each VLAN has its own separate subnet (broadcast domain) as we see in figure above:
• VLAN 2 – 10.10.20.0/24;
• VLAN 3 – 10.10.30.0/24;
• VLAN 4 – 10.10.40.0./24.
VLAN configuration on most of switches is straightforward, basically we need to define which ports are members of
VLAN and define "trunk" port that can carry tagged frames between switch and router.
Configuration example on MikroTik router:
Create VLAN interfaces:
/interface vlan
add name=VLAN2 vlan-id=2 interface=ether1 disabled=no
add name=VLAN3 vlan-id=3 interface=ether1 disabled=no
add name=VLAN4 vlan-id=4 interface=ether1 disabled=no
/ip address
add address=10.10.20.1/24 interface=VLAN2
add address=10.10.30.1/24 interface=VLAN3
add address=10.10.40.1/24 interface=VLAN4
Manual:Interface/VLAN 24
RouterA:
RouterB:
[Back to Content]
References
[1] http:/ / standards. ieee. org/ getieee802/ download/ 802. 1Q-1998. pdf
Manual:IP/DHCP Server 25
Manual:IP/DHCP Server
Applies to RouterOS: v3, v4, v5+
Summary
Standards: RFC 2131
Package: dhcp
The DHCP (Dynamic Host Configuration Protocol) is needed for easy distribution of IP addresses in a network. The
MikroTik RouterOS implementation includes both server and client parts and is compliant with RFC 2131.
The router supports an individual server for each Ethernet-like interface. The MikroTik RouterOS DHCP server
supports the basic functions of giving each requesting client an IP address/netmask lease, default gateway, domain
name, DNS-server(s) and WINS-server(s) (for Windows clients) information (set up in the DHCP networks
submenu)
In order DHCP server to work, you must set up also IP pools (do not include the DHCP server's own IP address into
the pool range) and DHCP networks.
It is also possible to hand out leases for DHCP clients using the RADIUS server, here are listed the parameters for
used in RADIUS server.
Access-Request:
• NAS-Identifier - router identity
• NAS-IP-Address - IP address of the router itself
• NAS-Port - unique session ID
• NAS-Port-Type - Ethernet
• Calling-Station-Id - client identifier (active-client-id)
• Framed-IP-Address - IP address of the client (active-address)
• Called-Station-Id - name of DHCP server
• User-Name - MAC address of the client (active-mac-address)
• Password - ""
Access-Accept:
• Framed-IP-Address - IP address that will be assigned to client
• Framed-Pool - ip pool from which to assign ip address to client
• Rate-Limit - Datarate limitation for DHCP clients. Format is: rx-rate[/tx-rate] [rx-burst-rate[/tx-burst-rate]
[rx-burst-threshold[/tx-burst-threshold] [rx-burst-time[/tx-burst-time][priority] [rx-rate-min[/tx-rate-min]]]]. All
rates should be numbers with optional 'k' (1,000s) or 'M' (1,000,000s). If tx-rate is not specified, rx-rate is as
tx-rate too. Same goes for tx-burst-rate and tx-burst-threshold and tx-burst-time. If both rx-burst-threshold and
tx-burst-threshold are not specified (but burst-rate is specified), rx-rate and tx-rate are used as burst thresholds. If
both rx-burst-time and tx-burst-time are not specified, 1s is used as default. Priority takes values 1..8, where 1
implies the highest priority, but 8 - the lowest. If rx-rate-min and tx-rate-min are not specified rx-rate and tx-rate
values are used. The rx-rate-min and tx-rate-min values can not exceed rx-rate and tx-rate values.
• Ascend-Data-Rate - tx/rx data rate limitation if multiple attributes are provided, first limits tx data rate, second -
rx data rate. If used together with Ascend-Xmit-Rate, specifies rx rate. 0 if unlimited
Manual:IP/DHCP Server 26
• Ascend-Xmit-Rate - tx data rate limitation. It may be used to specify tx limit only instead of sending two
sequential Ascend-Data-Rate attributes (in that case Ascend-Data-Rate will specify the receive rate). 0 if
unlimited
• Session-Timeout - max lease time (lease-time)
lease time: 3d
[admin@MikroTik] ip dhcp-server>
The wizard has made the following configuration based on the answers above:
[admin@MikroTik] ip dhcp-server>
Manual:IP/DHCP Server 27
General
Sub-menu: /ip dhcp-server
Property Description
add-arp (yes | no; Default: no) Whether to add dynamic ARP entry. If set to no either ARP mode should be enabled on that interface or
static ARP entries should be administratively defined in /ip arp submenu.
address-pool (string | static-only; IP pool, from which to take IP addresses for clients. If set to static-only, then only the clients that have a
Default: static-only) static lease (i.e. no dynamic addresses will be given to clients, only the ones added in lease submenu) will be
allowed.
authoritative (after-10sec-delay | Whether the DHCP server is the only one DHCP server for the network:
after-2sec-delay | yes | no; Default: • after-10sec-delay - to clients request for an address, dhcp server will wait 10 seconds and if there is
after-2sec-delay) another request from the client after this period of time, then dhcp server will offer the address to the
client or will send DHCPNAK, if the requested address is not available from this server
• after-2sec-delay - to clients request for an address, dhcp server will wait 2 seconds and if there is another
request from the client after this period of time, then dhcp server will offer the address to the client or will
send DHCPNAK, if the requested address is not available from this server
• yes - to clients request for an address that is not available from this server, dhcp server will send negative
acknowledgment (DHCPNAK)
• no - dhcp server ignores clients requests for addresses that are not available from this server
delay-threshold (time | none; If secs field in DHCP packet is smaller than delay-threshold, then this packet is ignored. If set to none - there
Default: none) is no threshold (all DHCP packets are processed)
lease-time (time; Default: 72h) The time that a client may use the assigned address. The client will try to renew this address after a half of
this time and will request a new address after time limit expires.
relay (IP; Default: 0.0.0.0) The IP address of the relay this DHCP server should process requests from:
• 0.0.0.0 - the DHCP server will be used only for direct requests from clients (no DHCP really allowed)
• 255.255.255.255 - the DHCP server should be used for any incomming request from a DHCP relay
except for those, which are processed by another DHCP server that exists in the /ip dhcp-server submenu.
src-address (IP; Default: 0.0.0.0) The address which the DHCP client must send requests to in order to renew an IP address lease. If there is
only one static address on the DHCP server interface and the source-address is left as 0.0.0.0, then the static
address will be used. If there are multiple addresses on the interface, an address in the same subnet as the
range of given addresses should be used.
use-radius (yes | no; Default: no) Whether to use RADIUS server for dynamic leases
Manual:IP/DHCP Server 28
Property Description
setup () Start DHCP server setup wizard, which guides you through the steps to easily create all necessary configuration. Read more>>
Property Description
store-leases-disk (time | immediately | never; Default: 5m) How frequently lease changes should be stored on disk
Networks
Sub-menu: /ip dhcp-server network
Property Description
address (IP/netmask; the network DHCP server(s) will lend addresses from
Default: )
dns-server (string; the DHCP client will use these as the default DNS servers. Two comma-separated DNS servers can be specified to be
Default: ) used by DHCP client as primary and secondary DNS servers
domain (string; Default: ) The DHCP client will use this as the 'DNS domain' setting for the network adapter.
netmask (integer: 0..32; The actual network mask to be used by DHCP client. If set to '0' - netmask from network address will be used.
Default: 0)
ntp-server (IP; Default: ) the DHCP client will use these as the default NTP servers. Two comma-separated NTP servers can be specified to be
used by DHCP client as primary and secondary NTP servers
wins-server (IP; Default: ) The Windows DHCP client will use these as the default WINS servers. Two comma-separated WINS servers can be
specified to be used by DHCP client as primary and secondary WINS servers
Manual:IP/DHCP Server 29
Leases
Sub-menu: /ip dhcp-server lease
DHCP server lease submenu is used to monitor and manage server's leases. The issued leases are showed here as
dynamic entries. You can also add static leases to issue a particular client (identified by MAC address) the desired IP
address.
Generally, the DHCP lease it allocated as follows:
• an unused lease is in waiting state
• if a client asks for an IP address, the server chooses one
• if the client will receive statically assigned address, the lease becomes offered, and then bound with the respective
lease time
• if the client will receive a dynamic address (taken from an IP address pool), the router sends a ping packet and
waits for answer for 0.5 seconds. During this time, the lease is marked testing
• in case, the address does not respond, the lease becomes offered, and then bound with the respective lease time
• in other case, the lease becomes busy for the lease time (there is a command to retest all busy addresses), and the
client's request remains unanswered (the client will try again shortly)
A client may free the leased address. The dynamic lease is removed, and the allocated address is returned to the
address pool. But the static lease becomes busy until the client will reacquire the address.
Note: that the IP addresses assigned statically are not probed.
Properties
Property Description
address (IP; Default: ) Specify ip address (or ip pool) for static lease. If set to 0.0.0.0 - pool from server will be used
block-access (yes | no; Default: no) Block access for this client
client-id (string; Default: ) If specified, must match DHCP 'client identifier' option of the request
lease-time (time; Default: 0s) Time that the client may use the address. If set to 0s lease will never expire.
mac-address (MAC; Default: 00:00:00:00:00:00) If specified, must match the MAC address of the client
Property Description
host-name (text) Shows host name option from last received DHCP request
radius (yes | no) Shows, whether this dynamic lease is authenticated by RADIUS or not
rate-limit (string) Sets rate limit for active lease. Format is: rx-rate[/tx-rate] [rx-burst-rate[/tx-burst-rate]
[rx-burst-threshold[/tx-burst-threshold] [rx-burst-time[/tx-burst-time]]]]. All rates should be numbers with optional 'k'
(1,000s) or 'M' (1,000,000s). If tx-rate is not specified, rx-rate is as tx-rate too. Same goes for tx-burst-rate and
tx-burst-threshold and tx-burst-time. If both rx-burst-threshold and tx-burst-threshold are not specified (but burst-rate is
specified), rx-rate and tx-rate is used as burst thresholds. If both rx-burst-time and tx-burst-time are not specified, 1s is
used as default
Property Description
check-status (id) Check status of a given busy dynamic lease, and free it in case of no response
Alerts
Sub-menu: /ip dhcp-server alert
To find any rogue DHCP servers as soon as they appear in your network, DHCP Alert tool can be used. It will
monitor ethernet for all DHCP replies and check, whether this reply comes from a valid DHCP server. If reply from
unknown DHCP server is detected, alert gets triggered:
When the system alerts about a rogue DHCP server, it can execute a custom script.
As DHCP replies can be unicast, rogue dhcp detector may not receive any offer to other dhcp clients at all. To deal
with this, rogue dhcp detector acts as a dhcp client as well - it sends out dhcp discover requests once a minute
Properties
Property Description
alert-timeout (none | time; Time, after which alert will be forgotten. If after that time the same server will be detected, new alert will be
Default: none) generated. If set to none timeout will never expire.
interface (string; Default: ) Interface, on which to run rogue DHCP server finder.
on-alert (string; Default: ) Script to run, when an unknown DHCP server is detected.
Property Description
unknown-server (string) List of MAC addresses of detected unknown DHCP servers. Server is removed from this list after alert-timeout
Property Description
DHCP Options
Sub-menu: /ip dhcp-server option
With help of DHCP Option list, it is possible to define additional custom options for DHCP Server to advertise.
According to the DHCP protocol, a parameter is returned to the DHCP client only if it requests this parameter,
specifying the respective code in DHCP request Parameter-List (code 55) attribute. If the code is not included in
Parameter-List attribute, DHCP server will not send it to the DHCP client.
Properties
Property Description
code (integer:1..254; Default: ) dhcp option code. All codes are available at [1]
value (string; Default: ) Parameter's value in form of a string. If the string begins with "0x", it is assumed as a hexadecimal value
Manual:IP/DHCP Server 32
Example
Classless route adds specified route in clients routing table. In our example it will add dst-address=160.0.0.0/24
gateway=10.1.101.1
Result:
[admin@MikroTik] /ip route> print
Flags: X - disabled, A - active, D - dynamic, C - connect, S - static, r - rip, b - bgp, o - ospf,
m - mme, B - blackhole, U - unreachable, P - prohibit
# DST-ADDRESS PREF-SRC GATEWAY DISTANCE
0 ADS 0.0.0.0/0 10.1.101.1 0
1 ADS 160.0.0.0/24 10.1.101.1 0
Configuration Examples
[Back to Content]
References
[1] http:/ / www. iana. org/ assignments/ bootp-dhcp-parameters
Manual:IP/DHCP Relay
Applies to RouterOS: v3, v4 +
Summary
DHCP Relay is just a proxy that is able to receive a DHCP request and resend it to the real DHCP server.
Properties
Sub-menu: /ip dhcp-client
Manual:IP/DHCP Relay 33
Property Description
delay-threshold (time; Default: If secs field in DHCP packet is smaller than delay-threshold, then this packet is ignored
none)
dhcp-server (string; Default: ) List of DHCP servers' IP addresses which should the DHCP requests be forwarded to
interface (string; Default: ) Interface name the DHCP relay will be working on.
local-address (IP; Default: The unique IP address of this DHCP relay needed for DHCP server to distinguish relays. If set to 0.0.0.0 - the IP
0.0.0.0) address will be chosen automatically
DHCP relay does not choose the particular DHCP server in the dhcp-server list, it just send the incoming request to
all the listed servers.
Example setup
Let us consider that you have several IP networks 'behind' other routers, but you want to keep all DHCP servers on a
single router. To do this, you need a DHCP relay on your network which relies DHCP requests from clients to
DHCP server.
This example will show you how to configure a DHCP server and a DHCP relay which serve 2 IP networks -
192.168.1.0/24 and 192.168.2.0/24 that are behind a router DHCP-Relay.
IP addresses of DHCP-Server:
[admin@DHCP-Server] ip address>
IP addresses of DHCP-Relay:
To setup 2 DHCP Servers on DHCP-Server router add 2 pools. For networks 192.168.1.0/24 and 192.168.2.0:
[Back to Content]
Manual:IP/DHCP Client
Applies to RouterOS: v3, v4 +
Summary
The MikroTik RouterOS DHCP client may be enabled on any Ethernet-like interface at a time. The client will accept
an address, netmask, default gateway, and two dns server addresses. The received IP address will be added to the
interface with the respective netmask. The default gateway will be added to the routing table as a dynamic entry.
Should the DHCP client be disabled or not renew an address, the dynamic default route will be removed. If there is
already a default route installed prior the DHCP client obtains one, the route obtained by the DHCP client would be
shown as invalid.
After interface is added, you can use rint" or "print detail" command to see what parameters DHCP client acquired:
Note: If interface used by DHCP client is part of VRF configuration, then default route and other received
routes from DHCP server will be added to VRF routing table.
Properties
Sub-menu: /ip dhcp-client
Manual:IP/DHCP Client 36
Property Description
add-default-route (yes | no; Default: yes) Whether to install default route in routing table received from dhcp server.
client-id (string; Default: ) Corresponds to the settings suggested by the network administrator or ISP. If not specified, client's
MAC address will be sent
host-name (string; Default: ) Host name of the client sent to a DHCP server. If not specified, client's system identity will be used.
use-peer-dns (yes | no; Default: yes) Whether to accept the DNS settings advertised by DHCP Server. (Will override the settings put in the
/ip dns submenu.
use-peer-ntp (yes | no; Default: yes) Whether to accept the NTP settings advertised by DHCP Server. (Will override the settings put in the
/system ntp client submenu)
Status
Command /ip dhcp-client print detail will show current status of dhcp client and read-only properties listed in table
below:
Property Description
address (IP/Netmask) IP address and netmask, which is assigned to DHCP Client from the
Server
expires-after (time) Time when the lease expires (specified by the DHCP server).
netmask (IP)
primary-dns (IP) IP address of the primary DNS server, assigned by the DHCP server
primary-ntp (IP) IP address of the primary NTP server, assigned by the DHCP server
secondary-dns (IP) IP address of the secondary DNS server, assigned by the DHCP server
secondary-ntp (IP) IP address of the secondary NTP server, assigned by the DHCP server
status (bound | error | rebinding... | requesting... | searching... | Shows the status of DHCP Client
stopped)
Property Description
renew Renew current leases. If the renew operation was not successful, client tries to reinitialize lease (i.e. it starts lease request
(numbers) procedure (rebind) as if it had not received an IP address yet)
[Back to Content]
Manual:Interface/Traffic Engineering
Applies to RouterOS: v3, v4+
Properties
Sub-menu: /interface traffic-eng
Property Description
affinity-exclude (integer; Default: ) Do not use interface if resource-class matches any of specified bits.
affinity-include-all (integer; Default: ) Use interface only if resource-class matches all of specified bits.
affinity-include-any (integer; Default: ) Use interface if resource-class matches any of specified bits.
auto-bandwidth-avg-interval (time; Default: 5m) Interval in which actual amount of data is measured, from which average bandwidth is
calculated.
auto-bandwidth-reserve (integer[%]; Default: Specifies percentage of additional bandwidth to reserve. Read more >>
0%)
auto-bandwidth-update-interval (time; Default: Interval during which tunnel keeps track of highest average rate.
1h)
bandwidth (integer[bps]; Default: 0bps) How much bandwidth to reserve for TE tunnel. Value is in bits per second. Read more >>
bandwidth-limit (disabled | integer[%]; Default: Defines actual bandwidth limitation of TE tunnel. Limit is configured in percent of specified
disabled) tunnel bandwidth. Read more >>
disable-running-check (yes | no; Default: no) Specifies whether to detect if interface is running or not. If set to no interface will always
have running flag.
disabled (yes | no; Default: yes) Defines whether item is ignored or used.
from-address (auto | IP; Default: auto) Ingress address of the tunnel. If set to auto least IP address is picked.
holding-priority (integer [0..7]; Default: ) Is used to decide whether this session can be preempted by another session. 0 sets the highest
priority.
primary-path (string; Default: ) Primary label switching paths defined in /mpls traffic-eng tunnel-path menu.
Manual:Interface/Traffic Engineering 38
primary-retry-interval (time; Default: 1m) Interval after which tunnel will try to use primary path.
record-route (yes | no; Default: ) If enabled, the sender node will receive information about the actual route that the LSP tunnel
traverses. Record Route is analogous to a path vector, and hence can be used for loop
detection.
reoptimize-interval (time; Default: ) Interval after which tunnel will re-optimize current path. If current path is not the best path
then after optimization best path will be used. Read more >>
secondary-path (string[,string]; Default: ) List of label switching paths used by TE tunnel if primary path fails. Paths are defined in
/mpls traffic-eng tunnel-path menu.
setup-priority (integer[0..7]; Default: ) Parameter is used to decide whether this session can preempt another session. 0 sets the
highest priority.
Monitoring
To verify TE tunnel's status monitor command can be used.
Reoptimization
Path can be re-optimized manually by entering following command /interface traffic-eng reoptimize [id]. It allows
network administrators to reoptimize the LSPs that have been established based on changes in bandwidth, traffic,
management policy, or other factors.
Lets say TE tunnel chose another path after link failure on best path. You can verify optimization by looking at
explicit-route or recorded-route if record-route parameter is enabled.
Whenever the link comes back, TE tunnel will use the same path even it is not the best path (unless
reoptimize-interval is configured). To fix it we can manually reoptimize tunnel path.
See Also
• TE Tunnel Auto Bandwidth
• TE tunnels explained
[Back to Content]
Manual:HTB
Applies to RouterOS: 2.9, v3, v4
Theory
Structure
Hierarchical Token Bucket (HTB) allows to create a hierarchical queue structure and determine relations between
queues, like "parent-child" or "child-child".
As soon as queue has at least one child it becomes a inner queue, all queues without children - leaf queues. Leaf
queues make actual traffic consumption, Inner queues are responsible only for traffic distribution. All leaf queues
are treated on equal basis.
In RouterOS it is necessary to specify parent option to assign queue as a child to other queue
Manual:HTB 40
Dual Limitation
Each queue in HTB has two rate limits:
• CIR (Committed Information Rate) – (limit-at in RouterOS) worst case scenario, flow will get this amount of
traffic no matter what (assuming we can actually send so much data)
• MIR (Maximal Information Rate) – (max-limit in RouterOS) best case scenario, rate that flow can get up to, if
there queue's parent has spare bandwidth
In other words, at first limit-at (CIR) of the all queues will be satisfied, only then child queues will try to borrow the
necessary data rate from their parents in order to reach their max-limit (MIR).
Note: CIR will be assigned to the corresponding queue no matter what. (even if max-limit of the parent is exceeded)
That is why, to ensure optimal (as designed) usage of dual limitation feature, we suggest to stick to these rules:
• Sum of committed rates of all children must be less or equal to amount of traffic that is available to parent.
CIR(parent)* ≥ CIR(child1) +...+ CIR(childN)
*in case if parent is main parent CIR(parent)=MIR(parent)
• Maximal rate of any child must be less or equal to maximal rate of the parent
MIR (parent) ≥ MIR(child1) & MIR (parent) ≥ MIR(child2) & ... & MIR (parent) ≥ MIR(childN)
Queue colors in Winbox:
• 0% - 50% available traffic used - green
• 51% - 75% available traffic used - yellow
• 76% - 100% available traffic used - red
Priority
We already know that limit-at (CIR) to all queues will be given out no matter what.
Priority is responsible for distribution of remaining parent queues traffic to child queues so that they are able to reach
max-limit
Queue with higher priority will reach its max-limit before the queue with lower priority. 8 is the lowest priority, 1 is
the highest.
Make a note that priority only works:
• for leaf queues - priority in inner queue have no meaning.
• if max-limit is specified (not 0)
Examples
In this section we will analyze HTB in action. To do that we will take one HTB structure and will try to cover all the
possible situations and features, by changing the amount of incoming traffic that HTB have to recycle. and changing
some options.
Structure
Our HTB structure will consist of 5 queues:
• Queue01 inner queue with two children - Queue02 and Queue03
• Queue02 inner queue with two children - Queue04 and Queue05
• Queue03 leaf queue
• Queue04 leaf queue
• Queue05 leaf queue
Manual:HTB 41
Queue03, Queue04 and Queue05 are clients who require 10Mbps all the time Outgoing interface is able to handle
10Mbps of traffic.
Result of Example 1
• Queue03 will receive 6Mbps
• Queue04 will receive 2Mbps
• Queue05 will receive 2Mbps
• Clarification: HTB was build in a way, that, by satisfying all limit-ats, main queue no longer have throughput to
distribute
Manual:HTB 42
Result of Example 2
• Queue03 will receive 2Mbps
• Queue04 will receive 6Mbps
• Queue05 will receive 2Mbps
• Clarification: After satisfying all limit-ats HTB will give throughput to queue with highest priority.
Result of Example 3
• Queue03 will receive 2Mbps
• Queue04 will receive 6Mbps
• Queue05 will receive 2Mbps
• Clarification: After satisfying all limit-ats HTB will give throughput to queue with highest priority. But in this
case inner queue Queue02 had limit-at specified, by doing so, it reserved 8Mbps of throughput for queues
Queue04 and Queue05. From these two Queue04 have highest priority, that is why it gets additional throughput.
Manual:HTB 44
Result of Example 4
• Queue03 will receive ~3Mbps
• Queue04 will receive ~1Mbps
• Queue05 will receive ~6Mbps
• Clarification: Only by satisfying all limit-ats HTB was forced to allocate 20Mbps - 6Mbps to Queue03, 2Mbps
to Queue04, 12Mbps to Queue05, but our output interface is able to handle 10Mbps. As output interface queue is
usually FIFO throughput allocation will keep ratio 6:2:12 or 3:1:6
Manual:Queue Size 45
Manual:Queue Size
Applies to RouterOS: 2.9, v3, v4
As you can see in the picture above there are 25 steps and there are total of 1610 incoming packets over this time
frame.
Manual:Queue Size 46
100% Shaper
Queue is 100% shaper when every packet that is over allowed limits will be dropped immediately. This way all
packages that are not dropped will be sent out without any delay.
Lets apply max-limit=100 packets per step limitation to our example:
With this type of limitation only 1250 out of 1610 packets were able to pass the queue (22,4% packet drop), but all
packets arrive without delay.
100% Scheduler
Queue is 100% Scheduler when there is no packet drops at all, all packets are queued and will be sent out at the first
possible moment.
In each step queue must send out queued packets from previous steps first and only then sent out packets from this
step, this way it is possible to keep right sequence of packets.
We will again use same limit (100 packets per step)
There was no packet loss, but 630 (39,1%) packets had 1 step delay, and other 170 (10,6%) packets had 2 step
delay. (delay = latency)
Manual:Queue Size 47
There were 320 (19,9%) packets dropped and 80 (5,0%) packets had 1 step delay.
There were 190 (11,8%) packets dropped and 400 (24,8%) packets had 1 step delay.
Manual:Queues - PCQ Examples 48
There are two ways how to make this: using mangle and queue trees, or, using simple queues.
1. Mark all packets with packet-mark all:
/ip firewall mangle add chain=prerouting action=mark-packet new-packet-mark=all passthrough=no
2. Setup two PCQ queue types - one for download and one for upload. dst-address is classifier for user's download
traffic, src-address for upload traffic:
3. Finally, two queue rules are required, one for download and one for upload:
If you don't like using mangle and queue trees, you can skip step 1, do step 2, and step 3 would be to create one
simple queue as shown here:
Manual:Queues - PCQ Examples 49
See Also
• PCQ
Manual:Queues - PCQ
Applies to RouterOS: 2.9, v3, v4
Usage
PCQ was introduced to optimize massive QoS systems, where most of the queues are exactly the same for different
sub-streams. For example a sub-stream can be download or upload for one particular client (IP) or connection to
server.
PCQ algorithm is very simple - at first it uses selected classifiers to distinguish one sub-stream from another, then
applies individual FIFO queue size and limitation on every sub-stream, then groups all sub-streams together and
applies global FIFO queue size and limitation.
PCQ parameters:
• pcq-classifier (dst-address | dst-port | src-address | src-port; default: "") : selection of sub-stream identifiers
• pcq-rate (number) : maximal available data rate of each sub-steam
• pcq-limit (number) : queue size of one sub-stream in packets
• pcq-total-limit (number) : queue size of global FIFO queue
So instead of having 100 queues with 1000kbps limitation for download we can have one PCQ queue with 100
sub-streams
Manual:Queues - PCQ 50
Classification Examples
To better understand classification we will take a list of 18 packet streams from specific address and port, to a
specific address and port. Then we will choose a classifier and divide all 18 packet streams into PCQ sub-streams
Manual:Queues - PCQ 51
PCQ Burst for sub-streams. PCQ will have burst implementation identical to Simple Queues and Queue Tree
PCQ parameters:
• pcq-burst-rate (number) : maximal upload/download data rate which can be reached while the burst for
substream is allowed
• pcq-burst-threshold (number) : this is value of burst on/off switch
• pcq-burst-time (time) : period of time, in seconds, over which the average data rate is calculated. (This is NOT
the time of actual burst)
For detailed burst explanation refer to:
• Burst
PCQ also allows to use different size IPv4 and IPv6 networks as sub-stream identifiers . Before it was locked to
single IP address. This is done mainly for IPv6 as customers from ISP point of view will be represented by /64
network, but devices in customers network will be /128. PCQ can be used for both of these scenarios and more.
PCQ parameters:
• pcq-dst-address-mask (number) : size of IPv4 network that will be used as dst-address sub-stream identifier
• pcq-src-address-mask (number) : size of IPv4 network that will be used as src-address sub-stream identifier
• pcq-dst-address6-mask (number) : size of IPV6 network that will be used as dst-address sub-stream identifier
• pcq-src-address6-mask (number) : size of IPV6 network that will be used as src-address sub-stream identifier
See Also
• PCQ Examples
Manual:Queues - Burst
Applies to RouterOS: 2.9, v3, v4
Theory
Burst is a feature that allows to satisfy queue requirement for additional bandwidth even if required rate is bigger that
MIR (max-limit) for a limited period of time.
Burst can occur only if average-rate of the queue for the last burst-time seconds is smaller that burst-threshold.
Burst will stop if average-rate of the queue for the last burst-time seconds is bigger or equal to burst-threshold
Burst mechanism is simple - if burst is allowed max-limit value is replaced by burst-limit value. When burst is
disallowed max-limit value remains unchanged.
1. burst-limit (NUMBER) : maximal upload/download data rate which can be reached while the burst is allowed
2. burst-time (TIME) : period of time, in seconds, over which the average data rate is calculated. (This is NOT the
time of actual burst)
3. burst-threshold (NUMBER) : this is value of burst on/off switch
4. average-rate (read-only) : Every 1/16 part of the burst-time, the router calculates the average data rate of each
class over the last burst-time seconds
5. actual-rate (read-only) : actual traffic transfer rate of the queue
Manual:Queues - Burst 53
Example
Values: limit-at=1M , max-limit=2M , burst-threshold=1500k , burst-limit=4M
Client will try to download two 4MB (32Mb) blocks of data, first download will start at zero seconds, second
download will start at 17th second. Traffic was unused for last minute.
Burst-time=16s
As we can see as soon as client requested bandwidth it was able to get 4Mpbs burst for 6 seconds. This is longest
possible burst with given values (longest-burst-time = burst-threshold * burst-time / burst-limit). As soon as burst
runs out rest of the data will be downloaded with 2Mbps. This way block of data was downloaded in 9 seconds -
without burst it would take 16 seconds. Burst have 7 seconds to recharge before next download will start.
Note that burst is still disallowed when download started and it kicks in only afterwards - in the middle of download.
So with this example we proved that burst may happen in the middle of download. Burst was ~4 seconds long and
second block of was downloaded 4 seconds faster then without burst.
Average rate is calculated every 1/16 of burst time, so in this case 1s
Burst-time=8s
Manual:Queues - Burst 55
If we decrease burst-time to 8 seconds - we are able to see that in this case bursts are only at the beginning of
downloads
Average rate is calculated every 1/16th of burst time, so in this case every 0.5 seconds.
0.0 (0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0)/8=0Kbps average-rate < burst-threshold → Burst is allowed 4Mbps (2Mb per 0,5sek)
0.5 (0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+2)/8=250Kbps average-rate < burst-threshold → Burst is allowed 4Mbps (2Mb per 0,5sek)
1.0 (0+0+0+0+0+0+0+0+0+0+0+0+0+0+2+2)/8=500Kbps average-rate < burst-threshold → Burst is allowed 4Mbps (2Mb per 0,5sek)
1.5 (0+0+0+0+0+0+0+0+0+0+0+0+0+2+2+2)/8=750Kbps average-rate < burst-threshold → Burst is allowed 4Mbps (2Mb per 0,5sek)
2.0 (0+0+0+0+0+0+0+0+0+0+0+0+2+2+2+2)/8=1000Kbps average-rate < burst-threshold → Burst is allowed 4Mbps (2Mb per 0,5sek)
2.5 (0+0+0+0+0+0+0+0+0+0+0+2+2+2+2+2)/8=1250Kbps average-rate < burst-threshold → Burst is allowed 4Mbps (2Mb per 0,5sek)
3.0 (0+0+0+0+0+0+0+0+0+0+2+2+2+2+2+2)/8=1500Kbps average-rate = burst-threshold → Burst not allowed 2Mbps (1Mb per 0,5sek)
3.5 (0+0+0+0+0+0+0+0+0+2+2+2+2+2+2+1)/8=1625Kbps average-rate > burst-threshold → Burst not allowed 2Mbps (1Mb per 0,5sek)
4.0 (0+0+0+0+0+0+0+0+2+2+2+2+2+2+1+1)/8=1750Kbps average-rate > burst-threshold → Burst not allowed 2Mbps (1Mb per 0,5sek)
4.5 (0+0+0+0+0+0+0+2+2+2+2+2+2+1+1+1)/8=1875Kbps average-rate > burst-threshold → Burst not allowed 2Mbps (1Mb per 0,5sek)
5.0 (0+0+0+0+0+0+2+2+2+2+2+2+1+1+1+1)/8=2000Kbps average-rate > burst-threshold → Burst not allowed 2Mbps (1Mb per 0,5sek)
5.5 (0+0+0+0+0+2+2+2+2+2+2+1+1+1+1+1)/8=2125Kbps average-rate > burst-threshold → Burst not allowed 2Mbps (1Mb per 0,5sek)
6.0 (0+0+0+0+2+2+2+2+2+2+1+1+1+1+1+1)/8=2250Kbps average-rate > burst-threshold → Burst not allowed 2Mbps (1Mb per 0,5sek)
6.5 (0+0+0+2+2+2+2+2+2+1+1+1+1+1+1+1)/8=2375Kbps average-rate > burst-threshold → Burst not allowed 2Mbps (1Mb per 0,5sek)
7.0 (0+0+2+2+2+2+2+2+1+1+1+1+1+1+1+1)/8=2500Kbps average-rate > burst-threshold → Burst not allowed 2Mbps (1Mb per 0,5sek)
7.5 (0+2+2+2+2+2+2+1+1+1+1+1+1+1+1+1)/8=2625Kbps average-rate > burst-threshold → Burst not allowed 2Mbps (1Mb per 0,5sek)
8.0 (2+2+2+2+2+2+1+1+1+1+1+1+1+1+1+1)/8=2750Kbps average-rate > burst-threshold → Burst not allowed 2Mbps (1Mb per 0,5sek)
8.5 (2+2+2+2+2+1+1+1+1+1+1+1+1+1+1+1)/8=2625Kbps average-rate > burst-threshold → Burst not allowed 2Mbps (1Mb per 0,5sek)
9.0 (2+2+2+2+1+1+1+1+1+1+1+1+1+1+1+1)/8=2500Kbps average-rate > burst-threshold → Burst not allowed 2Mbps (1Mb per 0,5sek)
9.5 (2+2+2+1+1+1+1+1+1+1+1+1+1+1+1+1)/8=2375Kbps average-rate > burst-threshold → Burst not allowed 2Mbps (1Mb per 0,5sek)
10.0 (2+2+1+1+1+1+1+1+1+1+1+1+1+1+1+1)/8=2250Kbps average-rate > burst-threshold → Burst not allowed 2Mbps (1Mb per 0,5sek)
10.5 (2+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1)/8=2125Kbps average-rate > burst-threshold → Burst not allowed 2Mbps (1Mb per 0,5sek)
11.0 (1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1)/8=2000Kbps average-rate > burst-threshold → Burst not allowed 2Mbps (1Mb per 0,5sek)
11.5 (1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1)/8=2000Kbps average-rate > burst-threshold → Burst not allowed 2Mbps (1Mb per 0,5sek)
12.0 (1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1)/8=2000Kbps average-rate > burst-threshold → Burst not allowed 2Mbps (1Mb per 0,5sek)
12.5 (1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1)/8=2000Kbps average-rate > burst-threshold → Burst not allowed 2Mbps (1Mb per 0,5sek)
13.0 (1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1)/8=2000Kbps average-rate > burst-threshold → Burst not allowed 0Mbps (0Mb per 0,5sek)
13.5 (1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+0)/8=1875Kbps average-rate > burst-threshold → Burst not allowed 0Mbps (0Mb per 0,5sek)
14.0 (1+1+1+1+1+1+1+1+1+1+1+1+1+1+0+0)/8=1750Kbps average-rate > burst-threshold → Burst not allowed 0Mbps (0Mb per 0,5sek)
14.5 (1+1+1+1+1+1+1+1+1+1+1+1+1+0+0+0)/8=1625Kbps average-rate > burst-threshold → Burst not allowed 0Mbps (0Mb per 0,5sek)
15.0 (1+1+1+1+1+1+1+1+1+1+1+1+0+0+0+0)/8=1500Kbps average-rate > burst-threshold → Burst not allowed 0Mbps (0Mb per 0,5sek)
15.5 (1+1+1+1+1+1+1+1+1+1+1+0+0+0+0+0)/8=1375Kbps average-rate < burst-threshold → Burst is allowed 0Mbps (0Mb per 0,5sek)
16.0 (1+1+1+1+1+1+1+1+1+1+0+0+0+0+0+0)/8=1250Kbps average-rate < burst-threshold → Burst is allowed 0Mbps (0Mb per 0,5sek)
16.5 (1+1+1+1+1+1+1+1+1+0+0+0+0+0+0+0)/8=1125Kbps average-rate < burst-threshold → Burst is allowed 0Mbps (0Mb per 0,5sek)
17.0 (1+1+1+1+1+1+1+1+0+0+0+0+0+0+0+0)/8=1000Kbps average-rate < burst-threshold → Burst is allowed 2Mbps (1Mb per 0,5sek)
Manual:Queues - Burst 56
17.5 (1+1+1+1+1+1+1+0+0+0+0+0+0+0+0+1)/8=1000Kbps average-rate < burst-threshold → Burst is allowed 4Mbps (2Mb per 0,5sek)
18.0 (1+1+1+1+1+1+0+0+0+0+0+0+0+0+1+2)/8=1125Kbps average-rate < burst-threshold → Burst is allowed 4Mbps (2Mb per 0,5sek)
18.5 (1+1+1+1+1+0+0+0+0+0+0+0+0+1+2+2)/8=1250Kbps average-rate < burst-threshold → Burst is allowed 4Mbps (2Mb per 0,5sek)
19.0 (1+1+1+1+0+0+0+0+0+0+0+0+1+2+2+2)/8=1375Kbps average-rate < burst-threshold → Burst is allowed 4Mbps (2Mb per 0,5sek)
19.5 (1+1+1+0+0+0+0+0+0+0+0+1+2+2+2+2)/8=1500Kbps average-rate = burst-threshold → Burst not allowed 2Mbps (1Mb per 0,5sek)
20.0 (1+1+0+0+0+0+0+0+0+0+1+2+2+2+2+1)/8=1500Kbps average-rate = burst-threshold → Burst not allowed 2Mbps (1Mb per 0,5sek)
20.5 (1+0+0+0+0+0+0+0+0+1+2+2+2+2+1+1)/8=1500Kbps average-rate = burst-threshold → Burst not allowed 2Mbps (1Mb per 0,5sek)
21.0 (0+0+0+0+0+0+0+0+1+2+2+2+2+1+1+1)/8=1500Kbps average-rate = burst-threshold → Burst not allowed 2Mbps (1Mb per 0,5sek)
21.5 (0+0+0+0+0+0+0+1+2+2+2+2+1+1+1+1)/8=1625Kbps average-rate > burst-threshold → Burst not allowed 2Mbps (1Mb per 0,5sek)
22.0 (0+0+0+0+0+0+1+2+2+2+2+1+1+1+1+1)/8=1750Kbps average-rate > burst-threshold → Burst not allowed 2Mbps (1Mb per 0,5sek)
22.5 (0+0+0+0+0+1+2+2+2+2+1+1+1+1+1+1)/8=1875Kbps average-rate > burst-threshold → Burst not allowed 2Mbps (1Mb per 0,5sek)
23.0 (0+0+0+0+1+2+2+2+2+1+1+1+1+1+1+1)/8=2000Kbps average-rate > burst-threshold → Burst not allowed 2Mbps (1Mb per 0,5sek)
23.5 (0+0+0+1+2+2+2+2+1+1+1+1+1+1+1+1)/8=2125Kbps average-rate > burst-threshold → Burst not allowed 2Mbps (1Mb per 0,5sek)
24.0 (0+0+1+2+2+2+2+1+1+1+1+1+1+1+1+1)/8=2250Kbps average-rate > burst-threshold → Burst not allowed 2Mbps (1Mb per 0,5sek)
24.5 (0+1+2+2+2+2+1+1+1+1+1+1+1+1+1+1)/8=2375Kbps average-rate > burst-threshold → Burst not allowed 2Mbps (1Mb per 0,5sek)
25.0 (1+2+2+2+2+1+1+1+1+1+1+1+1+1+1+1)/8=2500Kbps average-rate > burst-threshold → Burst not allowed 2Mbps (1Mb per 0,5sek)
25.5 (2+2+2+2+1+1+1+1+1+1+1+1+1+1+1+1)/8=2500Kbps average-rate > burst-threshold → Burst not allowed 2Mbps (1Mb per 0,5sek)
26.0 (2+2+2+1+1+1+1+1+1+1+1+1+1+1+1+1)/8=2375Kbps average-rate > burst-threshold → Burst not allowed 2Mbps (1Mb per 0,5sek)
26.5 (2+2+1+1+1+1+1+1+1+1+1+1+1+1+1+1)/8=2250Kbps average-rate > burst-threshold → Burst not allowed 2Mbps (1Mb per 0,5sek)
27.0 (2+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1)/8=2125Kbps average-rate > burst-threshold → Burst not allowed 2Mbps (1Mb per 0,5sek)
27.5 (1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1)/8=2000Kbps average-rate > burst-threshold → Burst not allowed 2Mbps (1Mb per 0,5sek)
28.0 (1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1)/8=2000Kbps average-rate > burst-threshold → Burst not allowed 2Mbps (1Mb per 0,5sek)
28.5 (1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1)/8=2000Kbps average-rate > burst-threshold → Burst not allowed 2Mbps (1Mb per 0,5sek)
29.0 (1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1)/8=2000Kbps average-rate > burst-threshold → Burst not allowed 2Mbps (1Mb per 0,5sek)
29.5 (1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1)/8=2000Kbps average-rate > burst-threshold → Burst not allowed 2Mbps (1Mb per 0,5sek)
30.0 (1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1)/8=2000Kbps average-rate > burst-threshold → Burst not allowed 2Mbps (1Mb per 0,5sek)
30.5 (1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1)/8=2000Kbps average-rate > burst-threshold → Burst not allowed 0Mbps (0Mb per 0,5sek)
31.0 (1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+0)/8=1875Kbps average-rate > burst-threshold → Burst not allowed 0Mbps (0Mb per 0,5sek)
Manual:Packet Flow 57
Manual:Packet Flow
Applies to RouterOS: v3, v4, v5+
Overview
MikroTik RouterOS is designed to be easy to operate in various aspects of network configuration. Therefore creating
limitation for individual IP or natting internal clients to a public address or Hotspot configuration can be done
without the knowledge about how the packets are processed in the router - you just go to corresponding menu and
create necessary configuration.
However more complicated tasks, such as traffic prioritization, routing policies, where it is necessary to utilize more
than one RouterOS facility, requires knowledge: How these facilities work together? What happens when and why?
To address these questions we created a packet flow diagram.
Diagram
As it was impossible to get everything in one diagram, Packet flow diagram for Mikrotik RouterOS v3.x was
created in 2 parts:
• Bridging or Layer-2 (MAC) where Routing part is simplified to one "Layer-3" box
• Routing or Layer-3 (IP) where Bridging part is simplified to one "Bridging" box
The packet flow diagram is also available as a PDF [1].
Manual:Packet Flow 58
Analysis
Basic Concepts
- starting point in packets way through the router facilities. It does not matter what interface
(physical or virtual) packet is received it will start its way from here.
- last point in packets way through the router facilities. Just before the packet is actually sent out.
- last point in packets way to router itself, after this packet is discarded
Configurable Facilities
Each and every facilities in this section corresponds with one particular menu in RouterOS. Users are able to access
those menu and configure these facilities directly
- /ip accounting
- /interface bridge settings - available only for traffic that go through the bridge. For all other
traffic default value is Yes
- check if the actual input interface is a port for bridge OR checks if input interface is bridge
- allow to capture traffic witch otherwise would be discarded by connection tracking - this way our
Hotspot feature are able to provide connectivity even if networks settings are in complete mess
- bridge goes through the MAC address table in order to find a match to destination MAC address of
packet. When match is found - packet will be send out via corresponding bridge port. In case of no match - multiple
copies of packet will be created and packet will be sent out via all bridge ports
- router goes through the route n order to find a match to destination IP address of packet. When
match is found - packet will be send out via corresponding port or to the router itself . In case of no match - packet
will be discarded.
- this is a workaround that allows to set-up policy routing in mangle chain output
- indicates exact place where Time To Live (TTL) of the routed packet is reduced by 1. If it become
0 packet will be discarded
- self explainatory
- check if the actual output interface is a port for bridge OR checks if output interface is bridge
- undo all that was done by hotspot-in for the packets that is going back to client.
Manual:Packet Flow 60
Examples
IPsec encryption
Manual:Packet Flow 62
IPsec decryption
References
[1] http:/ / wiki. mikrotik. com/ images/ 1/ 1b/ Traffic_Flow_Diagram_RouterOS_3. x. pdf
Manual:Queue
Applies to RouterOS: 2.9, v3, v4
Queues
Submenu level: /queue
Queues are used to limit and prioritize traffic. They can be used to
• limit data rate for certain IP addresses, subnets, protocols, ports, and other parameters
• limit peer-to-peer traffic
• prioritize some packet flows over others
• configure traffic bursts for faster web browsing
• apply different limits based on time
• share available traffic among users equally, or depending on the load of the channel
Queue implementation in MikroTik RouterOS is based on Hierarchical Token Bucket (HTB). HTB allows to create
hierarchical queue structure and determine relations between queues.
In RouterOS, these hierarchical structures can be attached at 4 different places:
• global-in: represents all the input interfaces in general (INGRESS queue). Queues attached to global-in apply to
traffic that is received by the router before the packet filtering
• global-out: represents all the output interfaces in general (EGRESS queue).
Manual:Queue 63
• global-total: represents all input and output interfaces together (in other words it is aggregation of global-in and
global-out). Used in case when customers have single limit for both, upload and download.
• <interface name>: - represents one particular outgoing interface. Only traffic that is designated to go out via this
interface will pass this HTB queue.
There are two different ways how to configure queues in RouterOS:
• /queue simple menu - designed to ease configuration of simple, everyday queuing tasks (such as single client
upload/download limitation, p2p traffic limitation, etc.).
• /queue tree menu - for implementing advanced queuing tasks (such as global prioritization policy, user group
limitations). Requires marked packet flows from /ip firewall mangle facility.
Simple Queues
Submenu level: /queue simple
One configuration item in /queue simle' can create from 0 to 3 separate queues - one queue in global-in, one queue in
global-out and one queue in global-total. If all properties of a queue have default values (no set limits, queue type is
default), and queue has no children, then it is not actually created. This way, for exanple, creation of global-total
queues can be avoided if only upload/download limitation is used.
Simple queues have strict order - each packet must go through every queue until it will meet conditions. (In case of
1000 queues, packet for last queue will need to proceed through 999 queues before it will reach the destination)
{{{...}}}
Flow Identifiers
• target-addresses (multiple choice: IP address/netmask) : list of IP address ranges that will be limited by this
queue.
• interface (Name of the interface, or all) : identifies interface the target is connected to. Useful when it is not
possible to specify targets addresses.
Each of these two properties can be used to determine which direction is target upload and which is download.
Be careful to configure both of these options for the same queue - in case they will point to opposite directions queue
will not work.
If neither value of target-addresses nor of interface is specified, the queue will not be able to make difference
between upload and download, and will limit all traffic twice.
Other properties
• name (Text) : Unique queue identifier that can be used as parent option value for other queues
• direction (One of both, upload, download, none; default: both) : allow to enable one-directional limitation for
simple queues (disable other direction)
• both - limit both download and upload traffic
• upload - limit only traffic to the target
• download - limit only traffic from the target
• time (TIME-TIME,sun,mon,tue,wed,thu,fri,sat - TIME is local time, all day names are optional; default: not set) :
allow to specify time when particular queue will be active. Router must have correct time settings.
• dst-address (IP address/netmask) : allows to select only specific stream (from target address to this destination
address) for limitation explain what is target and what is dst and what is upload and what not
• p2p (one of all-p2p, bit-torrent, blubster, direct-connect, edonkey, fasttrack, gnutella, soulseek, winmx; default:
not set) : allow to select unencrypted packets of particular p2p for limitation
Manual:Queue 64
• packet-marks (Comma separated list of packet mark names) : allows to use marked packets from /ip firewall
mangle. Take look at the RouterOS packet flow diagram. It is necessary to mark packets before the simple queues
(before global-in HTB queue) or else target's download limitation will not work. The only mangle chain before
global-in is prerouting.
HTB Properties
• parent (Name of parent simple queue, or none) : assigns this queue as a child queue for selected target {{{...}}}.
Target queue can be HTB queue or any other previously created simple queue. In order for traffic to reach child
queues, parent queues must capture all necessary traffic.
• priority (1..8) : Prioritize one child queue over other child queue. Does not work on parent queues (if queue has
at least one child). One is the highest, eight is the lowest priority. Child queue with higher priority will have
chance to reach its limit-at before child with lower priority and after that child queue with higher priority will
have chance to reach its max-limit before child with lower priority. Priority have nothing to do with bursts.
• queue (SOMETHING/SOMETHING) : Choose the type of the upload/download queue. Queue types can be
created in /queue type.
• limit-at (NUMBER/NUMBER) : normal upload/download data rate that is guaranteed to a target
• max-limit (NUMBER/NUMBER) : maximal upload/download data rate that is allowed for a target to reach to
reach what
• burst-limit (NUMBER/NUMBER) : maximal upload/download data rate which can be reached while the burst is
active
• burst-time (TIME/TIME) : period of time, in seconds, over which the average upload/download data rate is
calculated. (This is NOT the time of actual burst)
• burst-threshold (NUMBER/NUMBER) : when average data rate is below this value - burst is allowed, as soon as
average data rate reach this value - burst is denied. (basically this is burst on/off switch). For optimal burst
behavior this value should above limit-at value and below max-limit value
And corresponding options for global-total HTB queue:
• total-queue (SOMETHING/SOMETHING): corresponds to queue
• total-limit-at (NUMBER/NUMBER): corresponds to limit-at
• total-max-limit (NUMBER/NUMBER): corresponds to max-limit
• total-burst-limit (NUMBER/NUMBER): corresponds to burst-limit
• total-burst-time (TIME/TIME): corresponds to burst-time
• total-burst-threshold (NUMBER/NUMBER): corresponds to burst-threshold
Good practice suggests that:
Sum of children's limit-at values must be less or equal to max-limit of the parent.
Every child's max-limit must be less than max-limit of the parent. This way you will leave some traffic for
the other child queues, and they will be able to get traffic without fighting for it with other child queues.
Manual:Queue 65
Statistics
• rate (read-only/read-only) : average queue passing data rate in bytes per second
• packet-rate (read-only/read-only) : average queue passing data rate in packets per second
• bytes (read-only/read-only) : number of bytes processed by this queue
• packets (read-only/read-only) : number of packets processed by this queue
• queued-bytes (read-only/read-only) : number of bytes waiting in the queue
• queued-packets (read-only/read-only) : number of packets waiting in the queue
• dropped (read-only/read-only) : number of dropped packets
• borrows (read-only/read-only) : packets that passed queue over its "limit-at" value (and was unused and taken
away from other queues)
• lends (read-only/read-only) : packets that passed queue below its "limit-at" value OR if queue is a parent - sum of
all child borrowed packets
• pcq-queues (read-only/read-only) : number of PCQ substreams, if queue type is PCQ
And corresponding options for global-total HTB queue:
• total-rate (read-only): corresponds to rate
• total-packet-rate (read-only): corresponds to packet-rate
• total-bytes (read-only): corresponds to bytes
• total-packets (read-only): corresponds to packets
• total-queued-bytes (read-only): corresponds to queued-bytes
• total-queued-packets (read-only): corresponds to queued-packets
• total-dropped (read-only): corresponds to dropped
• total-lends (read-only): corresponds to lends
• total-borrows (read-only): corresponds to borrows
• total-pcq-queues (read-only): corresponds to pcq-queues
Queue Tree
Submenu level: /queue tree
Queue tree creates only one directional queue in one of the HTBs. It is also the only way how to add queue on the
separate interface. This way it is possible to ease mangle configuration - you don't need separate marks for download
and upload - only upload will get to Public interface and only download will get to Private interface.
Also it is possible to have double queuing (example:prioritization of traffic in global-in or global-out, limitation per
client on the outgoing interface) If you have simple queues and queue tree in the same HTB - simple queues will get
traffic first.
Queue tree is not ordered - all traffic pass it together.
Manual:Queue 66
Flow Identifiers
• name (Text) : Unique queue identifier that can be used as parent option value for other queues
• packet-marks (Comma separated list of) : allows to use marked packets from /ip firewall mangle. Take look at
this packet flow diagram. You need to make sure that packets are marked before the simple queues (before
global-in HTB queue)
HTB Properties
• parent (Name of , or none) : assigns this queue as a child queue for selected target. Target queue can be HTB
queue or any other previously created queue
• priority (1..8) : Prioritize one child queue over other child queue. Does not work on parent queues (if queue has
at least one child). One is the highest, eight is the lowest priority. Child queue with higher priority will have
chance to reach its limit-at before child with lower priority and after that child queue with higher priority will
have chance to reach its max-limit before child with lower priority. Priority have nothing to do with bursts.
• queue (SOMETHING) : Choose the type of the queue. Queue types can be created here
• limit-at (NUMBER) : normal data rate that is guaranteed to a target
• max-limit (NUMBER) : maximal data rate that is allowed for a target to reach
• burst-limit (NUMBER) : maximal data rate which can be reached while the burst is active
• burst-time (TIME) : period of time, in seconds, over which the average data rate is calculated. (This is NOT the
time of actual burst)
• burst-threshold (NUMBER) : when average data rate is below this value - burst is allowed, as soon as average
data rate reach this value - burst is denied. (basically this is burst on/off switch). For optimal burst behavior this
value should above limit-at value and below max-limit value
Statistics
• rate (read-only) : average queue passing data rate in bytes per second
• packet-rate (read-only) : average queue passing data rate in packets per second
• bytes (read-only) : number of bytes processed by this queue
• packets (read-only) : number of packets processed by this queue
• queued-bytes (read-only) : number of bytes waiting in the queue
• queued-packets (read-only) : number of packets waiting in the queue
• dropped (read-only) : number of dropped packets
• borrows (read-only) : packets that passed queue over its "limit-at" value (and was unused and taken away from
other queues)
• lends (read-only) : packets that passed queue below its "limit-at" value OR if queue is a parent - sum of all child
borrowed packets
• pcq-queues (read-only) : number of PCQ substreams, if queue type is PCQ
Manual:Queue 67
Queue Types
Submenu level: /queue type
• name (Text) : Unique queue identifier that can be used in simple queues and queue tree as value of queue option
• kind (bfifo | pcq | pfifo | red | sfq) : kind of particular queue type
RED
Random Early Drop is a queuing mechanism which tries to avoid network congestion by controlling the average
queue size. When the average queue size reaches red-min-threshold, RED starts to drop packets randomly with
linearly increasing probability as the average queue size grows up until the average queue size reaches the
red-max-threshold. The effective queue size at any moment could be higher than the red-max-threshold as the
probability does not grow very fast, so it is possible to specify a hard limit for the queue size. When the average
queue size reaches red-max-threshold or becomes larger, all further packets are dropped until the average queue size
does not drop below this values (at which point probabilistic calculations will be activated again).
• red-avg-packet (number) : Used by RED for average queue size calculations (for packet to byte translation)
• red-burst (number) : Number of packets allowed for bursts of packets when there are no packets in the queue
• red-limit(number) : RED queue limit in packets
• red-max-threshold (number) : The average queue size at which packet marking probability is the highest
• red-min-threshold (number) : Average queue size in bytes
SFQ
Stochastic Fairness Queuing (SFQ) is ensured by hashing and round-robin algorithms. A traffic flow may be
uniquely identified by a 4 options(src-address, dst-address, src-port and dst-port), so these parameters are used by
SFQ hashing algorithm to classify packets into one of 1024 possible sub-streams. Then round-robin algorithm will
start to distribute available bandwidth to all sub-streams, on each round giving sfq-allot bytes of traffic. The whole
SFQ queue can contain 128 packets and there are 1024 sub-streams available.
• sfq-allot (number) : How often hash function must be refreshed
• sfq-perturb (time) : Amount of data in bytes that can be sent in one round-robin round
Manual:Queue 68
PCQ
Per Connection Queuing (PCQ) is a similar to SFQ, but it has additional features.
It is possible to choose flow identifiers (from dst-address | dst-port | src-address | src-port). For example if you
classify flows by src-address on local interface (interface with your clients), each PCQ sub-stream will be one
particular client's upload.
It is possible to assign speed limitation to sub-streams with pcq-rate option. If pcq-rate=0 sub-streams will
divide available traffic equally.
PCQ parameters:
• pcq-classifier (dst-address | dst-port | src-address | src-port; default: "") : selection of sub-stream identifiers
• pcq-rate (number) : maximal available data rate of each sub-steam
• pcq-limit (number) : queue size of one sub-stream in packets
• pcq-total-limit (number) : queue size of global FIFO queue
Interface Queue
Submenu level: /queue interface
• interface(SOMETHING) : name of interface
• queue (something) : queue type assigned to particular interface
Manual:Interface/Bonding
Applies to RouterOS: v3, v4
Summary
Bonding is a technology that allows to aggregate multiple ethernet-like interfaces into a single virtual link, thus
getting higher data rates and providing failover.
Specifications
• Packages required: system
• License required: Level1
• Submenu level: /interface bonding
• Standards and Technologies: None
• Hardware usage: Not significant
Manual:Interface/Bonding 69
And on Router2:
Note: bonding interface needs a couple of seconds to get connectivity with its peer.
Link monitoring
It is critical that one of available link monitoring options are enabled. In example above if one of
the bonded links fail, bonding driver will still continue to send packets over failed link which will
lead to network degradation. Currently bonding in RouterOS supports two schemes for monitoring a link state of
slave devices: MII and ARP monitoring. It is not possible to use both methods at a time due to restrictions in the
bonding driver.
ARP Monitoring
ARP monitoring sends ARP queries and uses the response as an indication that the link is operational. This also
gives assurance that traffic is actually flowing over the links. If balance-rr and balance-xor modes are set, then the
switch should be configured to evenly distribute packets across all links. Otherwise all replies from the ARP targets
will be received on the same link which could cause other links to fail. ARP monitoring is enabled by setting three
properties link-monitoring, arp-ip-targets and arp-interval. Meaning of each option is described later in this article. It
is possible to specify multiple ARP targets that can be useful in a High Availability setups. If only one target is set,
the target itself may go down. Having an additional targets increases the reliability of the ARP monitoring.
Enable ARP monitoring
We will not change arp-interval value in our example, RouterOS sets arp-interval to 100ms by default.
Manual:Interface/Bonding 70
Unplug one of the cables to test if link monitoring works correctly, you will notice some ping timeouts until arp
monitoring detects link failure.
MII monitoring
MII monitoring monitors only the state of the local interface. In RouterOS it is possible to configure MII monitoring
in two ways:
• MII Type 1 - device driver determines whether link is up or down. If device driver does not support this option
then link will appear as always up.
• MII Type 2 - deprecated calling sequences within the kernel are used to determine if link is up. This method is
less efficient but can be used on all devices. This mode should be set only if MII type 1 is not supported.
Main disadvantage is that MII monitoring can't tell if the link actually can pass the packets or not even if the link is
detected as up.
MII monitoring is configured setting desired link-monitoring mode and mii-interval.
Enable MII Type2 monitoring:
Bonding modes
802.3ad
802.3ad mode is an IEEE standard also called LACP (Link Aggregation Control Protocol). It includes automatic
configuration of the aggregates, so minimal configuration of the switch is needed. This standard also mandates that
frames will be delivered in order and connections should not see mis-ordering of packets. Also standard mandates
that all devices in the aggregate must operate at the same speed and duplex and works only with MII link monitoring.
LACP balances outgoing traffic across the active ports based on hashed protocol header information and accepts
incoming traffic from any active port. The hash includes the Ethernet source and destination address, and, if
available, the VLAN tag, and the IPv4/IPv6 source and destination address. How has is calculated depends on
transmit-hash-policy parameter.
Manual:Interface/Bonding 71
Configuration example
Example connects two ethernet interfaces on a router to the Edimax switch as a single load balanced and fault
tolerant link. More interfaces can be added to increase throughput and fault tolerance. Since frame ordering is
mandatory on Ethernet links then any traffic between two devices always flows over the same physical link limiting
the maximum speed to that of one interface. The transmit algorithm attempts to use as much information as it can to
distinguish different traffic flows and balance across the available interfaces.
Router R1 configuration:
/inteface bonding add slaves=ether1,ether2 mode=802.3ad lacp-rate=30secs link-monitoring=mii-type1 \
transmit-hash-policy=layer-2-and-3
Configuration on a switch:
TRK1 LACP
TRK2 Disable
TRK3 Disable
TRK4 Disable
TRK5 Disable
TRK6 Disable
TRK7 Disable
Notice that LACP is enabled on first trunk group (TRK1) and switch ports on first trunk group are bound with 'v'
flag. In our case port 2 and port4 will run LACP.
Verify if LACP is working: On the switch at first we should verify if LACP protocol is enabled and running:
Manual:Interface/Bonding 72
After that we can ensure that LACP negotiated with our router. If you don't see both ports on the list then something
is wrong and LACP is not going to work.
Group
[Actor] [Partner]
Priority: 1 65535
After we verified that switch successfully negotiated LACP with our router, we can start traffic from Client1 and
Client2 to the Server and check how traffic is evenly forwarded through both bonding slaves:
balance-rr
If this mode is set, packets are transmitted in sequential order from the first available slave to the last.
Balance-rr is the only mode that will send packets across multiple interfaces that belong to the same TCP/IP
connection.
When utilizing multiple sending and multiple receiving links, packets often are received out of order, which result in
segment retransmission, for other protocols such as UDP it is not a problem if client software can tolerate
out-of-order packets.
If switch is used to aggregate links together, then appropriate switch port configuration is required, however many
switches do not support balance-rr.
Manual:Interface/Bonding 73
Quick setup guide demonstrates use of the balance-rr bonding mode. As you can see, it is quite simple to set up.
Balance-rr is also useful for bonding several wireless links, however it requires equal bandwidth for all bonded links.
If bandwidth of one bonded link drops, then total bandwidth of bond will be equal to bandwidth of the slowest
bonded link.
active-backup
This mode uses only one active slave to transmit packets. Different slave becomes active only if primary slave fails.
Mac address of the bonding interface is visible only on active port to avoid confusing of the switch. Active-backup is
best choice in high availability setups with multiple switches that are interconnected.
ARP monitoring in this mode will not work correctly if both routers are directly connected. In such setups mii-type1
or mii-type2 monitoring must be used or switch should be put between routers.
balance-xor
This mode balances outgoing traffic across the active ports based on hashed protocol header information and accepts
incoming traffic from any active port. Mode is very similar to LACP except that it is not standardized and works
with layer-3-and-4 hash policy.
broadcast
When ports configured with broadcast mode, all slave ports transmits the same packets to the destination that way
providing fault tolerance. This mode does not provide load balancing.
balance-tlb
This mode balances outgoing traffic by peer. Each link can be a different speed and duplex and no specific switch
configuration is required as in other modes. Downside of this mode is that only MII link monitoring is supported and
incoming traffic is not balanced. Incoming traffic will use the link that is configured as "primary".
Configuration example
Lets assume than router has two links - ether1 max bandwidth is 10Mbps and ether2 max bandwidth is 5Mbps.
First link has more bandwidth so we set it as primary link
Image above illustrates how balance-tlb mode works. As you can see router can communicate to all the clients
connected to switch with total bandwidth of both links (15Mbps). But as you already know, balance-tlb is not
balancing incoming traffic. In our example clients can communicate to router with total bandwidth of primary link
which is 10Mbps in our configuration.
balance-alb
Mode is basically the same as balance-tlb but incoming traffic is also balanced. Only additional downside of this
mode is that it requires device driver capability to change mac address. Most of the cheap cards do not support this
mode.
Image above illustrates how balance-alb mode works. Compared to balance-tlb traffic from clients also can use
Manual:Interface/Bonding 75
Property Description
Property Description
arp (disabled | enabled | proxy-arp Address Resolution Protocol for the interface.
| reply-only; Default: enabled) • disabled - the interface will not use ARP
• enabled - the interface will use ARP
• proxy-arp - the interface will use the ARP proxy feature
• reply-only - the interface will only reply to the requests originated to its own IP addresses. Neighbour
MAC addresses will be resolved using /ip arp statically set table only
arp-interval (time; Default: time in milliseconds which defines how often to monitor ARP requests
00:00:00.100)
arp-ip-targets (IP addres; Default: IP target address which will be monitored if link-monitoring is set to arp. You can specify multiple IP
) addresses, separated by comma
down-delay (time; Default: if a link failure has been detected, bonding interface is disabled for down-delay time. Value should be a
00:00:00) multiple of mii-interval
lacp-rate (1sec | 30secs; Default: Link Aggregation Control Protocol rate specifies how often to exchange with LACPDUs between bonding
30secs) peer. Used to determine whether link is up or other changes have occurred in the network. LACP tries to
adapt to these changes providing failover.
link-monitoring (arp | mii-type1 | method to use for monitoring the link (whether it is up or down)
mii-type2 | none; Default: none) • arp - uses Address Resolution Protocol to determine whether the remote interface is reachable
• mii-type1 - uses Media Independent Interface type1 to determine link status. Link status determenation
relies on the device driver
• mii-type2 - similar as mii-type1, but status determination does not rely on the device driver
• none - no method for link monitoring is used.
Note: some bonding modes require specific link monitoring to work properly.
mii-interval (time; Default: how often to monitor the link for failures (parameter used only if link-monitoring is mii-type1 or mii-type2)
00:00:00.100)
• 802.3ad - IEEE 802.3ad dynamic link aggregation. In this mode, the interfaces are aggregated in a group
where each slave shares the same speed. Provides fault tolerance and load balancing. Slave selection for
outgoing traffic is done according to the transmit-hash-policy more>
• active-backup - provides link backup. Only one slave can be active at a time. Another slave becomes
active only, if first one fails. more>
• balance-alb - adaptive load balancing. The same as balance-tlb but received traffic is also balanced.
Device driver should have support for changing the mac address. more>
• balance-rr - round-robin load balancing. Slaves in bonding interface will transmit and receive data in
sequential order. Provides load balancing and fault tolerance. more>
• balance-tlb - Outgoing traffic is distributed according to the current load on each slave. Incoming traffic is
not balanced and is received by the current slave. If receiving slave fails, then another slave takes the
MAC address of the failed slave. more>
• balance-xor - Transmit based on the selected transmit-hash-policy. This mode provides load balancing
and fault tolerance. more>
• broadcast - Broadcasts the same data on all interfaces at once. This provides fault tolerance but slows
down traffic throughput on some slow machines. more>
primary (string; Default: ) Interface is used as primary output interface. If primary interface fails, only then others slaves will be used.
This value works only with active-backup mode
slaves (string; Default: none) at least two ethernet-like interfaces separated by a comma, which will be used for bonding
up-delay (time; Default: 00:00:00) if a link has been brought up, bonding interface is disabled for up-delay time and after this time it is enabled.
Value should be a multiple of mii-interval
transmit-hash-policy (layer-2 | Selects the transmit hash policy to use for slave selection in balance-xor and 802.3ad modes
layer-2-and-3 | layer-3-and-4;
Default: layer-2)
• layer-2 - Uses XOR of hardware MAC addresses to generate the hash. This algorithm will place all traffic
to a particular network peer on the same slave. This algorithm is 802.3ad compliant.
• layer-2-and-3 - This policy uses a combination of layer2 and layer3 protocol information to generate the
hash. Uses XOR of hardware MAC addresses and IP addresses to generate the hash. This algorithm will
place all traffic to a particular network peer on the same slave. For non-IP traffic, the formula is the same
as for the layer2 transmit hash policy. This policy is intended to provide a more balanced distribution of
traffic than layer2 alone, especially in environments where a layer3 gateway device is required to reach
most destinations. This algorithm is 802.3ad compliant.
• layer-3-and-4 - This policy uses upper layer protocol information, when available, to generate the hash.
This allows for traffic to a particular network peer to span multiple slaves, although a single connection
will not span multiple slaves. For fragmented TCP or UDP packets and all other IP protocol traffic, the
source and destination port information is omitted. For non-IP traffic, the formula is the same as for the
layer2 transmit hash policy. This algorithm is not fully 802.3ad compliant.
Notes
Link failure detection and failover is working significantly better with expensive network cards, for example, made
by Intel, then with more cheap ones. For example, on Intel cards failover is taking place in less than a second after
link loss, while on some other cards, it may require up to 20 seconds. Also, the Active load balancing
(mode=balance-alb) does not work on some cheap cards.
Manual:TE Tunnels Example 77
/ip address
add address=192.168.55.1/30 interface=ether1
add address=192.168.55.18/30 interface=ether2
add address=10.255.1.1/32 interface=lo0
/mpls ldp
set enabled=yes lsr-id=10.255.1.1 transport-address=10.255.1.1
R2
ether1 connects to R1, ether2 connects to R3
/ip address
add address=192.168.55.2/30 interface=ether1
add address=192.168.55.5/30 interface=ether2
add address=10.255.1.2/32 interface=lo0
/mpls ldp
set enabled=yes lsr-id=10.255.1.2 transport-address=10.255.1.2
R3
ether1 connects to R2, ether2 connects to R4
/ip address
add address=192.168.55.6/30 interface=ether1
add address=192.168.55.9/30 interface=ether2
add address=10.255.1.3/32 interface=lo0
/mpls ldp
Manual:TE Tunnels Example 79
R4
ether1 connects to R3, ether2 connects to R5
/ip address
add address=192.168.55.10/30 interface=ether1
add address=192.168.55.13/30 interface=ether2
add address=10.255.1.4/32 interface=lo0
/mpls ldp
set enabled=yes lsr-id=10.255.1.4 transport-address=10.255.1.4
R5
ether1 connects to R4, ether2 connects to R1
/ip address
add address=192.168.55.14/30 interface=ether1
add address=192.168.55.17/30 interface=ether2
add address=10.255.1.5/32 interface=lo0
/mpls ldp
set enabled=yes lsr-id=10.255.1.5 transport-address=10.255.1.5
After OSPF and LDP setup ensure that ospf is working properly
0 expl-null
1 L 16 10.255.1.5/32 e 192.168.55.17
2 L 17 19 192.168.55.8/30 e 192.168.55.2
3 L 18 19 10.255.1.4/32 e 192.168.55.17
4 L 19 21 10.255.1.3/32 e 192.168.55.2
5 L 20 192.168.55.12/30 e 192.168.55.17
6 L 21 192.168.55.4/30 e 192.168.55.2
7 L 22 10.255.1.2/32 e 192.168.55.2
VPLS tunnel
ether4 goes to CE routers
R1
/interface vpls
add remote-peer=10.255.1.3 vpls-id=3:3
R3
/interface vpls
add remote-peer=10.255.1.1 vpls-id=3:3
TE Support
Traffic engineering needs RSVP protocol enabled on head end, tail end and forwarding routers. And additional setup
to use CSPF.
In our example all routers have the same configuration:
# set up CSPF
/routing ospf instance
set default mpls-te-area=backbone mpls-te-router-id=lo0
TE Tunnels
Manual:MPLS/Traffic-eng
Applies to RouterOS: v3, v4 +
Interface
Sub-menu: /mpls traffic-eng interface
Properties:
Property Description
bandwidth (integer[bps]; Default: 0bps) Total bandwidth that can be allocated on an interface by TE tunnels.
disabled (yes | no; Default: yes) Defines whether item is ignored or used. By default VPLS interface is disabled.
down-flood-thresholds
(integer[0..100],interer[0..100],...; Default:
15,30,45,60,75,80,85,90,95,97,98,99,100)
k-factor (integer; Default: 3) Value used to calculate RSVP timeout. Timeout is calculated using following formula:
(K + 0.5)*1.5*R, where K is k-factor, R is refresh-time. Read more >>
refresh-time (time; Default: 30s) Interval in which RSVP Path messages are sent out.
up-flood-thresholds (integer[0..100],interer[0..100],...;
Default: 15,30,45,60,75,80,85,90,95,97,98,99,100)
Manual:MPLS/Traffic-eng 83
use-udp (yes | no; Default: no) An RSVP implementation generally requires the ability to perform "raw" network I/O,
i.e., to send and receive IP datagrams using protocol 46. Some systems may not
support raw network I/O, in such cases RSVP messages can be encapsulated in UDP
datagrams. Ports 1698 and 1699 will be used.
Read-only properties:
Property Description
Tunnel Path
Sub-menu: /mpls traffic-eng tunnel-path
Properties:
Property Description
affinity-exclude (integer; Default: ) Do not use the path if resource-class matches any of specified bits.
affinity-include-all (integer; Default: ) Use the path only if resource-class matches all of specified bits.
affinity-include-any (integer; Default: ) Use the path if resource-class matches any of specified bits.
disabled (yes | no; Default: yes) Defines whether item is ignored or used. By default VPLS interface is disabled.
holding-priority (integer[0..7]; Default: ) Is used to decide whether this path can be preempted by another path. 0 sets the highest priority.
hops (Address:[strict|loose] [, List of hops that path traverses. Used if use-cspf is not enabled. It is possible to specify strict hop or
Address:[strinct|loose]]; Default: ) loose hop:
• strict - defines that there must not be any other hops between previous hop and "strict" hop (fully
specified path).
• loose - there are acceptable other hops between previous hop and defined hop (not fully specified
path).
Read more >>
record-route (yes | no; Default: ) If enabled, the sender node will receive information about the actual route that the LSP tunnel
traverses. Record Route is analogous to a path vector, and hence can be used for loop detection.
reoptimize-interval (time; Default: ) Interval in which tunnel path will be re-optimized. Useful if use-cspf is set to yes.
setup-priority (integer[0..7]; Default: ) Parameter is used to decide whether this path can preempt another path. 0 sets the highest priority.
use-cspf (yes | no; Default: yes) Whether to use CSPF to create dynamic tunnel path.
Monitoring TE Status
Path State
Sub-menu: /mpls traffic-eng path-state
Available read only properties:
Manual:MPLS/Traffic-eng 84
Property Description
label (integer)
out-label (integer)
out-next-hop (IP)
path-in-explicit-route ()
path-out-explicit-route ()
path-out-record-route () List of recorded routes along the path that is sent out to next hop.
resv-out-record-route ()
Resv State
Sub-menu: /mpls traffic-eng resv-state
Available read only properties:
Property Description
dst (address:ID) Shows TE destination address and tunnel ID from RSVP session.
label (integer)
next-hop ()
shared (yes | no) Whether LSP tunnels can share resources, so that the new LSP tunnel can be set up without having to wait for the old
LSP tunnel to be cleared. Read more >>
Manual:MPLS/Traffic-eng 85
src (address:ID) Shows TE source address and LSP ID from RSVP session.
Manual:TE Tunnels
Overview
For MPLS overview and RouterOS supported MPLS features see MPLS Overview.
MPLS RSVP TE tunnels are a way to establish unidirectional label switching paths. In general RSVP TE serves
similar purpose as label distribution using LDP protocol - establishing label switched path that ensures frame
delivery from ingress to egress router, but with additional features:
• possibility to establish label switching path using either full or partial explicit route;
• constraint based LSP establishment - label switching path is established over links that fulfill requirements, such
as bandwidth and link properties.
MPLS RSVP TE is based on RSVP protocol with extensions introduced by RFC 3209 that adds support for explicit
route and label exchange.
Note that constraints for path establishment are purely controlled by administrator - for example, bandwidth of link
participating in RSVP TE network is set by administrator and does not necessarily reflect real bandwidth of the link.
The same way bandwidth reserved for tunnel is set by administrator and does not automatically imply any limits on
traffic sent over tunnel. Therefore at any moment in time, bandwidth available on TE link is bandwidth configured
for link minus sum of all reservations made on link, not physically available bandwidth which can be either less (in
case data is forwarded over tunnels with rate that exceeds bandwidth reserved for tunnel or if non-RSVP tunnel data
is forwarded over link as well) or more (in case data is forwarded over tunnels with rate smaller than allocated for
tunnel) than bandwidth available for reservations.
RSVP TE tunnels are initiated by head-end (ingress router) of tunnel. Head-end router sends RSVP Path message
containing necessary parameters towards tail-end of the tunnel. Routers along the path ensure that they can forward
Path message towards next hop, taking into acount path constraints. Once Path message reaches tail-end of the
tunnel, tail-end router sends RSVP Resv message in the opposite direction. Resv message hop by hop traverses
exactly the same path that Path message, only in the opposite direction. Each router forwarding Resv message
allocates necessary bandwith on appropriate downstream link if possible. Once head-end router succesfully receives
Resv message that matches sent Path message, tunnel can be considered established. Tunnel is maintained by
periodically refreshing its state using Path and Resv messages.
RSVP TE tunnels can be established with number of path options:
• along path that data from head-end of tunnel is routed to tail-end - in this case each router along tunnel path
figures out next hop of tunnel based on routing table. If at some point usable route is not found or downstream
interface does not meet constraints (for example if requested bandwidth exceeds available bandwidth), tunnel can
not be established.
• along statically configured explicit path - in this case each router along tunnel path figures out next hop of tunnel
based on explicit route specified in Path message. This explicit route can be either complete (specifies all routers
along the path in the order they must be traversed) or partial (specifies only some routers that must be traversed).
To decide next hop router, each router along the path look up route to next router specified in explicit route. If no
usable route is found or downstream interface does not meet constraints, tunnel can not be established
• Constrained Shortest Path First - in this case head-end router calculates path to tail-end using its knowledge of
network state - properties of links and available bandwidth. This option needs assistance from IGP routing
protocol (such as OSPF) to distribute bandwidth information throughout the network. This is implemented in
Manual:TE Tunnels 86
OSPF by means of opaque LSAs. When using CSPF, head-end router calculates path that satisfies the
requirements and produces explicit path for Path message. If path that matches constraints can not be calculated,
tunnel can not be established. Dynamically calculated path can also be partially explicit - in this case CSPF seeks
for shortest path matching constraints between every two explicit hops. If explicit path is specified completely
and CSPF is used, CSPF just checks if this path meets the constraints taking into account knowledge about link
states in network - so instead of failure to establish tunnel while forwarding Path message in network, Path
message is not even sent as it is clear that establishing tunnel will fail.
Example network
Consider the same network as used for LDP signaled VPLS example in MPLSVPLS:
Customer A wants to establish IP VPN between his 3 sites and Customer B wants to transparent connection for
ethernet segments at his sites.
Enabling TE support
In order for OSPF to distribute TE information, TE related OSPF parameters must be set:
This instructs OSPF to distribute TE information in "backbone" area using IP address of "lobridge" as router ID.
In order for router to be able to participate in TE tunnel (either as head-end, tail-end or forwarding router), TE
support must be enabled. TE support must be enabled on all interfaces that will receive and send RSVP TE protocol
packets. On R1 it is done by commands (interface ether3 is facing network 1.1.1.0/24):
This configures ether3 interface with TE support, having bandwidth 100000 Bps. Other routers are configured in
similar way.
As soon as TE support is enabled on interface, appropriate opaque LSAs are distributed into OSPF area. For
example, on R1 it can be seen, that there is total 15 opaque LSAs in LSA database:
[admin@R1] > /routing ospf lsa print
...
backbone opaque-area 1.0.0.0 1.1.1.2 0x80000004 1038
backbone opaque-area 1.0.0.0 2.2.2.3 0x80000004 1039
backbone opaque-area 1.0.0.0 3.3.3.4 0x80000004 1038
backbone opaque-area 1.0.0.0 4.4.4.5 0x80000004 1038
backbone opaque-area 1.0.0.0 11.11.11.1 0x80000004 1037
backbone opaque-area 1.0.0.1 1.1.1.2 0x80000004 1038
backbone opaque-area 1.0.0.1 2.2.2.3 0x80000004 1039
backbone opaque-area 1.0.0.1 3.3.3.4 0x80000004 1037
backbone opaque-area 1.0.0.1 4.4.4.5 0x80000004 1038
backbone opaque-area 1.0.0.2 1.1.1.2 0x80000004 1038
backbone opaque-area 1.0.0.2 2.2.2.3 0x80000004 1039
backbone opaque-area 1.0.0.2 3.3.3.4 0x80000004 1037
backbone opaque-area 1.0.0.2 4.4.4.5 0x80000004 1038
backbone opaque-area 1.0.0.3 2.2.2.3 0x80000004 1039
backbone opaque-area 1.0.0.3 11.11.11.1 0x80000004 1037
...
This creates path template for purely dynamic path that will use CSPF.
Next, TE tunnel itself must be created:
Notice, that CSPF has created explicit route that traverses R2, R3 and R5 (tail-end). TE tunnel was requested to
record route it is traversing (by "record-route=yes" setting), recorded route is displayed in status along with labels
that particular router has allocated for this tunnel.
Once TE tunnel is established, VPLS interface from R1 to R5 automatically switches to use this TE tunnel:
On routers in between R1 and R5, RSVP path and reservation state can be monitored, for example on R2:
[admin@R2] > /mpls traffic-eng path-state print
Flags: L - locally-originated, E - egress, F - forwarding, P - sending-path, R - sending-resv
# SRC DST BANDWIDTH OUT-INTERFACE OUT-NEXT-HOP
0 FPR 9.9.9.1:1 9.9.9.5:2 1000 ether2 2.2.2.3
[admin@R2] > /mpls traffic-eng resv-state print
Flags: E - egress, A - active, N - non-output, S - shared
# SRC DST BANDWIDTH LABEL INTERFACE NEXT-HOP
0 AS 9.9.9.1:1 9.9.9.5:7 1000 30 ether2 2.2.2.3
Note, that available bandwidth on ether2 interface (connected to R3) on R2 has changed:
Bandwidth limitation
TE tunnel can be configured to limit the rate at which traffic is allowed to enter the tunnel. Limit is specified on
ingress router in percent of tunnel bandwidth. E.g. creating the following tunnel:
means that tunnel will reserve bandwidth of 100 kilobits per second across MPLS backbone from 9.9.9.1 to 9.9.9.5
and that ingress router will limit the rate of traffic entering the tunnel to 120 kilobits per second (120% of 100
kilobits per second bandwidth). This can be confirmed by monitoring tunnel interface:
Note that by default any limiting is disabled. By specifying limit as percentage of tunnel bandwidth, TE tunnel
bandwith limits can be configured in rather flexible ways - some tunnels can be configured to hard limit while others
can be configured with reasonable reserve, achieving different classes of service.
Manual:TE tunnel auto bandwidth 91
means that tunnel will measure average rate over 10 second periods and once per minute will update bandwidth in
range from 10 to 500 kilobits per second. Tunnel bandwidth setting specifies the initial bandwidth of tunnel. The
above tunnel in complete absence of data over it after 1 minute will change its bandwidth to specified minimum 10
kbps:
Additionally, tunnel can be configured to reserve more bandwidth than measured. This can be achieved with
auto-bandwidth-reserve setting which specifies percentage of additional bandwidth to reserve - so setting
auto-bandwith-reserve to 10 means that tunnel will reserve 10% more bandwidth than measured (but will still obey
the auto-bandwidth-range). For example changing above tunnel and running constant stream of 50kbps through it
will yield the following results:
active-label: 27
reserved-bandwidth: 100.0kbps
rate-limit: 120.0kbps
rate-measured-last: 48.8kbps
rate-measured-highest: 48.8kbps
After update period and after previous reservations are torn down notice how reserved bandwidth exceeds average
rate by 30%. Also notice that rate-limit correctly changes to 120% of reserved-bandwidth:
Note that in case reservation must be updated to lower value, brief period after update period reserved-bandwidth
will still display previous reservation value. The reason for this is that new reservation is made without disrupting the
previous tunnel and therefore shares its reservation until old reservation is torn down. rate-limit on turn is correctly
updated to intended value. In the above example, after stopping the 50kbps stream and after update period will pass
with tunnel being idle, for a brief period after update tunnel info can be:
After previous reservation (63.4kbps) is torn down, reserved-bandwidth correctly changes to 10kbps:
active-label: 34
reserved-bandwidth: 10.0kbps
rate-limit: 12.0kbps
rate-measured-last: 0bps
rate-measured-highest: 0bps
Note that auto-bandwidth-reserve is applied to actual measured bandwidth, before range checking according to
auto-bandwidth-range - therefore 10kbps gets reserved, instead of 13kbps.
Manual:Connection tracking
There are several ways to see what connections are making their way though the router.
In the Winbox Firewall window, you can switch to the Connections tab, to see current connections to/from/through
your router. It looks like this:
You can also Turn on and off the connection tracking altogether, in the Tracking menu, accessible with a button of
the same name in this window. Note that turning off the connection tracking will make NAT and most of the
Manual:Connection tracking 94
R1 is ISP router sending BGP routes R2 is client's main gateway and clients local network is 192.168.1.0/24
After setting up bgp peering (which is not covered in this article) we get following BGP routes
Next step is to add all received BGP rotues to another routing table, to do that we set up routing filters
As you can see now routes are added to "local" routing table
...
Following mangle rule will match all packets that destination is resolved in "local" routing table.
Now when we try to send packets from the client for example to address 10.10.10.4, mangle rule will not match
anything. This is because by default every destination is resolved in "main" routing table.
To fix this we have to explicitly specify to resolve all packets coming from client in "local" routing table.
As you can see from the logs only packets coming from the client are matched. The reason for this is because
routing-table matcher is matching only packet which destination address is resolved in local routing table. In our
example 192.168.1.10 as destination is resolved in "main" routing table.
From what was said above, this approach is useful only for upload traffic marking and shaping.
Manual:IP/Firewall/L7
Applies to RouterOS: v3, v4 +
Summary
layer7-protocol is a method of searching for patterns in ICMP/TCP/UDP streams.
L7 matcher is collecting first 10 packets of connection or first 2KB of connection and searches for pattern in
collected data. If pattern is not found in collected data, matcher is not inspecting further. Allocated memory is freed
and protocol is considered as unknown. You should take into account that a lot of connections will significantly
increase memory usage. To avoid it add regular firewall matchers to reduce amount of data passed to layer-7 filters.
Additional requirement is that layer7 matcher must see both directions of traffic (incoming and outgoing). To satisfy
this requirement l7 rules should be set in forward chain. If rule is set in input/prerouting chain then the same rule
must be set also in output/postrouting chain, otherwise collected data may not be complete resulting in incorrectly
matched pattern.
L7 patterns found in l7-filter project page [1] and in [2] are compatible with RouterOS.
You can also download a script with a list of common protocols here [3] (only for RouterOS v3), just run Import
command with this file.
Properties
Sub-menu: /ip firewall layer7-protocol
Manual:IP/Firewall/L7 97
Property Description
name (string; Default: ) Descriptive name of l7 pattern used by configuration in firewall rules. See example >>.
regexp (string; Default: ) POSIX compliant regular expression used to match pattern.
Examples
# add l7 matcher
add action=accept chain=forward comment="" disabled=no layer7-protocol=\
bittorrent protocol=tcp
As you can see before l7 rule we added several regular rules that will match known traffic thus reducing memory
usage.
L7 in input chain
In this example we will try to match telnet protocol connecting to our router.
Note that we need both directions that is why we need also l7 rule in output chain that sees outgoing packets.
[Back to Content]
Manual:IP/Firewall/L7 98
References
[1] http:/ / l7-filter. sourceforge. net/ protocols
[2] http:/ / protocolinfo. org/ wiki/ Main_Page
[3] http:/ / www. mikrotik. com/ download/ l7-protos. rsc
Manual:IP/Firewall/NAT
Applies to RouterOS: v3, v4 +
Summary
Sub-menu: /ip firewall nat
Network Address Translation is an Internet standard that allows hosts on local area networks to use one set of IP
addresses for internal communications and another set of IP addresses for external communications. A LAN that
uses NAT is referred as natted network. For NAT to function, there should be a NAT gateway in each natted
network. The NAT gateway (NAT router) performs IP address rewriting on the way a packet travel from/to LAN.
There are two types of NAT:
• source NAT or srcnat. This type of NAT is performed on packets that are originated from a natted network. A
NAT router replaces the private source address of an IP packet with a new public IP address as it travels through
the router. A reverse operation is applied to the reply packets travelling in the other direction.
• destination NAT or dstnat. This type of NAT is performed on packets that are destined to the natted network. It
is most comonly used to make hosts on a private network to be acceesible from the Internet. A NAT router
performing dstnat replaces the destination IP address of an IP packet as it travel through the router towards a
private network.
Hosts behind a NAT-enabled router do not have true end-to-end connectivity. Therefore some Internet protocols
might not work in scenarios with NAT. Services that require the initiation of TCP connection from outside the
private network or stateless protocols such as UDP, can be disrupted. Moreover, some protocols are inherently
incompatible with NAT, a bold example is AH protocol from the IPsec suite.
To overcome these limitations RouterOS includes a number of so-called NAT helpers, that enable NAT traversal for
various protocols.
Properties
Manual:IP/Firewall/NAT 99
Property Description
action (action name; Default: accept) Action to take if packet is matched by the rule:
• accept - accept the packet. Packet is not passed to next NAT rule.
• add-dst-to-address-list - add destination address to Address list
specified by address-list parameter
• add-src-to-address-list - add source address to Address list specified by
address-list parameter
• dst-nat - replaces destination address and/or port of an IP packet to
values specified by to-addresses and to-ports parameters
• jump - jump to the user defined chain specified by the value of
jump-target parameter
• log - add a message to the system log containing following data:
in-interface, out-interface, src-mac, protocol, src-ip:port->dst-ip:port
and length of the packet. After packet is matched it is passed to next
rule in the list, similar as passthrough
• masquerade - replace source address of an IP packet to IP determined
by routing facility.
• netmap - creates a static 1:1 mapping of one set of IP addresses to
another one. Often used to distribute public IP addresses to hosts on
private networks
• passthrough - ignore this rule and go to next one (useful for statistics).
• redirect - replaces destination port of an IP packet to one specified by
to-ports parameter
• return - passes control back to the chain from where the jump took
place
• same - gives a particular client the same source/destination IP address
from supplied range for each connection. This is most frequently used
for services that expect the same client address for multiple
connections from the same client
• src-nat - replaces source address of an IP packet to values specified by
to-addresses and to-ports parameters
address-list (string; Default: ) Name of the address list to be used. Applicable if action is
add-dst-to-address-list or add-src-to-address-list
address-list-timeout (time; Default: 00:00:00) Time interval after which the address will be removed from the address list
specified by address-list parameter. Used in conjunction with
add-dst-to-address-list or add-src-to-address-list actions
Value of 00:00:00 will leave the address in the address list forever
chain (name; Default: ) Specifies to which chain rule will be added. If the input does not match the
name of an already defined chain, a new chain will be created.
connection-bytes (integer-integer; Default: ) Matches packets only if a given amount of bytes has been transfered
through the particular connection. 0 - means infinity, for example
connection-bytes=2000000-0 means that the rule matches if more than
2MB has been transfered through the relevant connection
connection-limit (integer,netmaks; Default: ) Restrict connection limit per address or address block/td>
connection-mark (no-mark | string; Default: ) Matches packets marked via mangle facility with particular connection
mark. If no-mark is set, rule will match any unmarked connection.
connection-rate (Integer 0..4294967295; Default: ) Connection Rate is a firewall matcher that allow to capture traffic based on
present speed of the connection. Read more>>
Manual:IP/Firewall/NAT 100
connection-state (estabilished | invalid | new | related; Default: ) Interprets the connection tracking analysis data for a particular packet:
• established - a packet which belongs to an existing connection
• invalid - a packet which could not be identified for some reason
• new - a packet which begins a new connection
• related - a packet which is related to, but not part of an existing
connection, such as ICMP errors or a packet which begins FTP data
connection
connection-type (ftp | h323 | irc | pptp | quake3 | sip | tftp; Default: ) Matches packets from related connections based on information from their
connection tracking helpers. A relevant connection helper must be enabled
under /ip firewall service-port
dst-address (IP/netmask | IP range; Default: ) Matches packets which destination is equal to specified IP or falls into
specified IP range.
dst-address-list (name; Default: ) Matches destination address of a packet against user-defined address list
dst-address-type (unicast | local | broadcast | multicast; Default: ) Matches destination address type:
• unicast - IP address used for point to point transmission
• local - if dst-address is assigned to one of router's interfaces
• broadcast - packet is sent to all devices in subnet
• multicast - packet is forwarded to defined group of devices
dst-limit (integer,time,integer,dst-address | dst-port | src-address, Matches packets if given pps limit is exceeded. As opposed to the limit
time; Default: ) matcher, every destination IP address / destination port has it's own limit.
Parameters are written in following format: count,time,burst,mode,expire.
• count - maximum average packet rate measured in packets per time
interval
• time - specifies the time interval in which the packet rate is measured
• burst - number of packets which are not counted by packet rate
• mode - the classifier for packet rate limiting
• expire - specifies interval after which recored ip address /port will be
deleted
dst-port (integer[-integer]: 0..65535; Default: ) List of destination port numbers or port number ranges
fragment (yes|no; Default: ) Matches fragmented packets. First (starting) fragment does not count. If
connection tracking is enabled there will be no fragments as system
automatically assembles every packet
in-bridge-port (name; Default: ) Actual interface the packet has entered the router, if incoming interface is
bridge
in-interface (name; Default: ) Interface the packet has entered the router
ingress-priority (integer: 0..63; Default: ) Matches ingress priority of the packet. Priority may be derived from
VLAN, WMM or MPLS EXP bit. Read more>>
Manual:IP/Firewall/NAT 101
jump-target (name; Default: ) Name of the target chain to jump to. Applicable only if action=jump
layer7-protocol (name; Default: ) Layer7 filter name defined in layer7 protocol menu.
limit (integer,time,integer; Default: ) Matches packets if given pps limit is exceeded. Parameters are written in
following format: count,time,burst.
• count - maximum average packet rate measured in packets per time
interval
• time - specifies the time interval in which the packet rate is measured
• burst - number of packets which are not counted by packet rate
log-prefix (string; Default: ) Adds specified text at the beginning of every log message. Applicable if
action=log
nth (integer,integer; Default: ) Matches every nth packet. Read more >>
out-bridge-port (name; Default: ) Actual interface the packet is leaving the router, if outgoing interface is
bridge
packet-mark (no-mark | string; Default: ) Matches packets marked via mangle facility with particular packet mark. If
no-mark is set, rule will match any unmarked packet.
packet-size (integer[-integer]:0..65535; Default: ) Matches packets of specified size or size range in bytes.
per-connection-classifier (ValuesToHash:Denominator/Remainder; PCC matcher allows to divide traffic into equal streams with ability to
Default: ) keep packets with specific set of options in one particular stream. Read
more >>
port (integer[-integer]: 0..65535; Default: ) Matches if any (source or destination) port matches the specified list of
ports or port ranges. Applicable only if protocol is TCP or UDP
protocol (name or protocol ID; Default: tcp) Matches particular IP protocol specified by protocol name or number
psd (integer,time,integer,integer; Default: ) Attempts to detect TCP and UDP scans. Parameters are in following
format WeightThreshold, DelayThreshold, LopPortWeight,
HighPortWeight
• WeightThreshold - total weight of the latest TCP/UDP packets with
different destination ports coming from the same host to be treated as
port scan sequence
• DelayThreshold - delay for the packets with different destination ports
coming from the same host to be treated as possible port scan
subsequence
• LowPortWeight - weight of the packets with privileged (<=1024)
destination port
• HighPortWeight - weight of the packet with non-priviliged
destination port
Manual:IP/Firewall/NAT 102
random (integer: 1..99; Default: ) Matches packets randomly with given probability.
routing-mark (string; Default: ) Matches packets marked by mangle facility with particular routing mark
same-not-by-dst (yes | no; Default: ) Specifies whether to take into account or not destination IP address when
selecting a new source IP address. Applicable if action=same
src-address (Ip/Netmaks, Ip range; Default: ) Matches packets which source is equal to specified IP or falls into
specified IP range.
src-address-list (name; Default: ) Matches source address of a packet against user-defined address list
src-address-type (unicast | local | broadcast | multicast; Default: ) Matches source address type:
• unicast - IP address used for point to point transmission
• local - if address is assigned to one of router's interfaces
• broadcast - packet is sent to all devices in subnet
• multicast - packet is forwarded to defined group of devices
src-port (integer[-integer]: 0..65535; Default: ) List of source ports and ranges of source ports. Applicable only if protocol
is TCP or UDP.
src-mac-address (MAC address; Default: ) Matches source MAC address of the packet
tcp-flags (ack | cwr | ece | fin | psh | rst | syn | urg; Default: ) Matches specified TCP flags
• ack - acknowledging data
• cwr - congestion window reduced
• ece - ECN-echo flag (explicit congestion notification)
• fin - close connection
• psh - push function
• rst - drop connection
• syn - new connection
• urg - urgent data
time (time-time,sat | fri | thu | wed | tue | mon | sun; Default: ) Allows to create filter based on the packets' arrival time and date or, for
locally generated packets, departure time and date
to-addresses (IP address[-IP address]; Default: 0.0.0.0) Replace original address with specified one. Applicable if action is dst-nat,
netmap, same, src-nat
to-ports (integer[-integer]: 0..255; Default: ) Replace original port with specified one. Applicable if action is dst-nat,
redirect, netmap, same, src-nat
/ip firewall nat print stats will show additional read-only properties
Property Description
By default print is equivalent to print static and shows only static rules.
Property Description
Basic examples
If you want to "hide" the private LAN 192.168.0.0/24 "behind" one address 10.5.8.109 given to you by the ISP, you
should use the source network address translation (masquerading) feature of the MikroTik router. The masquerading
will change the source IP address and port of the packets originated from the network 192.168.0.0/24 to the address
10.5.8.109 of the router when the packet is routed through it.
To use masquerading, a source NAT rule with action 'masquerade' should be added to the firewall configuration:
All outgoing connections from the network 192.168.0.0/24 will have source address 10.5.8.109 of the router and
source port above 1024. No access from the Internet will be possible to the Local addresses. If you want to allow
connections to the server on the local network, you should use destination Network Address Translation (NAT).
If you want to link Public IP 10.5.8.200 address to Local one 192.168.0.109, you should use destination address
translation feature of the MikroTik router. Also if you want allow Local server to talk with outside with given Public
IP you should use source address translation, too.
Add Public IP to Public interface:
Add rule allowing access to the internal server from external networks:
Add rule allowing the internal server to talk to the outer networks having its source address translated to 10.5.8.200:
Manual:IP/Firewall/NAT 104
If you want to link Public IP subnet 11.11.11.0/24 to local one 2.2.2.0/24, you should use destination address
translation and source address translation features with action=netmap.
If you would like to direct requests for a certain port to an internal machine (sometimes called opening a port, port
mapping), you can do it like this:
/ip firewall nat add chain=dstnat dst-port=1234 action=dst-nat protocol=tcp to-address=192.168.1.1 to-port=1234
This rule translates to: when an incoming connection requests TCP port 1234, use the DST-NAT action and redirect
it to local address 192.168.1.1 and the port 1234
[Back to Content]
Manual:IP/Firewall/Mangle
Applies to RouterOS: v3, v4
Summary
Sub-menu: /ip firewall mangle
Mangle is a kind of 'marker' that marks packets for future processing with special marks. Many other facilities in
RouterOS make use of these marks, e.g. queue trees, NAT, routing. They identify a packet based on its mark and
process it accordingly. The mangle marks exist only within the router, they are not transmitted across the network.
Additionally, the mangle facility is used to modify some fields in the IP header, like TOS (DSCP) and TTL fields.
Properties
Manual:IP/Firewall/Mangle 105
Property Description
action (action name; Default: accept) Action to take if packet is matched by the rule:
• accept - accept the packet. Packet is not passed to next firewall rule.
• add-dst-to-address-list - add destination address to Address list
specified by address-list parameter
• add-src-to-address-list - add source address to Address list specified by
address-list parameter
• change-dscp - change Differentiated Services Code Point (DSCP) field
value specified by the new-dscp parameter
• change-mss - change Maximum Segment Size field value of the packet
to a value specified by the new-mss parameter
• change-ttl - change Time to Live field value of the packet to a value
specified by the new-ttl parameter
• jump - jump to the user defined chain specified by the value of
jump-target parameter
• log - add a message to the system log containing following data:
in-interface, out-interface, src-mac, protocol, src-ip:port->dst-ip:port
and length of the packet. After packet is matched it is passed to next
rule in the list, similar as passthrough
• mark-connection - place a mark specified by the new-connection-mark
parameter on the entire connection that matches the rule
• mark-packet - place a mark specified by the new-packet-mark
parameter on a packet that matches the rule
• mark-routing - place a mark specified by the new-routing-mark
parameter on a packet. This kind of marks is used for policy routing
purposes only
• passthrough - ignore this rule and go to next one (useful for statistics).
• return - pass control back to the chain from where the jump took place
• set-priority - set priority speciefied by the new-priority parameter on
the packets sent out through a link that is capable of transporting
priority (VLAN or WMM-enabled wireless interface). Read more>
• strip-ipv4-options - strip IPv4 option fields from IP header.
address-list (string; Default: ) Name of the address list to be used. Applicable if action is
add-dst-to-address-list or add-src-to-address-list
address-list-timeout (time; Default: 00:00:00) Time interval after which the address will be removed from the address list
specified by address-list parameter. Used in conjunction with
add-dst-to-address-list or add-src-to-address-list actions
Value of 00:00:00 will leave the address in the address list forever
chain (name; Default: ) Specifies to which chain rule will be added. If the input does not match the
name of an already defined chain, a new chain will be created.
connection-bytes (integer-integer; Default: ) Matches packets only if a given amount of bytes has been transfered
through the particular connection. 0 - means infinity, for example
connection-bytes=2000000-0 means that the rule matches if more than
2MB has been transfered through the relevant connection
connection-limit (integer,netmaks; Default: ) Restrict connection limit per address or address block/td>
connection-mark (no-mark | string; Default: ) Matches packets marked via mangle facility with particular connection
mark. If no-mark is set, rule will match any unmarked connection.
connection-rate (Integer 0..4294967295; Default: ) Connection Rate is a firewall matcher that allow to capture traffic based on
present speed of the connection. Read more >>
Manual:IP/Firewall/Mangle 106
connection-state (estabilished | invalid | new | related; Default: ) Interprets the connection tracking analysis data for a particular packet:
• established - a packet which belongs to an existing connection
• invalid - a packet which could not be identified for some reason
• new - a packet which begins a new connection
• related - a packet which is related to, but not part of an existing
connection, such as ICMP errors or a packet which begins FTP data
connection
connection-type (ftp | h323 | irc | pptp | quake3 | sip | tftp; Default: ) Matches packets from related connections based on information from their
connection tracking helpers. A relevant connection helper must be enabled
under /ip firewall service-port
dst-address (IP/netmask | IP range; Default: ) Matches packets which destination is equal to specified IP or falls into
specified IP range.
dst-address-list (name; Default: ) Matches destination address of a packet against user-defined address list
dst-address-type (unicast | local | broadcast | multicast; Default: ) Matches destination address type:
• unicast - IP address used for point to point transmission
• local - if dst-address is assigned to one of router's interfaces
• broadcast - packet is sent to all devices in subnet
• multicast - packet is forwarded to defined group of devices
dst-limit (integer,time,integer,dst-address | dst-port | src-address, Matches packets if given pps limit is exceeded. As opposed to the limit
time; Default: ) matcher, every destination IP address / destination port has it's own limit.
Parameters are written in following format: count,time,burst,mode,expire.
• count - maximum average packet rate measured in packets per time
interval
• time - specifies the time interval in which the packet rate is measured
• burst - number of packets which are not counted by packet rate
• mode - the classifier for packet rate limiting
• expire - specifies interval after which recored ip address /port will be
deleted
dst-port (integer[-integer]: 0..65535; Default: ) List of destination port numbers or port number ranges
fragment (yes|no; Default: ) Matches fragmented packets. First (starting) fragment does not count. If
connection tracking is enabled there will be no fragments as system
automatically assembles every packet
in-bridge-port (name; Default: ) Actual interface the packet has entered the router, if incoming interface is
bridge
in-interface (name; Default: ) Interface the packet has entered the router
ingress-priority (integer: 0..63; Default: ) Matches ingress priority of the packet. Priority may be derived from
VLAN, WMM or MPLS EXP bit. Read more >>
Manual:IP/Firewall/Mangle 107
jump-target (name; Default: ) Name of the target chain to jump to. Applicable only if action=jump
layer7-protocol (name; Default: ) Layer7 filter name defined in layer7 protocol menu.
limit (integer,time,integer; Default: ) Matches packets if given pps limit is exceeded. Parameters are written in
following format: count,time,burst.
• count - maximum average packet rate measured in packets per time
interval
• time - specifies the time interval in which the packet rate is measured
• burst - number of packets which are not counted by packet rate
log-prefix (string; Default: ) Adds specified text at the beginning of every log message. Applicable if
action=log
nth (integer,integer; Default: ) Matches every nth packet. Read more >>
out-bridge-port (name; Default: ) Actual interface the packet is leaving the router, if outgoing interface is
bridge
p2p (all-p2p | bit-torrent | blubster | direct-connect | edonkey | Matches packets from various peer-to-peer (P2P) protocols. Does not work
fasttrack | gnutella | soulseek | warez | winmx; Default: ) on encrypted p2p packets.
packet-mark (no-mark | string; Default: ) Matches packets marked via mangle facility with particular packet mark. If
no-mark is set, rule will match any unmarked packet.
packet-size (integer[-integer]:0..65535; Default: ) Matches packets of specified size or size range in bytes.
per-connection-classifier (ValuesToHash:Denominator/Remainder; PCC matcher allows to divide traffic into equal streams with ability to
Default: ) keep packets with specific set of options in one particular stream. Read
more >>
port (integer[-integer]: 0..65535; Default: ) Matches if any (source or destination) port matches the specified list of
ports or port ranges. Applicable only if protocol is TCP or UDP
protocol (name or protocol ID; Default: tcp) Matches particular IP protocol specified by protocol name or number
Manual:IP/Firewall/Mangle 108
psd (integer,time,integer,integer; Default: ) Attempts to detect TCP and UDP scans. Parameters are in following
format WeightThreshold, DelayThreshold, LopPortWeight,
HighPortWeight
• WeightThreshold - total weight of the latest TCP/UDP packets with
different destination ports coming from the same host to be treated as
port scan sequence
• DelayThreshold - delay for the packets with different destination ports
coming from the same host to be treated as possible port scan
subsequence
• LowPortWeight - weight of the packets with privileged (<=1024)
destination port
• HighPortWeight - weight of the packet with non-priviliged
destination port
random (integer: 1..99; Default: ) Matches packets randomly with given probability.
routing-mark (string; Default: ) Matches packets marked by mangle facility with particular routing mark
src-address (Ip/Netmaks, Ip range; Default: ) Matches packets which source is equal to specified IP or falls into
specified IP range.
src-address-list (name; Default: ) Matches source address of a packet against user-defined address list
src-address-type (unicast | local | broadcast | multicast; Default: ) Matches source address type:
• unicast - IP address used for point to point transmission
• local - if address is assigned to one of router's interfaces
• broadcast - packet is sent to all devices in subnet
• multicast - packet is forwarded to defined group of devices
src-port (integer[-integer]: 0..65535; Default: ) List of source ports and ranges of source ports. Applicable only if protocol
is TCP or UDP.
src-mac-address (MAC address; Default: ) Matches source MAC address of the packet
tcp-flags (ack | cwr | ece | fin | psh | rst | syn | urg; Default: ) Matches specified TCP flags
• ack - acknowledging data
• cwr - congestion window reduced
• ece - ECN-echo flag (explicit congestion notification)
• fin - close connection
• psh - push function
• rst - drop connection
• syn - new connection
• urg - urgent data
time (time-time,sat | fri | thu | wed | tue | mon | sun; Default: ) Allows to create filter based on the packets' arrival time and date or, for
locally generated packets, departure time and date
ttl (equal | greater-than | less-than | not-equal : integer(0..255); Matches packets TTL value.
Default: )
Stats
/ip firewall filter print stats will show additional read-only properties
Manual:IP/Firewall/Mangle 109
Property Description
By default print is equivalent to print static and shows only static rules.
Basic examples
It is a well known fact that VPN links have smaller packet size due to incapsulation overhead. A large packet with
MSS that exceeds the MSS of the VPN link should be fragmented prior to sending it via that kind of connection.
However, if the packet has DF flag set, it cannot be fragmented and should be discarded. On links that have broken
path MTU discovery (PMTUD) it may lead to a number of problems, including problems with FTP and HTTP data
transfer and e-mail services.
Manual:IP/Firewall/Mangle 110
In case of link with broken PMTUD, a decrease of the MSS of the packets coming through the VPN link solves the
problem. The following example demonstrates how to decrease the MSS value via mangle:
/ip firewall mangle
add out-interface=pppoe-out protocol=tcp tcp-flags=syn action=change-mss new-mss=1300 chain=forward
Marking each packet is quite resource expensive especially if rule has to match against many parameters from IP
header or address list containing hundreds of entries.
Lets say we want to
• mark all tcp packets except tcp/80 and match these packets against first address list
• mark all udp packets and match them against second address list.
/ip firewall mangle
Setup looks quite simple and probably will work without problems in small networks. Now multiply count of rules
by 10, add few hundred entries in address list, run 100Mbit of traffic over this router and you will see how rapidly
CPU usage is increasing. The reason for such behavior is that each rule reads IP header of every packet and tries to
match collected data against parameters specified in firewall rule.
Fortunately if connection tracking is enabled, we can use connection marks to optimize our setup.
/ip firewall mangle
new-connection-mark=first
new-connection-mark=second
Now first rule will try to match data from IP header only from first packet of new connection and add connection
mark. Next rule will no longer check IP header for each packet, it will just compare connection marks resulting in
lower CPU consumption. Additionally passthrough=no was added that helps to reduce CPU consumption even more.
[Back to Content]
Manual:IP/Firewall/Filter 111
Manual:IP/Firewall/Filter
Applies to RouterOS: v3, v4
Summary
Sub-menu: /ip firewall filter
The firewall implements packet filtering and thereby provides security functions that are used to manage data flow
to, from and through the router. Along with the Network Address Translation it serves as a tool for preventing
unauthorized access to directly attached networks and the router itself as well as a filter for outgoing traffic.
Network firewalls keep outside threats away from sensitive data available inside the network. Whenever different
networks are joined together, there is always a threat that someone from outside of your network will break into your
LAN. Such break-ins may result in private data being stolen and distributed, valuable data being altered or
destroyed, or entire hard drives being erased. Firewalls are used as a means of preventing or minimizing the security
risks inherent in connecting to other networks. Properly configured firewall plays a key role in efficient and secure
network infrastrure deployment.
MikroTik RouterOS has very powerful firewall implementation with features including:
• stateful packet inspection
• Layer-7 protocol detection
• peer-to-peer protocols filtering
• traffic classification by:
• source MAC address
• IP addresses (network or list) and address types (broadcast, local, multicast, unicast)
• port or port range
• IP protocols
• protocol options (ICMP type and code fields, TCP flags, IP options and MSS)
• interface the packet arrived from or left through
• internal flow and connection marks
• DSCP byte
• packet content
• rate at which packets arrive and sequence numbers
• packet size
• packet arrival time
• and much more!
Manual:IP/Firewall/Filter 112
Chains
The firewall operates by means of firewall rules. Each rule consists of two parts - the matcher which matches traffic
flow against given conditions and the action which defines what to do with the matched packet.
Firewall filtering rules are grouped together in chains. It allows a packet to be matched against one common criterion
in one chain, and then passed over for processing against some other common criteria to another chain. For example
a packet should be matched against the IP address:port pair. Of course, it could be achieved by adding as many rules
with IP address:port match as required to the forward chain, but a better way could be to add one rule that matches
traffic from a particular IP address, e.g.: /ip firewall filter add src-address=1.1.1.2/32 jump-target="mychain" and in
case of successfull match passes control over the IP packet to some other chain, id est mychain in this example. Then
rules that perform matching against separate ports can be added to mychain chain without specifying the IP
addresses.
There are three predefined chains, which cannot be deleted:
• input - used to process packets entering the router through one of the interfaces with the destination IP address
which is one of the router's addresses. Packets passing through the router are not processed against the rules of the
input chain
• forward - used to process packets passing through the router
• output - used to process packets originated from the router and leaving it through one of the interfaces. Packets
passing through the router are not processed against the rules of the output chain
Packet flow diagrams illustrate how packets are processed in RouterOS.
When processing a chain, rules are taken from the chain in the order they are listed there from top to bottom. If a
packet matches the criteria of the rule, then the specified action is performed on it, and no more rules are processed
in that chain (the exception is the passthrough action). If a packet has not matched any rule within the chain, then it
is accepted.
Properties
Property Description
action (action name; Default: accept) Action to take if packet is matched by the rule:
• accept - accept the packet. Packet is not passed to next firewall rule.
• add-dst-to-address-list - add destination address to address list
specified by address-list parameter
• add-src-to-address-list - add source address to address list specified by
address-list parameter
• drop - silently drop the packet
• jump - jump to the user defined chain specified by the value of
jump-target parameter
• log - add a message to the system log containing following data:
in-interface, out-interface, src-mac, protocol, src-ip:port->dst-ip:port
and length of the packet. After packet is matched it is passed to next
rule in the list, similar as passthrough
• passthrough - ignore this rule and go to next one (useful for statistics).
• reject - drop the packet and send an ICMP reject message
• return - passes control back to the chain from where the jump took
place
• tarpit - captures and holds TCP connections (replies with SYN/ACK to
the inbound TCP SYN packet)
address-list (string; Default: ) Name of the address list to be used. Applicable if action is
add-dst-to-address-list or add-src-to-address-list
Manual:IP/Firewall/Filter 113
address-list-timeout (time; Default: 00:00:00) Time interval after which the address will be removed from the address list
specified by address-list parameter. Used in conjunction with
add-dst-to-address-list or add-src-to-address-list actions
Value of 00:00:00 will leave the address in the address list forever
chain (name; Default: ) Specifies to which chain rule will be added. If the input does not match the
name of an already defined chain, a new chain will be created.
connection-bytes (integer-integer; Default: ) Matches packets only if a given amount of bytes has been transfered
through the particular connection. 0 - means infinity, for example
connection-bytes=2000000-0 means that the rule matches if more than
2MB has been transfered through the relevant connection
connection-limit (integer,netmask; Default: ) Restrict connection limit per address or address block
connection-mark (no-mark | string; Default: ) Matches packets marked via mangle facility with particular connection
mark. If no-mark is set, rule will match any unmarked connection.
connection-rate (Integer 0..4294967295; Default: ) Connection Rate is a firewall matcher that allow to capture traffic based on
present speed of the connection. Read more >>
connection-state (estabilished | invalid | new | related; Default: ) Interprets the connection tracking analysis data for a particular packet:
• established - a packet which belongs to an existing connection
• invalid - a packet which could not be identified for some reason
• new - a packet which begins a new connection
• related - a packet which is related to, but not part of an existing
connection, such as ICMP errors or a packet which begins FTP data
connection
connection-type (ftp | h323 | irc | pptp | quake3 | sip | tftp; Default: ) Matches packets from related connections based on information from their
connection tracking helpers. A relevant connection helper must be enabled
under /ip firewall service-port
dst-address (IP/netmask | IP range; Default: ) Matches packets which destination is equal to specified IP or falls into
specified IP range.
dst-address-list (name; Default: ) Matches destination address of a packet against user-defined address list
dst-address-type (unicast | local | broadcast | multicast; Default: ) Matches destination address type:
• unicast - IP address used for point to point transmission
• local - if dst-address is assigned to one of router's interfaces
• broadcast - packet is sent to all devices in subnet
• multicast - packet is forwarded to defined group of devices
dst-limit (integer,time,integer,dst-address | dst-port | src-address, Matches packets if given pps limit is exceeded. As opposed to the limit
time; Default: ) matcher, every destination IP address / destination port has it's own limit.
Parameters are written in following format: count,time,burst,mode,expire.
• count - maximum average packet rate measured in packets per time
interval
• time - specifies the time interval in which the packet rate is measured
• burst - number of packets which are not counted by packet rate
• mode - the classifier for packet rate limiting
• expire - specifies interval after which recored ip address /port will be
deleted
dst-port (integer[-integer]: 0..65535; Default: ) List of destination port numbers or port number ranges
fragment (yes|no; Default: ) Matches fragmented packets. First (starting) fragment does not count. If
connection tracking is enabled there will be no fragments as system
automatically assembles every packet
Manual:IP/Firewall/Filter 114
in-bridge-port (name; Default: ) Actual interface the packet has entered the router, if incoming interface is
bridge
in-interface (name; Default: ) Interface the packet has entered the router
ingress-priority (integer: 0..63; Default: ) Matches ingress priority of the packet. Priority may be derived from
VLAN, WMM or MPLS EXP bit. Read more>>
jump-target (name; Default: ) Name of the target chain to jump to. Applicable only if action=jump
layer7-protocol (name; Default: ) Layer7 filter name defined in layer7 protocol menu.
limit (integer,time,integer; Default: ) Matches packets within given pps limit. Parameters are written in
following format: count,time,burst.
• count - maximum average packet rate measured in packets per time
interval
• time - specifies the time interval in which the packet rate is measured
• burst - number of packets which are not counted by packet rate
log-prefix (string; Default: ) Adds specified text at the beginning of every log message. Applicable if
action=log
nth (integer,integer; Default: ) Matches every nth packet. Read more >>
out-bridge-port (name; Default: ) Actual interface the packet is leaving the router, if outgoing interface is
bridge
p2p (all-p2p | bit-torrent | blubster | direct-connect | edonkey | Matches packets from various peer-to-peer (P2P) protocols. Does not work
fasttrack | gnutella | soulseek | warez | winmx; Default: ) on encrypted p2p packets.
packet-mark (no-mark | string; Default: ) Matches packets marked via mangle facility with particular packet mark. If
no-mark is set, rule will match any unmarked packet.
packet-size (integer[-integer]:0..65535; Default: ) Matches packets of specified size or size range in bytes.
per-connection-classifier (ValuesToHash:Denominator/Remainder; PCC matcher allows to divide traffic into equal streams with ability to
Default: ) keep packets with specific set of options in one particular stream. Read
more >>
port (integer[-integer]: 0..65535; Default: ) Matches if any (source or destination) port matches the specified list of
ports or port ranges. Applicable only if protocol is TCP or UDP
protocol (name or protocol ID; Default: tcp) Matches particular IP protocol specified by protocol name or number
Manual:IP/Firewall/Filter 115
psd (integer,time,integer,integer; Default: ) Attempts to detect TCP and UDP scans. Parameters are in following
format WeightThreshold, DelayThreshold, LopPortWeight,
HighPortWeight
• WeightThreshold - total weight of the latest TCP/UDP packets with
different destination ports coming from the same host to be treated as
port scan sequence
• DelayThreshold - delay for the packets with different destination ports
coming from the same host to be treated as possible port scan
subsequence
• LowPortWeight - weight of the packets with privileged (<=1024)
destination port
• HighPortWeight - weight of the packet with non-priviliged
destination port
random (integer: 1..99; Default: ) Matches packets randomly with given probability.
routing-mark (string; Default: ) Matches packets marked by mangle facility with particular routing mark
src-address (Ip/Netmaks, Ip range; Default: ) Matches packets which source is equal to specified IP or falls into
specified IP range.
src-address-list (name; Default: ) Matches source address of a packet against user-defined address list
src-address-type (unicast | local | broadcast | multicast; Default: ) Matches source address type:
• unicast - IP address used for point to point transmission
• local - if address is assigned to one of router's interfaces
• broadcast - packet is sent to all devices in subnet
• multicast - packet is forwarded to defined group of devices
src-port (integer[-integer]: 0..65535; Default: ) List of source ports and ranges of source ports. Applicable only if protocol
is TCP or UDP.
src-mac-address (MAC address; Default: ) Matches source MAC address of the packet
tcp-flags (ack | cwr | ece | fin | psh | rst | syn | urg; Default: ) Matches specified TCP flags
• ack - acknowledging data
• cwr - congestion window reduced
• ece - ECN-echo flag (explicit congestion notification)
• fin - close connection
• psh - push function
• rst - drop connection
• syn - new connection
• urg - urgent data
time (time-time,sat | fri | thu | wed | tue | mon | sun; Default: ) Allows to create filter based on the packets' arrival time and date or, for
locally generated packets, departure time and date
Stats
/ip firewall filter print stats will show additional read-only properties
Property Description
By default print is equivalent to print static and shows only static rules.
Basic examples
Router protection
Lets say our private network is 192.168.0.0/24 and public (WAN) interface is ether1. We will set up firewall to allow
connections to router itself only from our local network and drop the rest. Also we will allow ICMP protocol on any
interface so that anyone can ping your router from internet.
Customer protection
To protect the customer's network, we should check all traffic which goes through router and block unwanted. For
icmp, tcp, udp traffic we will create chains, where will be droped all unwanted packets:
Manual:IP/Firewall/Address list
Applies to RouterOS: 2.9, v3, v4 +
Summary
Sub-menu: /ip firewall address-list
Firewall address lists allow user to create lists of IP addresses grouped together. Firewall filter, mangle and NAT
facilities can use address lists to match packets against them.
The address list records could be updated dynamically via the action=add-src-to-address-list or
action=add-dst-to-address-list items found in NAT, mangle and filter facilities.
Properties
Property Description
address (IP address/netmask | IP-IP; Default: ) IP address or range to add to address list
list (string; Default: ) Name of the address list where to add IP address
Example
The following example creates an address list of people thet are connecting to port 23 (telnet) on the router and drops
all further traffic from them. Additionaly, the address list will contain one static entry of address=192.0.34.166/32
(www.example.com):
[admin@MikroTik] > /ip firewall address-list add list=drop_traffic address=192.0.34.166/32
[admin@MikroTik] > /ip firewall address-list print
Flags: X - disabled, D - dynamic
# LIST ADDRESS
0 drop_traffic 192.0.34.166
[admin@MikroTik] > /ip firewall mangle add chain=prerouting protocol=tcp dst-port=23 \
\... action=add-src-to-address-list address-list=drop_traffic
[admin@MikroTik] > /ip firewall filter add action=drop chain=input src-address-list=drop_traffic
[admin@MikroTik] > /ip firewall address-list print
Flags: X - disabled, D - dynamic
# LIST ADDRESS
0 drop_traffic 192.0.34.166
1 D drop_traffic 1.1.1.1
2 D drop_traffic 10.5.11.8
Manual:IP/Firewall/Address list 120
[admin@MikroTik] >
As seen in the output of the last print command, two new dynamic entries appeared in the address list. Hosts with
these IP addresses tried to initialize a telnet session to the router.
[Back to Content]
Manual:IP/Services
Applies to RouterOS: v3, v4
Summary
Sub-menu: /ip service
This document lists protocols and ports used by various MikroTik RouterOS services. It helps you to determine why
your MikroTik router listens to certain ports, and what you need to block/allow in case you want to prevent or grant
access to the certain services. Please see the relevant sections of the Manual for more explanations.
Properties
Note that it is not possible to add new services, only existing service modifications are allowed.
Property Description
address (IP address/netmask | IPv6/0..128; List of IP/IPv6 prefixes from which the service is accessible.
Default: )
certificate (name; Default: none) The name of the certificate used by particular service. Applicable only for services that depends on
certificates (www-ssl)
Example
For example allow telnet only from specific IPv6 address range
Service Ports
Sub-menu: /ip firewall service-port
Hosts behind a NAT-enabled router do not have true end-to-end connectivity. Therefore some Internet protocols
might not work in scenarios with NAT.
To overcome these limitations RouterOS includes a number of NAT helpers, that enable NAT traversal for various
protocols.
Helper Description
irc
SIP
tftp
Proto/Port Description
53/tcp DNS
53/udp
8291/tcp Winbox
8728/tcp API
/1 ICMP
/4 IPIP encapsulation
/47 General Routing Encapsulation (GRE) - used for PPTP and EoIP tunnels
/112 VRRP
[Back to Content]
Manual:IP/Address
Applies to RouterOS: 2.9, v3, v4 +
Summary
Sub-menu: /ip address
Standards: IPv4 RFC 791
IP addresses serve for a general host identification purposes in IP networks. Typical (IPv4) address consists of four
octets. For proper addressing the router also needs the network mask value, id est which bits of the complete IP
address refer to the address of the host, and which - to the address of the network. The network address value is
calculated by binary AND operation from network mask and IP address values. It's also possible to specify IP
address followed by slash "/" and the amount of bits that form the network address.
In most cases, it is enough to specify the address, the netmask, and the interface arguments. The network prefix and
the broadcast address are calculated automatically.
It is possible to add multiple IP addresses to an interface or to leave the interface without any addresses assigned to
it. In case of bridging or PPPoE connection, the physical interface may bot have any address assigned, yet be
perfectly usable. Putting an IP address to a physical interface included in a bridge would mean actually putting it on
the bridge interface itself. You can use /ip address print detail to see to which interface the address belongs to.
MikroTik RouterOS has following types of addresses:
• Static - manually assigned to the interface by a user
• Dynamic - automatically assigned to the interface by DHCP or an estabilished PPP connections
Manual:IP/Address 123
Properties
Property Description
broadcast (IP; Default: roadcasting IP address, calculated by default from an IP address and a network mask. Starting from v5RC6 this
255.255.255.255) parameter is removed
netmask (IP; Default: 0.0.0.0) Delimits network address part of the IP address from the host part
network (IP; Default: 0.0.0.0) IP address for the network. For point-to-point links it should be the address of the remote end. Starting from v5RC6
this parameter is configurable only for addresses with /32 netmask (point to point links)
Property Description
actual-interface Name of the actual interface the logical one is bound to. For example, if the physical interface you assigned the address to, is
(name) included in a bridge, the actual interface will show that bridge
Two IP addresses from the same network assigned to routers different interfaces are not valid unless VRF is used.
For example, the combination of IP address 10.0.0.1/24 on the ether1 interface and IP address 10.0.0.132/24 on the
ether2 interface is invalid, because both addresses belong to the same network 10.0.0.0/24. Use addresses from
different networks on different interfaces, or enable proxy-arp on ether1 or ether2.
Example
[admin@MikroTik] ip address> add address=10.10.10.1/24 interface=ether2
[admin@MikroTik] ip address> print
Flags: X - disabled, I - invalid, D - dynamic
# ADDRESS NETWORK BROADCAST INTERFACE
0 2.2.2.1/24 2.2.2.0 2.2.2.255 ether2
1 10.5.7.244/24 10.5.7.0 10.5.7.255 ether1
2 10.10.10.1/24 10.10.10.0 10.10.10.255 ether2
[admin@MikroTik] ip address>
[Back to Content]
Manual:IP/ARP 124
Manual:IP/ARP
Applies to RouterOS: 2.9, v3, v4 +
Summary
Sub-menu: /ip arp
Standards: ARP RFC 826
Even though IP packets are addressed using IP addresses, hardware addresses must be used to actually transport data
from one host to another. Address Resolution Protocol is used to map OSI level 3 IP addresses to OSI level 2 MAC
addreses. Router has a table of currently used ARP entries. Normally the table is built dynamically, but to increase
network security, it can be partialy or completely built statically by means of adding static entries.
Properties
Property Description
Property Description
ARP Modes
It is possible to set several ARP modes in interface configuration .....
Manual:IP/ARP 125
Disabled
If ARP feature is turned off on the interface, i.e., arp=disabled is used, ARP requests from clients are not answered
by the router. Therefore, static arp entry should be added to the clients as well. For example, the router's IP and MAC
addresses should be added to the Windows workstations using the arp command:
Enabled
This mode is enabled by default on all interfaces. ARPs will be discovered automatically and new dynamic entries
will be added to ARP table.
Proxy ARP
A router with properly configured proxy ARP feature acts like a transparent ARP proxy between directly connected
networks.
(needs editing)
This behaviour can be usefull, for example, if you want to assign dial-in (ppp, pppoe, pptp) clients IP addresses from
the same address space as used on the connected LAN.
Reply Only
If arp property is set to reply-only on the interface, then router only replies to ARP requests. Neighbour MAC
addresses will be resolved using /ip arp statically, but there will be no need to add the router's MAC address to other
hosts' ARP tables like in case if arp is disabled.
Manual:IP/Route
Applies to RouterOS: v3, v4, v5+
Overview
Router keeps routing information in several separate spaces:
• FIB (Forwarding Information Base), that is used to make packet forwarding decisions. It contains a copy of the
necessary routing information.
• Each routing protocol (except BGP) has it's own internal tables. This is where per-protocol routing decisions are
made. BGP does not have internal routing tables and stores complete routing information from all peers in the
RIB.
• RIB contains routes grouped in separate routing tables based on their value of routing-mark. All routes without
routing-mark are kept in the main routing table. These tables are used for best route selection. The main table is
also used for nexthop lookup.
Manual:IP/Route 126
RIB (Routing Information Base) contains complete routing information, including static routes and policy routing
rules configured by the user, routing information learned from routing protocols, information about connected
networks. RIB is used to filter routing information, calculate best route for each destination prefix, build and update
Forwarding Information Base and to distribute routes between different routing protocols.
By default forwarding decision is based only on the value of destination address. Each route has dst-address
property, that specifies all destination addresses this route can be used for. If there are several routes that apply to a
particular IP address, the most specific one (with largest netmask) is used. This operation (finding the most specific
route that matches given address) is called routing table lookup.
If routing table contains several routes with the same dst-address, only one of them can be used to forward packets.
This route is installed into FIB and marked as active.
When forwarding decision uses additional information, such as a source address of the packet, it is called policy
routing. Policy routing is implemented as a list of policy routing rules, that select different routing table based on
destination address, source address, source interface, and routing mark (can be changed by firewall mangle rules) of
the packet.
All routes by default are kept in the main routing table. Routes can be assigned to specific routing table by setting
their routing-mark property to the name of another routing table. Routing tables are referenced by their name, and
are created automatically when they are referenced in the configuration.
Each routing table can have only one active route for each value of dst-address IP prefix.
There are different groups of routes, based on their origin and properties.
Manual:IP/Route 127
Default route
Route with dst-address 0.0.0.0/0 applies to every destination address. Such route is called the default route. If
routing table contains an active default route, then routing table lookup in this table will never fail.
Connected routes
Connected routes are created
automatically for each IP network that
has at least one enabled interface
attached to it (as specifie in the /ip
address configuration). RIB tracks
status of connected routes, but does not
modify them. For each connected route
there is one ip address item such that:
Because results of the forwarding decision are cached, packets with the same source address, destination address, source interface, routing
mark and ToS are sent to the same gateway. This means that one connection will use only one link in each direction, so ECMP routes can be used
to implement per-connection load balancing. See interface bonding if you need to achieve per-packet load balancing.
To implement some setups, such as load balancing, it might be necessary to use more than one path to given
destination. However, it is not possible to have more than one active route to destination in a single routing table.
ECMP (Equal cost multi-path) routes have multiple gateway nexthop values. All reachable nexthops are copied to
FIB and used in forwarding packets.
OSPF protocol can create ECMP routes. Such routes can also be created manually.
Route selection
Each routing table can have one active route for each destination prefix. This route is installed into FIB. Active route
is selected from all candidate routes with the same dst-address and routing-mark, that meet the criteria for
becoming an active route. There can be multiple such routes from different routing protocols and from static
configuration. Candidate route with the lowest distance becomes an active route. If there is more than one candidate
route with the same distance, selection of active route is arbitrary (except for BGP routes).
BGP has the most complicated selection process (described in separate article). Notice that this protocol-internal
selection is done only after BGP routes are installed in the main routing table; this means there can be one candidate
route from each BGP peer. Also note that BGP routes from different BGP instances are compared by their distance,
just like other routes.
Nexthop lookup
Nexthop lookup is a part of the route
selection process.
Routes that are installed in the FIB
need to have interface associated with
each gateway address. Gateway
address (nexthop) has to be directly
reachable via this interface. Interface
that should be used to send out packets
to each gateway address is found by
doing nexthop lookup.
Some routes (e.g. iBGP) may have
gateway address that is several hops
away from this router. To install such
routes in the FIB, it is necessary to find
the address of the directly reachable
gateway (an immediate nexthop), that
should be used to reach the gateway
address of this route. Immediate
nextop addresses are also found by doing nexthop lookup.
Nexthop lookup is done only in the main routing table, even for routes with different value of routing-mark. It is
necessary to restrict set of routes that can be used to look up immediate nexthops. Nexthop values of RIP or OSPF
routes, for example, are supposed to be directly reachable and should be looked up only using connected routes. This
is achieved using scope and target-scope properties.
• Routes with interface name as the value of gateway are not used for nexthop lookup. If route has both interface
nexthops and active IP address nexthops, then interface nexthops are ignored.
Manual:IP/Route 129
• Routes with scope greater than the maximum accepted value are not used for nexthop lookup. Each route
specifies maximum accepted scope value for it's nexthops in the target-scope property. Default value of this
property allows nexthop lookup only through connected routes, with the exception of iBGP routes that have larger
default value and can lookup nexthop also through IGP and static routes.
Interface and immediate nexthop are selected based on the result of nexthop lookup:
• If most specific active route that nexthop lookup finds is connected route, then interface of this connected route is
used as the nexthop interface, and this gateway is marked as reachable. Since gateway is directly reachable
through this interface (that's exactly what connected route means), the gateway address is used as the immediate
nexthop address.
• If most specific active route that nexthop lookup finds has nexthop that is already resolved, immediate nexthop
address and interface is copied from that nexthop and this gateway is marked as recursive.
• If most specific active route that nexthop lookup finds is ECMP route, then it uses first gateway of that route that
is not unreachable.
• If nexthop lookup does not find any route, then this gateway is marked as unreachable.
Manual:IP/Route 130
Rules that do not match current packet are ignored. If rule has action drop or unreachable, then it is returned as a
result of the routing decision process. If action is lookup then destination address of the packet is looked up in
routing table that is specified in the rule. If lookup fails (there is no route that matches destination address of packet),
then FIB proceeds to the next rule. Otherwise:
• if type of the route is blackhole, prohibit or unreachable, then return this action as the routing decision result;
• if this is a connected route, or route with an interface as the gateway value, then return this interface and the
destination address of the packet as the routing decision result;
• if this route has IP address as the value of gateway, then return this address and associated interface as the routing
decision result;
• if this route has multiple values of nexthop, then pick one of them in round robin fashion.
Result of this routing decision is stored in new routing cache entry.
Properties
Route flags
Property(Flag) Description
disabled (X) Configuration item is disabled. It does not have any effect on other routes and is not used by forwarding or routing protocols in
any way.
active (A) Route is used for packet forwarding. See route selection.
dynamic (D) Configuration item created by software, not by management interface. It is not exported, and cannot be directly modified.
unreachable Discard packet forwarded by this route. Notify sender with ICMP host unreachable (type 3 code 1) message.
(U)
prohibit (P) Discard packet forwarded by this route. Notify sender with ICMP communication administratively prohibited (type 3 code 13)
message.
Manual:IP/Route 132
General properties
Property Description
check-gateway (arp | ping; Periodically (every 10 seconds) check gateway by sending either ICMP echo request (ping) or ARP request (arp). If
Default: "") no response from gateway is received for 10 seconds, request times out. After two timeouts gateway is considered
unreachable. After receiving reply from gateway it is considered reachable and timeout counter is reset.
distance (integer[1..255]; Value used in route selection. Routes with smaller distance value are given preference. If value of this property is not
Default: "1") set, then the default depends on route protocol:
• connected routes: 0
• static routes: 1
• eBGP: 20
• OSPF: 110
• RIP: 120
• MME: 130
• iBGP: 200
dst-address (IP prefix; IP prefix of route, specifies destination addresses that this route can be used for. Netmask part of this property
Default: 0.0.0.0/0) specifies how many of the most significant bits in packet destination address must match this value. If there are
several active routes that match destination address of packet, then the most specific one (with largest netmask value)
is used.
gateway (IP IP%interface | Array of IP addresses or interface names. Specifies which host or interface packets should be sent to. Connected
IP@table[, IP | string, [..; routes and routes with blackhole, unreachable or prohibit type do not have this property. Usually value of this
Default: "") property is a single IP address of a gateway that can be directly reached through one of router's interfaces (but see
nexthop lookup). ECMP routes have more than one gateway value. Value can be repeated several times.
pref-src (IP; Default: "") Which of the local IP addresses to use for locally originated packets that are sent via this route. Value of this property
has no effect on forwarded packets. If value of this property is set to IP address that is not local address of this router
then the route will be inactive. If pref-src value is not set, then for locally originated packets that are sent using this
route router will choose one of local addresses attached to the output interface that match destination prefix of the
route (an example).
route-tag (integer; Default: Value of route tag attribute for RIP or OSPF. For RIP only values 0..4294967295 are valid.
"")
routing-mark (string; Name of routing table that contains this route. Not set by default which is the same as main. Packets that are marked
Default: "") by firewall with this value of routing-mark will be routed using routes from this table, unless overridden by policy
routing rules. Not more than 250 routing marks are possible per router.
scope (integer[0..255]; Used in nexthop resolution. Route can resolve nexthop only through routes that have scope less than or equal to the
Default: "30") target-scope of this route. Default value depends on route protocol:
• connected routes: 10 (if interface is running)
• OSPF, RIP, MME routes: 20
• static routes: 30
• BGP routes: 40
• connected routes: 200 (if interface is not running)
target-scope Used in nexthop resolution. This is the maximum value of scope for a route through which a nexthop of this route can
(integer[0..255]; Default: be resolved. See nexthop lookup. For iBGP value is set to 30 by default.
"10")
type (unicast | blackhole | Routes that do not specify nexthop for packets, but instead perform some other action on packets have type different
prohibit | unreachabl; from the usual unicast. blackhole route silently discards packets, while unreachable and prohibit routes send ICMP
Default: unicast) Destination Unreachable message (code 1 and 13 respectively) to the source address of the packet.
Property Description
gateway-status Array of gateways, gateway states and which interface is used for forwarding. Syntax "IP state interface", for example
(array) "10.5.101.1 reachable bypass-bridge". State can be unreachable, reachable or recursive. See nexthop lookup for details.
ospf-type (string)
Property Description
bgp-as-path (string; Default: "") Value of BGP AS_PATH attribute. Comma separated list of AS numbers with confederation AS
numbers enclosed in () and AS_SETs enclosed in {}. Used to check for AS loops and in BGP route
selection algorithm: routes with shorter AS_PATH are preferred (but read how AS_PATH length is
calculated).
bgp-communities (array of Value of BGP communities list. This attribute can be used to group or filter routes. Named values
(integer:integer | internet | no-advertise | have special meanings:
no-export |local-as; Default: ) • internet - advertise this route to the Internet community (i.e. all routers)
• no-advertise - do not advertise this route to any peers
• no-export - do not advertise this route to EBGP peers
• local-as - same as no-export, except that route is also advertised to EBGP peers inside local
confederation
bgp-local-pref (integer; Default: ) Value of BGP LOCAL_PREF attribute. Used in BGP route selection algorithm: routes with greater
LOCAL_PREF value are preferred. If value is not set then it is interpreted as 100.
bgp-med (integer; Default: ) Value of BGP MULTI_EXIT_DISC BGP attribute. Used in BGP route selection algorithm: routes
with lower MULTI_EXIT_DISC value are preferred.. If value is not set then it is interpreted as 0.
bgp-origin (igp | egp | incomplete; Default: Value of BGP ORIGIN attribute. Used in BGP route selection algorithm: igp routes are preferred over
) egp and egp over incomplete.
bgp-prepend (integer [0..16]; Default: ) How many times to prepend router's own AS number to AS_PATH attribute when announcing route
via BGP. Affects only routes sent to eBGP peers (for iBGP value 0 is always used).
Read-only
Manual:IP/Route 134
Property Description
bgp-weight (integer) Additional value used by BGP best path selection algorithm. Routes with higher weight are preferred. It can be set by
incoming routing filters and is useful only for BGP routes. If value is not set then it is interpreted as 0.
received-from (string) Name of the BGP peer from which route is received.
Packages required: routing-test, mpls-test for RouterOS v3; routing, mpls for RouterOS v4+
Description
RouterOS 3.x allows to create multiple Virtual Routing and Forwarding instances on a single router. This is useful
for BGP based MPLS VPNs. Unlike BGP VPLS, which is OSI Layer 2 technology, BGP VRF VPNs work in Layer
3 and as such exchange IP prefixes between routers. VRFs solve the problem of overlapping IP prefixes, and provide
the required privacy (via separated routing for different VPNs).
To create a VRF, configure it under /ip route vrf. You can now add routes to that VRF - simply specify
routing-mark attribute. Connected routes from interfaces belonging to a VRF will be installed in the right routing
table automatically.
Technically VRFs are based on policy routing. There is exactly one policy route table for each active VRF. The
existing policy routing support in MT RouterOS is not changed; but on the other hand, it is not possible to have
policy routing within a VRF. The main differences between VRF tables and simple policy routing are:
• Routes in VRF tables resolve next-hops in their own route table by default, while policy routes always use the
main route table. Read-only route attribute gateway-table displays information about which table is used for a
particular route (default is main).
• Route lookup is different. For policy routing: after route lookup has been done in policy-route table, and no route
was found, route lookup proceeds to the main route table. For VRFs: if lookup is done, and no route is found in
VRF route table, the lookup fails with "network unreachable" error. (You can still override this behavior with
custom route lookup rules, as they have precedence.)
You can use multi-protocol BGP with VPNv4 address family to distribute routes from VRF route tables - not only to
other routers, but also to different routing tables in the router itself. First configure the route distinguisher for a VRF.
It can be done under /ip route vrf. Usually there will be one-to-one correspondence between route distinguishers and
VRFs, but that's not a mandatory requirement. Route installation in VRF tables is controlled by BGP extended
communities attribute. Configure import and export lists under /ip route vrf, import-route-targets and
export-route-targets. Export route target list for a VRF should contained at least the route distinguisher for that
VRF. Then configure a list of VRFs for each BGP instance that will participate in VRF routing.
Once list of VRFs for BGP instance, route distinguisher and export route targets has been configured, some active
VPNv4 address family routes may be created, depending on BGP redistribution settings. They are installed in a
separate route table and, if present, visible under /routing bgp vpnv4-route. These so called VPNv4 routes have
prefix that consists of a route distinguisher and an IPv4 network prefix. This way you can have overlapping IPv4
Manual:Virtual Routing and Forwarding 135
Examples
In this example rudimentary MPLS backbone (consisting of two Provider Edge (PE) routers PE1 and PE2) is created
and configured to forward traffic between Customer Edge (CE) routers CE1 and CE2 routers that belong to cust-one
VPN.
CE1 Router
/ip address add address=10.1.1.1/24 interface=ether1
# use static routing
/ip route add dst-address=10.3.3.0/24 gateway=10.1.1.2
CE2 Router
/ip address add address=10.3.3.4/24 interface=ether1
/ip route add dst-address=10.1.1.0/24 gateway=10.3.3.3
PE1 Router
/interface bridge add name=lobridge
/ip address add address=10.1.1.2/24 interface=ether1
/ip address add address=10.2.2.2/24 interface=ether2
/ip address add address=10.5.5.2/32 interface=lobridge
/ip route vrf add disabled=no routing-mark=cust-one route-distinguisher=1.1.1.1:111 \
export-route-targets=1.1.1.1:111 import-route-targets=1.1.1.1:111 interfaces=ether1
/mpls ldp set enabled=yes transport-address=10.5.5.2
/mpls ldp interface add interface=ether2
/routing bgp instance set default as=65000
/routing bgp instance vrf add instance=default routing-mark=cust-one redistribute-connected=yes
/routing bgp peer add remote-address=10.5.5.3 remote-as=65000 address-families=vpnv4 \
update-source=lobridge
# add route to the remote BGP peer's loopback address
/ip route add dst-address=10.5.5.3/32 gateway=10.2.2.3
Manual:Virtual Routing and Forwarding 136
interface Loopback0
ip address 10.5.5.3 255.255.255.255
interface FastEthernet0/0
ip address 10.2.2.3 255.255.255.0
mpls ip
interface FastEthernet1/0
ip vrf forwarding cust-one
ip address 10.3.3.3 255.255.255.0
Results
Check that VPNv4 route redistribution is working:
Let's take closer look at IP routes in cust-one VRF. The 10.1.1.0/24 IP prefix is a connected route that belongs to an
interface that was configured to belong to cust-one VRF. The 10.3.3.0/24 IP prefix was advertised via BGP as
VPNv4 route from PE2 and is imported in this VRF routing table, because our configured import-route-targets
matched the BGP extended communities attribute it was advertised with.
You should be able to ping from CE1 to CE2 and vice versa.
As opposed to the simplest setup, in this example we have two customers: cust-one and cust-two.
We configure two VPNs for then, cust-one and cust-two respectively, and exchange all routes between them. (This is
also called "route leaking").
Note that this could be not the most typical setup, because routes are usually not exchanged between different
customers. In contrast, by default it should not be possible to gain access from one VRF site to a different VRF site
in another VPN. (This is the "Private" aspect of VPNs.) Separate routing is a way to provide privacy; and it is also
required to solve the problem of overlapping IP network prefixes. Route exchange is in direct conflict with these two
requirement but may sometimes be needed (e.g. temp. solution when two customers are migrating to single network
infrastructure).
Manual:Virtual Routing and Forwarding 139
PE1 Router
# replace the old VRF with this:
/ip route vrf add disabled=no routing-mark=cust-one route-distinguisher=1.1.1.1:111 \
export-route-targets=1.1.1.1:111 import-route-targets=1.1.1.1:111,2.2.2.2:222 interfaces=ether1
ip vrf cust-two
rd 2.2.2.2:222
route-target export 2.2.2.2:222
route-target import 1.1.1.1:111
route-target import 2.2.2.2:222
exit
interface FastEthernet2/0
ip vrf forwarding cust-two
ip address 10.4.4.3 255.255.255.0
Results
The output of /ip route print now is interesting enough to deserve detailed observation.
The route 10.1.1.0/24 was received from remote BGP peer and is installed in both VRF routing tables.
The routes 10.3.3.0/24 and 10.4.4.0/24 are also installed in both VRF routing tables. Each is as connected route in
one table and as BGP route in another table. This has nothing to do with their being advertised via BGP. They are
Manual:Virtual Routing and Forwarding 141
simply being "advertised" to local VPNv4 route table and locally reimported after that. Import and export
route-targets determine in which tables they will end up.
This can be deduced from its attributes - they don't have the usual BGP properties. (Route 10.4.4.0/24.)
# add route to 5.5.5.0/24 in 'vrf1' routing table with gateway in the main routing table
add dst-address=5.5.5.0/24 gateway=10.3.0.1@main routing-mark=vrf1
The second way is to explicitly specify interface in gateway field. The interface specified can belong to a VRF
instance. Example:
# add route to 5.5.5.0/24 in the main routing table with gateway at 'ether2' VRF interface
add dst-address=5.5.5.0/24 gateway=10.3.0.1%ether2 routing-mark=main
# add route to 5.5.5.0/24 in the main routing table with 'ptp-link-1' VRF interface as gateway
add dst-address=5.5.5.0/24 gateway=ptp-link-1 routing-mark=main
As can be observed, there are two variations possible - to specify gateway as ip_address%interface or to simply
specify interface. The first should be used for broadcast interfaces in most cases. The second should be used for
point-to-point interfaces, and also for broadcast interfaces, if the route is a connected route in some VRF. For
example, if you have address 1.2.3.4/24 on interface ether2 that is put in a VRF, there will be connected route to
1.2.3.0/24 in that VRF's routing table. It is acceptable to add static route 1.2.3.0/24 in a different routing table with
interface-only gateway, even though ether2 is a broadcast interface:
References
RFC 4364: BGP/MPLS IP Virtual Private Networks (VPNs) [1]
MPLS Fundamentals, chapter 7, Luc De Ghein, Cisco Press 2006
References
[1] http:/ / www. ietf. org/ rfc/ rfc4364. txt
Manual:Routing/OSPF
Applies to RouterOS: v3, v4 +
Summary
MikroTik RouterOS implements OSPF version 2 (RFC 2328). The OSPF protocol is the link-state protocol that takes
care of the routes in the dynamic network structure that can employ different paths to its subnetworks. It always
chooses shortest path to the subnetwork first.
Instance
Sub-menu: /routing ospf instance
Since v3.17 it is possible to run multiple OSPF instances. General OSPF configuration now is moved to instances.
Properties
Property Description
distribute-default (never | specifies how to distribute default route. Should be used for ABR (Area Border router) or ASBR
if-installed-as-type-1 | if-installed-as-type-2 | (Autonomous System boundary router)
always-as-type-1 | always-as-type-2; Default: • never - do not send own default route to other routers
never) • if-installed-as-type-1 - send the default route with type 1 metric only if it has been installed (a
static default route, or route added by DHCP, PPP, etc.)
• if-installed-as-type-2 - send the default route with type 2 metric only if it has been installed (a
static default route, or route added by DHCP, PPP, etc.)
• always-as-type-1 - always send the default route with type 1 metric
• always-as-type-2 - always send the default route with type 2 metric
domain-id (Hex|Address;) MPLS related parameter. Identifies OSPF domain of the instance. This value is attached to OSPF
routes redistributed in BGP as VPNv4 routes as BGP extended community attribute, and used when
BGP VPNv4 routes are redistributed back OSPF to determine whether to generate inter-area or
AS-external LSA for that route. By default Null domain-id is used, as described in RFC 4577.
domain-tag (integer: 0..4294967295 ;) if set, then used in route redistribution (as route-tag in all external LSAs generated by this router),
and in route calculation (all external LSAs having this route tag are ignored). Needed for
interoperability with older Cisco systems. By default not set.
in-filter (string;) name of the routing filter chain used for incoming prefixes
metric-bgp (integer|auto; Default: 20) routes learned from the BGP protocol are redistributed with this metric. When set to auto, MED
attribute value from BGP route will be used, if MED is not set then default value 20 is used.
Manual:Routing/OSPF 143
metric-connected (integer; Default: 20) routes to directly connected networks are distributed with this metric
metric-default (integer; Default: 1) the default route is distributed with this metric
metric-other-ospf (integer|auto; Default: routes learned from other OSPF instances are redistributed with this metric. If auto is configured,
20) then the cost from previous instance is taken into account, otherwise cost is set to statically
configured value.
metric-rip (integer; Default: 20) routes learned from the RIP protocol are redistributed with this metric
metric-static (integer; Default: 20) static routes are distributed with this metric
mpls-te-area (string;) the area used for MPLS traffic engineering. TE Opaque LSAs are generated in this area. No more
than one OSPF instance can have mpls-te-area configured.
mpls-te-router-id (ip;) loopback interface from which to take IP address used as Router-ID in MPLS TE Opaque LSAs
out-filter (string;) name of the routing filter chain used for outgoing prefixes
redistribute-bgp (as-type-1 | as-type-2 | no; redistribute routes learned by the BGP protocol
Default: no)
redistribute-connected (as-type-1 | redistribute connected routes, i.e. routes to directly reachable networks
as-type-2 | no; Default: no)
redistribute-rip (as-type-1 | as-type-2 | no; redistribute routes learned by the RIP protocol
Default: no)
router-id (IP address; Default: 0.0.0.0) the OSPF Router ID. If not specified, OSPF use one of router's IP addresses.
routing-table (name of routing table;) the routing table this OSPF instance operates on
Notes
OSPF protocol supports two types of metrics:
• type1 - ospf metric is the sum of the internal OSPF cost and the external route cost
• type2 - ospf metric is equal only to the external route cost.
Status
Command /routing ospf monitor will display current OSPF status.
For multi instance OSPF you have to use following command: /routing ospf instance print status
Available read only properties:
Manual:Routing/OSPF 144
Property Description
dijkstras (integer) shows how many times Dijkstra's algorithm was executed (i.e. OSPF routes were recalculated)
external-imports (integer) how many external routes were imported into OSPF from this router
Area
Sub-menu: /routing ospf area
Description
OSPF allows collections of routers to be grouped together. Such a group is called an area. Each area runs a separate
copy of the basic link-state routing algorithm. This means that each area has its own link-state database and
corresponding shortest path tree.
The structure of an area is invisible from other areas. This isolation of knowledge makes the protocol more scalable
if multiple areas are used; routing table calculation takes less CPU resources and routing traffic is reduced.
However, multi-area setups create additional complexity. It is not recommended separate areas with fewer than 50
routers. The maximum number of routers in one area is mostly dependent on CPU power you have for routing table
calculation.
Properties
Property Description
area-id (IP address; Default: OSPF area identifier. If the router has networks in more than one area, then an area with area-id=0.0.0.0 (the
0.0.0.0) backbone) must always be present. The backbone always contains all area border routers. The backbone is
responsible for distributing routing information between non-backbone areas. The backbone must be
contiguous, i.e. there must be no disconnected segments. However, area border routers do not need to be
physically connected to the backbone - connection to it may be simulated using a virtual link.
default-cost (integer; Default: 1) specifies the cost for the default route originated by this stub area ABR. Applicable only for stub areas on
ABRs
inject-summary-lsas (yes | no; specifies whether to flood summary LSAs in this stub area. Applicable only for stub areas on ABRs
Default: yes)
translator-role (translate-always | Parameter indicates which ABR will be used as translator from type7 to type5. Applicable only if area type is
translate-candidate | NSSA
translate-never; Default: • translate-always - router will be always used as translator
translate-candidate) • translate-never - router will never be used as translator
• translate-candidate - ospf ellects one of candidate routers to be a translator
Status
/routing ospf area print status will show additional read-only properties
Property Description
Area Range
Sub-menu: /routing ospf area range
Description
Prefix ranges are used to aggregate routing information on area boundaries. By default, ABR creates a summary
LSA for each route in specific area, and advertises it in adjacent areas.
Using ranges allows to create only one summary LSA for multiple routes and send only single advertisement into
adjacent areas, or to suppress advertisements altogether.
If a range is configured with 'advertise' parameter, a single summary LSA is advertised for each range if there are
any routes under the range is the specific area. Else ('advertise' parameter disabled) no summary LSAs are created
and advertised outside area boundaries at all.
Properties
Property Description
advertise (yes | no; Default: yes) whether to create summary LSA and advertise it to adjacent areas
area (string; Default: ) the OSPF area associated with this range
cost (integer | default; Default: default) the cost of the summary LSA this range will create
default - use the largest cost of all routes used (i.e. routes that fall within this range)
Note: For an active range (i.e. one that has at least one OSPF route from the specified area falling under it), a
route with type 'unreachable' is created and installed in the routing table.
Network
Sub-menu: /routing ospf network
To start the OSPF protocol, you have to define the networks on which OSPF will run and associated area for each of
these networks
Manual:Routing/OSPF 146
Property Description
area (string; the OSPF area to be associated with the specified address range
Default:
backbone)
network (IP the network prefix associated with the area. OSPF will be enabled on all interfaces that has at least one address falling within
prefix; Default: ) this range. Note that the network prefix of the address is used for this check (i.e. not the local address). For point-to-point
interfaces this means the address of the remote endpoint.
Interface
Sub-menu: /routing ospf interface
Property Description
authentication (none | simple | md5; specifies authentication method for OSPF protocol messages.
Default: none) • none - do not use authentication
• simple - plain text authentication
• md5 - keyed Message Digest 5 authentication
authentication-key (string; Default: authentication key to be used for simple or MD5 authentication
"")
authentication-key-id (integer; key id is used to calculate message digest (used only when MD5 authentication is enabled). Value should
Default: 1) match on all OSPF routers from the same region.
cost (integer: 1..65535; Default: 1) interface cost expressed as link state metric
dead-interval (time; Default: 40s) specifies the interval after which a neighbor is declared as dead. This interval is advertised in hello
packets. This value must be the same for all routers on a specific network, otherwise adjacency between
them will not form
hello-interval (time; Default: 10s) the interval between hello packets that the router sends out this interface. The smaller this interval is, the
faster topological changes will be detected, but more routing traffic will ensue. This value must be the
same for all routers on a specific network, otherwise adjacency between them will not form
network-type (broadcast | nbma | the OSPF network type on this interface. Note that if interface configuration does not exist, the default
point-to-point | ptmp; Default: network type is 'point-to-point' on PtP interfaces, and 'broadcast' on all other interfaces.
broadcast) • broadcast - network type suitable for Ethernet and other multicast capable link layers. Elects
designated router
• nbma - Non-Broadcast Multiple Access. Protocol packets are sent to each neighbors unicast address.
Requires manual configuration of neighbors. Elects designated router
• point-to-point - suitable for networks that consists only of two nodes. Does not elect designed router
• ptmp - Point-to-Multipoint. Easier to configure than NBMA because it requires no manual
configuration of neighbor. Does not elect designed router. This is the most robust network type and as
such suitable for wireless networks, if 'broadcast' mode does not works good enough for them
passive (yes | no; Default: no) if enabled, do not send or receive OSPF traffic on this interface
priority (integer: 0..255; Default: 1) router's priority. Used to determine the designated router in a broadcast network. The router with highest
priority value takes precedence. Priority value 0 means the router is not eligible to become designated or
backup designated router at all.
retransmit-interval (time; Default: time between retransmitting lost link state advertisements. When a router sends a link state advertisement
5s) (LSA) to its neighbor, it keeps the LSA until it receives back the acknowledgment. If it receives no
acknowledgment in time, it will retransmit the LSA
transmit-delay (time; Default: 1s) link state transmit delay is the estimated time it takes to transmit a link state update packet on the interface
Manual:Routing/OSPF 147
Status
/routing ospf interface print status will show additional information about used interfaces
Property Description
adjacent-neighbors (integer;) count of OSPF neighbors found on this interface that have formed adjacencies
NBMA Neighbor
Sub-menu: /routing ospf nbma-neighbor
Manual configuration for non-broadcast multi-access neighbors. Required only if interfaces with
'network-type=nbma' are configured.
Property Description
poll-interval (time; Default: 2m) how often to send hello messages to neighbors which are in "down" state (i.e. there is no traffic from them)
priority (integer: 0..255; Default: 0) assumed priority value of neighbors which are in "down" state
Virtual Link
Sub-menu: /routing ospf virtual-link
Description
As stated in OSPF RFC, the backbone area must be contiguous. However, it is possible to define areas in such a way
that the backbone is no longer contiguous. In this case the system administrator must restore backbone connectivity
by configuring virtual links. Virtual link can be configured between two routers through common area called transit
area, one of them should have to be connected with backbone. Virtual links belong to the backbone. The protocol
treats two routers joined by a virtual link as if they were connected by an unnumbered point-to-point network
Properties
Manual:Routing/OSPF 148
Property Description
authentication (none | simple | md5; Default: none) specifies authentication method for OSPF protocol messages.
authentication-key (string; Default: "") authentication key to be used for simple or MD5 authentication
transit-area (string; Default: (unknown)) a non-backbone area the two routers have in common
Note: Virtual link should be configured on both routers. Virtual links can not be established through stub
areas.
LSA
Sub-menu: /routing ospf lsa
Read only properties:
Property Description
area (string)
type (string)
sequence-number (string) Number of times the LSA for a link has been updated.
age (integerr) How long ago (in seconds) the last update occurred
options (string)
body (string)
Neighbor
Sub-menu: /routing ospf Neighbor
Read only properties:
Property Description
address (IP address) IP address of neighbor router that is used to form OSPF connection
state-changes (integer) Total count of OSPF state changes since neighbor identification
ls-retransmits (integer)
ls-requests (integer)
db-summaries (integer)
OSPF Router
Sub-menu: /routing ospf ospf-router
List of all area border routers (ABRs).
Read only properties:
Property Description
area (string)
state (string)
cost (integer)
Route
Sub-menu: /routing ospf route
Read only properties:
Manual:Routing/OSPF 150
Property Description
state (intra-area | inter-area | ext-1 | ext-2 | imported-ext-1 | imported-ext-2) State representing origin of the route
area (external | backbone | <other area>) Which OSPF area this route belongs to
Sham link
Sub-menu: /routing ospf sham-link
Description
A sham-link is required between any two VPN sites that belong to the same OSPF area and share an OSPF backdoor
link. If there is no intra-area link between the CE routers, you do not need to configure an OSPF sham link.
Sham link configuration example
Sham link must be configured on both sides.
For a sham link to be active, two conditions must be met:
• src-address is a valid local address with /32 netmask in OSPF instance's routing table.
• there is a valid route to dst-address in the OSPF instance's routing table.
When the sham link is active, hello packets are sent on it only until the neighbor reaches full state. After that, hello
packet sending on the sham link is suppressed.
RouterOS does not support periodic LSA refresh suppression on sham-links yet.
Properties
Property Description
area (area name) name of area that shares an OSPF backdoor link
See More
• OSPF case studies
• OSPF Configuration Examples
[Back to Content]
Manual:OSPF Case Studies 151
Summary
Sub-menu level: /routing ospf
This chapter describes the Open Shortest Path First (OSPF) routing protocol support in RouterOS.
OSPF is Interior Gateway Protocol (IGP) and distributes routing information only between routers belonging to the
same Autonomous System (AS).
OSPF is based on link-state technology that has several advantages over distance-vector protocols such as RIP:
• no hop count limitations;
• multicast addressing is used to send routing information updates;
• updates are sent only when network topology changes occur;
• logical definition of networks where routers are divided into areas
• transfers and tags external routes injected into AS.
However there are few disadvantages:
• OSPF is quite CPU and memory intensive due to SPF algorithm and maintenance of multiple copies of routing
information;
• more complex protocol to implement compared to RIP;
MikroTik RouterOS implements OSPF version 2 (RFC 2328) and version 3 (RFC 5340, OSPF for IPv6).
OSPF Terminology
Term definitions related to OSPF operations.
• Neighbor - connected (adjacent) router that is running OSPF with the adjacent interface assigned to the same
area. Neighbors are found by Hello packets.
• Adjacency - logical connection between router and its corresponding DR and BDR. No routing information is
exchanged unless adjacencies are formed.
• Link - link refers to a network or router interface assigned to any given network.
• Interface - physical interface on the router. Interface is considered as link, when it is added to OSPF. Used to
build link database.
• LSA - Link State Advertisement, data packet contains link-state and routing information, that is shared among
OSPF neighbors.
• DR - Designated Router, chosen router to minimize the number of adjacencies formed. Option is used in
broadcast networks.
• BDR -Backup Designated Router, hot standby for the DR. BDR receives all routing updates from adjacent
routers, but it does not flood LSA updates.
• Area - areas are used to establish a hierarchical network.
• ABR - Area Border Router, router connected to multiple areas.
• ASBR - Autonomous System Boundary Router, router connected to an external network (in a different AS).
• NBMA - Non-broadcast multi-access, networks allow multi-access but have no broadcast capability (for example
X.25, Frame Relay). Additional OSPF neighbor configuration is required for those networks.
Manual:OSPF Case Studies 152
OSPF Operation
OSPF is a link-state protocol. Interface of the router is considered an OSPF link and state of all the links are stored in
link-state database.
Link-state routing protocols are distributing, replicating database that describes the routing topology. Each router in
routing domain collects local routing topology and sends this information via link-state advertisements (LSAs).
LSAs are flooded to all other routers in routing domain and each router generates link-state database from received
LSAs. The link-state protocol's flooding algorithm ensures that each router has identical link-state database. Each
router is calculating routing table based on this link-state database.
Looking at the link-state database each routing domain router knows how many other routers are in the network, how
many interfaces routers have, what networks link between router connects, cost of each link and so on.
There are several steps before OSPF network becomes fully functional:
• Neighbor discovery
• Database Synchronization
• Routing calculation
Field Description
Packet type There are several types of OSPF packets: Hello packet, Database Description (DD) packet, Link state request packet, link State
Update packet and Link State Acknowledgment packet. All of these packets except Hello packet are used in link-state database
synchronization
Area ID Allows OSPF router to associate the packet to the proper OSPF area.
Authentication These fields allow the receiving router to verify that the packet's contents was not modified and that packet really came from
fields OSPF router which Router ID appears in the packet.
There are five different OSPF packet types used to ensure proper LSA flooding over the OSPF network.
• Hello packet - used to discover OSPF neighbors and build adjacencies.
• Database Description (DD) - check for Database synchronization between routers. Exchanged after adjacencies
are built.
• Link-State Request (LSR) - used to request up to date pieces of the neighbor’s database. Out of date parts of
routes database are determined after DD exchange.
• Link-State Update (LSU) - carries a collection of specifically requested link-state records.
• Link-State Acknowledgment (LSack) - is used to acknowledge other packet types that way introducing reliable
communication.
Neighbor discovery
Neighbors are discovered by periodically sending OSPF Hello packets out of configured interfaces. By default Hello
packets are sent out with 10 second interval. This interval can be changed by setting hello interval. Router learns the
existence of a neighboring router when it receives the neighbor's Hello in return.
The transmission and reception of Hello packets also allows router to detect failure of the neighbor. If Hello packets
are not received within Dead interval (which by default is 40s) router starts to route packets around the failure. Hello
protocol ensures that the neighboring routers agree on the Hello interval and Dead interval parameters, preventing
situations when not in time received Hello packets mistakenly bring the link down.
Manual:OSPF Case Studies 154
Field Description
router priority an 8-bit value used to aid in the election of the DR and BDR. (Not set in p2p links)
router dead interval time interval has to be received before consider the neighbor is down. ( By default four times bigger than Hello interval)
Neighbor router IDs a list of router-ids for all the originating router's neighbors
On each type of network segment Hello protocol works a little different. It is clear that on point-to-point segments
only one neighbor is possible and no additional actions are required. However if more than one neighbor can be on
the segment additional actions are taken to make OSPF functionality even more efficient.
Note: Network mask, Priority, DR and BDR fields are used only when the neighbors are connected by a
broadcast or NBMA network segment.
Attached node to the broadcast subnet can send single packet and that packet is received by all
other attached nodes. This is very useful for auto-configuration and information replication. Another useful
capability in broadcast subnets is multicast. This capability allows to send single packet which will be received by
nodes configured to receive multicast packet. OSPF is using this capability to find OSPF neighbors and detect
bidirectional connectivity.
Consider Ethernet network illustrated in image below.
Each OSPF router joins the IP multicast group AllSPFRouters (224.0.0.5), then router periodically multicasts its
Hello packets to the IP address 224.0.0.5. All other routers that joined the same group will receive multicasted Hello
packet. In that way OSPF routers maintain relationships with all other OSPF routers by sending single packet instead
of sending separate packet to each neighbor on the segment.
This approach has several advantages:
Summary
Two routers do not become neighbors unless the following conditions are met.
• Two way communication between routers is possible. Determined by flooding Hello packets.
• Interface should belong to the same area;
• Interface should belong to the same subnet and have the same network mask, unless it has network-type
configured as point-to-point;
• Routers should have the same authentication options, and have to exchange same password (if any);
• Hello and Dead intervals should be the same in Hello packets;
• External routing and NSSA flags should be the same in Hello packets.
Database Synchronization
Link-state Database synchronization between OSPF routers are very important.
There are two types of database synchronizations:
Image on the right illustrates adjacency formations on broadcast subnets. Routers R1 and R2 are Designated Router
and Backup Designated router respectively. For example, R3 wants to flood Link State Update (LSU) to both R1 and
R2, router sends LSU to IP multicast address AllDRouters (224.0.0.6) and only DR and BDR listens to this
multicast address. Then Designated Router sends LSU addressed to AllSPFRouters, updating the rest of the routers.
DR election
DR and BDR routers are elected from data received in Hello packet. The first OSPF router on a subnet is always
elected as Designated Router, when second router is added it becomes Backup Designated Router. When existing
DR or BDR fails new DR or BDR is elected taking into account configured router priority. Router with the highest
priority becomes the new DR or BDR.
Being Designated Router or Backup Designated Router consumes additional resources. If Router Priority is set to 0,
then router is not participating in the election process. This is very useful if certain slower routers are not capable of
being DR or BDR.
The cost of an interface on Cisco routers is inversely proportional to the bandwidth of that interface. Higher
bandwidth indicates lower cost. If similar costs are necessary on RouterOS, then use following formula:
Cost = 100000000/bw in bps.
OSPF router is using Dijkstra's Shortest Path First (SPF) algorithm to calculate shortest path. The algorithm places
router at the root of a tree and calculates shortest path to each destination based on the cumulative cost required to
reach the destination. Each router calculates own tree even though all routers are using the same link-state database.
SPT calculation
Assume we have the following network. Network consists of 4(four) routers. OSPF costs for outgoing interfaces are
shown near the line that represents the link. In order to build shortest path tree for router R1, we need to make R1 the
root and calculate the smallest cost for each destination.
As you can see from image above multiple shortest paths have been found to 172.16.1.0 network, allowing load
balancing of the traffic to that destination called equal-cost multipath (ECMP). After the shortest path tree is built,
router starts to build the routing table accordingly. Networks are reached consequently to the cost calculated in the
tree.
Routing table calculation looks quite simple, however when some of the OSPF extensions are used or OSPF areas
are calculated, routing calculation gets more complicated.
Configuring OSPF
Let's look how to configure single-area OSPF network.
One command is required to start OSPF on MikroTik RouterOS - add network in ospf network menu.
Let's assume we have the following network.
Manual:OSPF Case Studies 158
It has only one area with three routers connected to the same network 172.16.0.0/24. Backbone area is created during
RouterOS installation and additional configuration is not required for area settings.
R1 configuration:
R2 configuration:
R3 configuration:
As you can see OSPF is up and running, notice that router-id is set the same as IP address of the router. It was done
automatically, because router-id was not specified during OSPF configuration.
Add a network to assign interface to the certain area. Look at the OSPF interface menu to verify that dynamic entry
was created and correct network type was detected.
Next step is to verify, that both neighbors are found, DR and BDR is elected and adjacencies are established:
Most of the properties are self explanatory, but if something is unclear, description can be found in neighbor
reference manual
Last thing to check whether LSA table is generated properly.
Manual:OSPF Case Studies 159
We have three router links and one network link. All properties are explained in LSA reference manual.
Congratulations, we have fully working OSPF network at this point.
Authentication
It is possible to secure OSPF packets exchange, MikroTik RouterOS provides two authentication methods, simple
and MD5. OSPF authentication is disabled by default.
Authentication is configured per interface. Add static ospf interface entry and specify authentication properties to
secure OSPF information exchange. md5 authentication configuration on ether1 is shown below:
/routing ospf interface
add interface=ether1 authentication=md5 authentication-key=mySampleKey authentication-key-id=2
Simple authentication is plain text authentication method. Method is vulnerable to passive attacks, anybody with
packet sniffer can easily get password. Method should be used only to protect OSPF from mis-configurations.
MD5 is a cryptographic authentication and is more preferred. Authentication-key, key-id and OSPF packet content is
used to generate message digest that is added to the packet. Unlike the simple authentication method, key is not
exchanged over the network.
Authentication-key-id value is 1, when authentication is not set (even for router that do not allow to set key id at all).
Multi-area networks
Large single area network can produce serious issues:
• Each router recalculates database every time whenever network topology change occurs, the process takes
CPU resources.
• Each router holds entire link-state database, which shows the topology of the entire network, it takes
memory resources.
• Complete copy of the routing table and number of routing table entries may be significantly greater than the
number of networks, that can take even more memory resources.
• Updating large databases require more bandwidth.
To keep routing table size, memory and CPU demands to a manageable levels. OSPF uses a two-layer area
hierarchy:
• backbone (transit) area - Primary function of this area is the fast and efficient movement of IP packets.
Backbone area interconnects other areas and generally, end users are not found within a backbone area.
• regular area - Primary function of this area is to connect users and resources. To travel from one are to another,
traffic must travel over the backbone, meaning that two regular areas cannot be directly connected. Regular areas
have several Subtypes:
• Standard Area
• Stub Area
• Totally Stubby Area
• Not-so-stubby area (NSSA)
Manual:OSPF Case Studies 160
Routing information exchange between areas is essentially Distance Vector algorithm and to prevent algorithm's
convergence problems, such as counting to infinity, all areas are required to attach directly to backbone area
making simple hub-and-spoke topology. Area-ID of backbone area is always 0.0.0.0 and can not be changed.
There are several types of routing information:
• intra-area routes - routes generated from within an area (destination belongs to the area).
• inter-area routes - routes originated from other areas, also called Summary Routes.
• external routes - routes originated from other routing protocols and that are injected into OSPF by
redistribution.
Backbone area is the core of all OSPF network, all areas have to be connected to backbone area. Start configuring
OSPF from backbone and then expand network configuration to other areas.
R1 configuration:
R2 configuration:
R3 configuration:
Route Redistribution
OSPF external routes are routes that are being redistributed from other routing protocols or from static routes.
Remember OSPF configuration setup described in previous section. As you may notice networks 10.0.1.0/24 and
10.0.4.0/24 are not redistributed into OSPF. OSPF protocol does not redistribute external routes by default.
Redistribution should be enabled in general OSPF configuration menu to do that. We need to redistribute connected
routes in our case, add following configuration to routers R3 and R2:
10.0.5.0/24 and 10.0.4.0/24 networks are redistributed from R3 over OSPF now. But we do not want other routers to
know that 10.0.5.0/24 is reachable over router R3. To achieve it we can add rules in routing filters inside "ospf-out"
chain.
Add routing filter to R3
Routing filters provide two chains to operate with OSPF routes: ospf-in and ospf-out. Ospf-in chain is used to filter
incoming routes and ospf-out is used to filter outgoing routes. More about routing filters can be found in routing
filters reference manual.
Virtual Link
All OSPF areas have to be attached to the backbone area, but sometimes physical connection is not possible. In this
case areas can be attached logically by using virtual links. Also virtual links can be used to glue together
fragmented backbone area.
R1 configuration:
R2 configuration:
Partitioned backbone
Route Summarization
Route summarization is consolidation of multiple routes into one single advertisement. It is normally done at the area
boundaries (Area Border Routers), but summarization can be configured between any two areas.
It is better to summarize in the direction to the backbone. Then way the backbone receives all the aggregate
addresses and injects them into other areas already summarized. There are two types of summarization: inter-area
and external route summarization.
Stub Area
Main purpose of stub areas is to keep such areas from carrying external routes. Routing from these areas to the
outside world is based on a default route. Stub area reduces the database size inside an area and reduces memory
requirements of routers in the area.
Manual:OSPF Case Studies 164
R2 configuration:
R3 configuration:
NSSA
Manual:OSPF Case Studies 165
R2 configuration:
NSSA areas have one another limitation: virtual links cannot be used over such area type.
Related Links
• OSPF Configuration Examples
• OSPF Reference Manual
Manual:OSPF-examples 166
Manual:OSPF-examples
Simple OSPF configuration
The following example illustrates how to configure single-area OSPF network. Let’s assume we have the following
network.
Example network consists of 3 routers connected together within 10.10.1.0/24 network and each router has also one
additional attached network.
In this example following IP addresses are configured:
R2:
R3:
As you can see router-id is 0.0.0.0, it means that router will use one of router's IP addresses as router-id. In most
cases it is recommended to set up loopback IP address as router-id. Loopback IP address is virtual, software address
that is used for router identification in network. The benefits are that loopback address is always up (active) and can’t
be down as physical interface. OSPF protocol used it for communication among routers that identified by router-id.
Loopback interface are configured as follows:
Create bridge interface named, for example, “loopback”:
Add IP address:
And the last step is to add network to the certain OSPF area.
On R1
Instead of typing in each network, you can aggregate networks using appropriate subnet mask. For example, to
aggregate 10.10.1.0/30, 10.10.1.4/30, 10.10.1.8/30 networks, you can set up following ospf network:
R2:
R3:
• Check your OSPF neighbors, what DR and BDR is elected and adjacencies established:
• Check router’s routing table (make sure OSPF routes are present):
Lets assume that IP addresses are already configured and default OSPF instance is enabled.
All we need to do is:
• create an area
• attach OSPF networks to the area
R1 configuration:
R2 configuration:
R3 configuration:
Manual:OSPF-examples 169
R4 configuration:
Now you can check routing table using command /ip route print
Routing table on router R3:
As you can see remote networks 172.16.0.0/16 and 192.168.2.0/24 are not in the routing table, because they are not
distributed by OSPF. Redistribution feature allows different routing protocols to exchange routing information
making possible, for example, to redistribute static or connected routes into OSPF. In our setup we need to
redistribute connected network. We need to add following configuration on routers R1, R2 and R3.
Now check router R3 to see if routes 192.168.2.0/24 and 172.16.0.0/16 are installed in routing table.
NBMA networks
OSPF network type NBMA (Non-Broadcast Multiple Access) uses only unicast communications, so it is the
preferred way of OSPF configuration in situations where multicast addressing is not possible or desirable for some
reasons. Examples of such situations:
• in 802.11 wireless networks multicast packets are not always reliably delivered (read Multicast_and_Wireless for
details); using multicast here can create OSPF stability problems;
• using multicast may be not efficient in bridged or meshed networks (i.e. large layer-2 broadcast domains).
Especially efficient way to configure OSPF is to allow only a few routers on a link to become the designated router.
(But be careful - if all routers that are capable of becoming the designated router will be down on some link, OSPF
will be down on that link too!) Since a router can become the DR only when priority on it's interface is not zero, this
priority can be configured as zero in interface and nbma-neighbor configuration to prevent that from happening.
(For simplicity, to keep configuration the same on all routers, nbma-neighbor to self is also added. Normally you
wouldn't do that, but it does not cause any harm either.)
Configure interface priorities. On routers A, B:
Results
On Router A:
On Router D:
Manual:Routing/BGP
Applies to RouterOS: v3, v4 +
Summary
The Border Gateway Protocol (BGP) allows setting up an interdomain dynamic routing system that automatically
updates routing tables of devices running BGP in case of network topology changes.
MikroTik RouterOS supports BGP Version 4, as defined in RFC 4271
Standards and Technologies:
• RFC 4271 Border Gateway Protocol 4
• RFC 4456 BGP Route Reflection
• RFC 5065 Autonomous System Confederations for BGP
• RFC 1997 BGP Communities Attribute
• RFC 2385 TCP MD5 Authentication for BGPv4
• RFC 5492 Capabilities Advertisement with BGP-4
• RFC 2918 Route Refresh Capability
• RFC 4760 Multiprotocol Extensions for BGP-4
• RFC 2545 Use of BGP-4 Multiprotocol Extensions for IPv6 Inter-Domain Routing
• RFC 4893 BGP Support for Four-octet AS Number Space
Instance
Sub-menu: /routing bgp instance
Property Description
client-to-client-reflection (yes | in case this instance is a route reflector: whether to redistribute routes learned from one routing reflection client to
no; Default: yes) other clients
cluster-id (IP address;) in case this instance is a route reflector: cluster ID of the router reflector cluster this instance belongs to. This
attribute helps to recognize routing updates that comes from another route reflector in this cluster and avoid
routing information looping. Note that normally there is only one route reflector in a cluster; this case 'cluster-id'
does not need to be configured and BGP router ID is used instead
confederation (integer: in case of BGP confederations: autonomous system number that identifies the [local] confederation as a whole
0..4294967295;)
confederation-peers (integer: in case of BGP confederations: list of BGP peers internal to the [local] confederation
0..4294967295;)
ignore-as-path-len (yes | no; whether to ignore AS_PATH attribute in BGP route selection algorithm
Default: no)
out-filter (string;) the output routing filter used by all BGP peers belonging to this instance
redistribute-connected (yes | if enabled, this BGP instance will redistribute the information about connected routes, i.e., routes to the networks
no; Default: no) that can be directly reached
Manual:Routing/BGP 173
redistribute-ospf (yes | no; if enabled, this BGP instance will redistribute the information about routes learned by OSPF
Default: no)
redistribute-other-bgp (yes | if enabled, this BGP instance will redistribute the information about routes learned by other BGP instances
no; Default: no)
redistribute-rip (yes | no; if enabled, this BGP instance will redistribute the information about routes learned by RIP
Default: no)
redistribute-static (yes | no; if enabled, the router will redistribute the information about static routes added to its routing database, i.e., routes
Default: no) that have been created using the '/ip route add' command on the router
router-id (IP address; Default: the BGP Router ID (for this instance). If not specified, BGP will use one of router's IP addresses.
0.0.0.0)
routing-table (string; Default: ) Name of routing table this BGP instance operates on. Non-default routing-table and list of VRFs cannot be
configured for the same instance at the same time. Available starting from v4.3
Peer
Sub-menu: /routing bgp peer
Property Description
address-families (ip | ipv6 | l2vpn | list of address families about which this peer will exchange routing information. The remote peer must support
l2vpn-cisco | vpnv4; Default: ip) (they usually do) BGP capabilities optional parameter to negotiate any other families than IP
allowas-in (string;)
as-override (yes | no;) If set, then all instances of remote peer's AS number in BGP AS PATH attribute are replaced with local AS
number before sending route update to that peer. Happens before routing filters and prepending.
hold-time (time; Default: ) specifies the BGP Hold Time value to use when negotiating with peers. According to the BGP specification, if
router does not receive successive KEEPALIVE and/or UPDATE and/or NOTIFICATION messages
within the period specified in the Hold Time field of the OPEN message, then the BGP connection to the peer
will be closed. The minimal hold-time value of both peers will be actually used (note that the special value 0
or 'infinity' is lower than any other values)
• infinity - never expire the connection and never send keepalive messages.
in-filter (string;) name of the routing filter that is applied to the incoming routing information
interface (string | unspecified; if specified, then outgoing connection will be made using only this interface; socket is directly bind to
Default: unspecified) specified interface. Important if you want to run BGP using IPv6 link-local addresses. Do not specify name of
interface that is added as a bridge port here!
max-prefix-limit (integer;) maximum number of prefixes to accept from a specific peer. When this limit is exceeded, TCP connection
between peers is tear down
max-prefix-restart-time (time 1 minimum time interval after which peers can reestablish BGP session.
minute .. 10 days | infinity; Default: • infinity - session is not reestablished until administrator's intervention.
infinity)
Manual:Routing/BGP 174
multihop (yes | no; Default: no) specifies whether the remote peer is more than one hop away.
This option affects outgoing nexthop selection as described in RFC 4271 (for EBGP only, excluding EBGP
peers local to the confederation). It also affects
• whether to accept connections from peers that are not in the same network (the remote address of the
connection is used for this check);
• whether to accept incoming routes with NEXT_HOP attribute that is not in the same network as the
address used to establish the connection;
• the target-scope of the routes installed from this peer; routes from multi-hop or IBGP peers resolve their
nexthops through IGP routes by default.
nexthop-choice (default | force-self Affects the outgoing NEXT_HOP attribute selection. Note that nexthops set in filters always takes
| propagate; Default: default) precedence. Also note that nexthop is not changed on route reflection, expect when it's set in filter.
• default - select the nexthop as described in RFC 4271
• force-self - always use a local address of the interface that used to connect to the peer as the nexthop;
• propagate - try to propagate further the nexthop received; i.e. if the route has BGP NEXT_HOP attribute,
then use it as the nexthop, otherwise fall back to the default case
out-filter (string;) name of the routing filter that is applied to the outgoing routing information, if instance has also configured
out-filter, then first will be applied instance filters and only then peer's filters.
passive (yes | no;) If set to yes, then connection attempts to remote peer are not made. The remote peer must initialize connection
in this case. Available starting from v4.3
remove-private-as (yes | no; If set, then if BGP AS PATH attribute contains only private AS numbers, the attribute is removed before
Default: ) sending out route update. The removing happens before routing filters are applied and before local AS number
is prepended to the AS path. Available starting from v4.3
route-reflect (yes | no; Default: no) specifies whether this peer is route reflection client
tcp-md5-key (string;) key used to authenticate the connection with TCP MD5 signature as described in RFC 2385
ttl (integer: 1..255 | default; Time To Leave, the hop limit for TCP connection. For example, if 'ttl=1' then only single hop neighbors will
Default: default) be able to establish the connection. This property only affects EBGP peers.
• default - system's default TTL value is used
update-source (IP address | If address is specified, this address is used as the source address of the outgoing TCP connection.
interface name;) If interface name is specified, an address belonging to the interface is used as described.
This property is ignored, if the value specified is not a valid address of the router or name an interface with
active addresses. Do not specify name of interface that is added as a bridge port here!
Property Description
uptime (time) how long the connection has been in established state
prefix-count (integer) number routing prefixes received from this peer currently in routing table
state (idle | connect | active | opensent | openconfirm | established) BGP protocol state
Advertisements
Sub-menu: /routing bgp advertisements
Read only information about outgoing routing information currently advertised.
This information is calculated dynamically after 'print' command is issued. As a result, it may not correspond to the
information that at the exact moment has been sent out. Especially if in case of slow connection, routing information
prepared for output will spend long time in buffers. 'advertisements print' will show as things should be, not as they
are!
Note: At the moment AS-PATH attribute for advertised routes is shown without prepends.
Property Description
origin (igp | egp | incomplete) the ORIGIN attribute value sent out
Network
Sub-menu: /routing bgp network
BGP network configuration. BGP Networks is a list of IP prefixes to be advertised.
Property Description
synchronize (yes | no; Default: no) install a route for this network only when there is an active IGP route matching this network
Aggregate
Sub-menu: /routing bgp aggregate
BGP allows the aggregation of specific routes into one route with. This menu ('/routing bgp aggregate') allows to
specify which routes you want to aggregate, and what attributes to use for the route created by aggregation.
Property Description
advertise-filter (string;) name of the filter chain used to select the routes from which to inherit attributes
attribute-filter (string;) name of the filter chain used to set the attributes of the aggregate route
include-igp (yes | no; Default: ) By default, BGP aggregate takes into account only BGP routes. Use this option to take IGP and connected
routes into consideration.
inherit-attributes (yes | no; Default: whether to inherit BGP attributes from aggregated routes
yes)
summary-only (yes | no; Default: whether to suppress advertisements of all routes that fall within the range of this aggregate
yes)
suppress-filter (string;) name of the filter chain used to select the routes to be suppressed
Terminology
• aggregated routes - all routes, that fall within the range of this aggregate; they possibly are suppressed;
• aggregate route - route created by aggregation.
Note: Each aggregate will only affect routes coming from peers that belong to it's instance. suppress-filter is
useful only if summary-only=no; advertise-filter is useful only if inherit-attributes=yes.
If result attribute-filter match reject or discard, the aggregate route is not created.
Manual:Routing/BGP 177
Vpnv4 route
Sub-menu: /routing bgp vpnv4-route
Read only information about vpnv4 routing information currently advertised.
Property Description
bgp-communities (;)
bgp-ext-communities (string;)
bgp-prepend (string;)
bgp-weight (string;)
dst-address (string;)
gateway (string;)
interface (string;)
route-distinguisher (string;)
[Back to Content]
Manual:BGP based VPLS 178
Example network
Consider the same network as used for LDP signaled VPLS example in MPLSVPLS:
The requirements of customers A and B are the same - ethernet segments must be transparently connected. Taking
into account simplicity of given network topology Service Provider has decided to use R5 as route reflector and to
have no backup route reflector. Consider that MPLS switching is configured and running, as discussed in
MPLSVPLS, but no any VPLS configuration has been applied yet. the rest of this document deals with specifics that
are introduced by use of BGP for VPLS signaling.
To enable VPLS NLRI delivery across BGP, BGP multiprotocol capability must be used. This is enabled by
specifying l2vpn in BGP peer's address-families setting.
For example, to configure BGP connection between R1 and R5, the following commands should get issued.
On R1:
[admin@R1] /routing bgp peer> add remote-address=9.9.9.5 remote-as=65530 address-families=l2vpn \
update-source=lobridge
and on R5:
Manual:BGP based VPLS 180
BGP connection should get established between R1 and R5. This can be confirmed by:
[admin@R1] /routing bgp peer> print status
Flags: X - disabled
0 name="peer1" instance=default remote-address=9.9.9.5 remote-as=65530 tcp-md5-key=""
nexthop-choice=default multihop=no route-reflect=no hold-time=3m ttl=255 in-filter=""
out-filter="" address-families=l2vpn update-source=lobridge remote-id=4.4.4.5
local-address=9.9.9.1 uptime=3s prefix-count=0 updates-sent=0 updates-received=0
withdrawn-sent=0 withdrawn-received=0 remote-hold-time=3m used-hold-time=3m
used-keepalive-time=1m refresh-capability=yes state=established
To enable R5 to operate as route reflector, all its peers should get added with route-reflect=yes setting. So to enable
proper VPLS NLRI distribution, R5 must be configured with 2 BGP peers - R1 and R4:
[admin@R5] /routing bgp peer> print status
Flags: X - disabled
0 name="peer1" instance=default remote-address=9.9.9.1 remote-as=65530 tcp-md5-key=""
nexthop-choice=default multihop=no route-reflect=yes hold-time=3m ttl=255 in-filter=""
out-filter="" address-families=l2vpn update-source=lobridge remote-id=1.1.1.1
local-address=9.9.9.5 uptime=5m55s prefix-count=0 updates-sent=0 updates-received=0
withdrawn-sent=0 withdrawn-received=0 remote-hold-time=3m used-hold-time=3m
used-keepalive-time=1m refresh-capability=yes state=established
and on R4:
[admin@R4] /routing bgp peer> print status
Flags: X - disabled
0 name="peer1" instance=default remote-address=9.9.9.5 remote-as=65530 tcp-md5-key=""
nexthop-choice=default multihop=no route-reflect=no hold-time=3m ttl=255 in-filter=""
out-filter="" address-families=l2vpn update-source=lobridge remote-id=4.4.4.5
local-address=9.9.9.4 uptime=3s prefix-count=0 updates-sent=0 updates-received=0
withdrawn-sent=0 withdrawn-received=0 remote-hold-time=3m used-hold-time=3m
used-keepalive-time=1m refresh-capability=yes state=established
Using route reflector means that in order to add new site to some VPLS, e.g. connected by router Ry, would mean
adding Ry as BGP peer to R5 (with route-reflect=yes setting) and adding R5 as BGP peer to Ry.
Manual:BGP based VPLS 182
Note: Since v3.20 vpls-id was replaced with separate import/export-route-targets to provide more flexibility.
route-distinguisher setting specifies value that gets attached to VPLS NLRI so that receiving routers can distinguish
advertisements that may otherwise look the same. This implies that unique route-distinguisher for every VPLS must
be used. It is not necessary to use the same route distinguisher for some VPLS on all routers forming that VPLS as
distinguisher is not used for determining if some BGP NLRI is related to particular VPLS (Route Target attribute is
used for this), but it is mandatory to have different distinguishers for different VPLSes.
export-route-targets setting is used for tagging BGP NLRI
import-route-targets setting is used to determine if BGP NLRI is related to particular VPLS
Manual:BGP based VPLS 183
site-id setting must be unique among members of particular VPLS. It is advisable although not mandatory to allocate
site-id values in as narrow range as possible as that increases efficency of BGP (for details see RFC 4761).
bridge setting specifies bridge to which dynamically created VPLS tunnels should get added.
bridge-horizon specifies horizon value to be used for ports added to bridge (see Split horizon bridging discussion in
MPLSVPLS).
According to above commands, VPLS for customer A is assigned vpls-id 100:1 and VPLS for customer B is
assigned vpls-id 100:2
After configuring R4 as member of VPLS 100:1 (used for customer A) with command:
[admin@R4] /interface vpls bgp-vpls> add bridge=A bridge-horizon=1 route-distinguisher=1:1 \
site-id=4 import-route-targets=1:1 export-route-targets=1:1
Dynamic VPLS tunnel gets created on both R1 and R4. On R1 this can be confirmed:
Here we have confirmed also that route reflection as configured on R5 works as expected as there is no BGP peer
relationship between R1 and R4.
Additionally we must configure R5 to participate in VPLS for customer A:
[admin@R5] /interface vpls bgp-vpls> add bridge=A bridge-horizon=1 route-distinguisher=1:1 \
site-id=5 import-route-targets=1:1 export-route-targets=1:1
This causes R1 and R4 to establish additional VPLS tunnel with R5. For example on R1:
2 D vpls1 A 0x80 50 1
3 D vpls2 A 0x80 50 1
To complete the setup, necessary configuration for customer B VPLS should be applied to R5:
As the result we get full mesh of VPLS tunnels established, for example on R5:
Note that remote-peer for VPLS tunnels is BGP NextHop address as received in BGP Update. For example BGP
logs on R5 when receiving Update for VPLS 2:2 (customer B), say:
11:24:06 route,bgp,debug,packet UPDATE Message
11:24:06 route,bgp,debug,packet RemoteAddress=9.9.9.1
11:24:06 route,bgp,debug,packet MessageLength=79
11:24:06 route,bgp,debug,packet
11:24:06 route,bgp,debug,packet PathAttributes
11:24:06 route,bgp,debug,packet bgp-origin=INCOMPLETE
11:24:06 route,bgp,debug,packet bgp-nexthop=9.9.9.1
11:24:06 route,bgp,debug,packet bgp-localpref=100
11:24:06 route,bgp,debug,packet bgp-extended-communities=RT:100:2
11:24:06 route,bgp,debug,packet
11:24:06 route,bgp,debug,packet NLRI= rd
11:24:06 route,bgp,debug,packet type=0
11:24:06 route,bgp,debug,packet administrator=2
11:24:06 route,bgp,debug,packet assigned-number=2 veId=1 veBlockOffset=0 veBlockSize=16
labelBase=40
This is reflected for dynamic VPLS tunnel, where remote-peer for tunnel with vpls-id 100:2 is 9.9.9.1. This implies
that R5 uses IGP route that leads to 9.9.9.1 to decide what transport label to use. In given case there are /32 IGP
routes distributed in the network by means of OSPF, therefore:
igp-nexthop: 4.4.4.3
imposed-labels: 17,45
Shows that 9.9.9.1/32 route is used and immediate nexthop is 4.4.4.3. Labels attached to VPLS packets are 17 and 45
where 45 is label mapping received with BGP Update, and 17 is label assigned by R3 for prefix 9.9.9.1/32:
Problem: BGP session has been established, but routing updates are ignored
NLRI (Network Layer Reachability Information) is ignored if path attributes are invalid. Turn on BGP debug logs to
see the exact cause of the problem. (/system logging add topics=bgp,!raw).
One frequent case is unacceptable BGP next-hop. (Read here more about RouterOS and BGP next-hops.) In this case
you must fix the next-hop on the sending side. In case the sender also is MT, you can use nexthop-choice peer
setting to modify default next-hop selection preferences. If that fails, specify next-hop manually using
set-out-nexthop routing filter.
You can also search routes by other attributes, but it will be much slower and can take some time on a router having
full BGP feed.
For example, since RouterOS 3.23 you can use this syntax to match routes having originated from a specific AS
30621:
Manual:BGP HowTo & FAQ 186
Problem: Routes are exchanged and installed in IP route table, but they stay inactive
Routes must be resolved to become active; it's possible that you need to change scope or target-scope attributes for
some routes.
There is also an out-filter BGP peer parameter for filtering outgoing BGP updates.
In recent RouterOS versions bgp-as-path filter accepts regular expressions. Community filtering by regular
expressions is not yet possible.
Question: How to quickly check how many routes there are in route table?
For all routes use:
To see route count from a particular peer look at prefix-count property in:
Question: How to seen routes advertised to, and routes received from a particular peer?
To see routes advertised to a particular peer (similar to Cisco command show ip bgp neighbor x.x.x.x
advertised-routes) use:
Or
To see routes received from a particular peer (similar to Cisco command show ip bgp neighbor
x.x.x.x received-routes) use:
Note: Routes that were discarded (with action discard) in incoming filters, or ignored because of invalid
attributes (e.g. not directly reachable next-hop for EBGP) will not be displayed!
Yes. Even though BGP itself cannot propagate multiple next-hops for a single route through the
network, there are ways how to have routes with multiple next-hops on a router.
One way is to set multiple next-hops with routing filter.
Another way is to resolve BGP next-hop (if it is not directly reachable) through a static or OSPF route with multiple
next-hops.
To send routing information to different peers, use peer specific filters. For example, if you want to advertise a lower
preference value (higher path cost) to one of the peers, you can prepend your AS number multiple times to the BGP
AS_PATH attribute:
Use /routing bgp advertisements print to see what routing information exactly is advertised to peers.
Manual:BGP HowTo & FAQ 188
This rule is incorrect (default netmask is /32, so it will match only prefix 1.1.1.0/32):
This is incorrect too (because it will match only route with netmask 255.255.255.0)
Use filter action log to see which routes are matched by a routing filter.
Question: How to announce just a single large IP prefix instead of many smaller (i.e. more specific) prefixes?
Use BGP aggregates if you need to aggregate multiple routes in a single one. An aggregate will be announced one if
there are some active routes with more specific netmasks falling under it. When an aggregate becomes active, a
corresponding blackhole route is a automatically created.
By default, BGP aggregates take in account only BGP routes. To also include IGP and connected routes in
consideration, use include-igp configuration option.
Results:
[admin@MikroTik] > routing bgp advertisements print
Use routing filters to control which routes are aggregated. For example, if you don't want to aggregate connected
routes:
Problem: Routes are announced, but with attributes not from IP routing table
There exists a limitation in MT BGP operation: if a BGP network with synchronization turned off, or default route
generated by default-originate=always configuration statement is announced, the attributes of that route will not be
taken from routing table.
If synchronize=yes or default-originate=if-installed is used, the attributes of the announced route will be taken
from routing table.
Question: Can MT propagate BGP route updates without installing them in IP route table (i.e. serve as a pure
route reflector)?
No, it's not possible.
Question: How much memory is required to keep the global BGP route table?
Our recommendations are at least 256 MB RAM for a single copy of the table and at least 512 MB RAM for two or
three copies.
Assuming the Internet route table size ~300 000 routes, for the first copy of the table, with routes resolved and
active, about 155 MB extra memory is needed. This is only for the first copy specifically, the amount of RAM
needed for each additional copy of the table is significantly less than that number.
RAM usage on RB1000 (BGP feed size 301 480 routes, no redistribution):
• No BGP routes: 26 MB
• Single copy: 181 MB
• Two copies: 241 MB
• Three copies: 299 MB
Memory requirements will increase if incoming routing filters that change route attributes are used. That happens
because unchanged copy of the route attributes received also will be stored in RAM, to be used in case of later
routing filter change.
The requirements will also increase depending on count of peers to which routes are advertised.
It is not recommended to turn on SNMP on routers with full BGP feed!
Manual:BGP soft reconfiguration alternatives in RouterOS 190
Static soft-reconfiguration
What could be the effect of routing filters to a route? There are two possible cases.
CASE 1: Filters only change some attributes of the route. The orginal received attributes always are stored with the
route. They are use to calculate new routing table attributes if filters changes. This process is trigerred automatically.
CASE 2: The route is discarded by filters. If the route is discarded, original attributes are not saved and information
about it is lost. To avoid that, use action=reject in filters instead of action=discard. Now the route is saved, but is
not eligible to become active (that is, it will not be installed in kernel routing table or redistributed to protocols).
• + Router does not lose routing information, because session is not reset.
• - Memory overhead for storing rejected routes.
Example:
Original configuration (routes are rejected):
[admin@A] > routing filter add chain=bgp-in action=reject prefix=4.0.0.0/8 prefix-length=8-32
[admin@A] > routing bgp peer set peer1 in-filter=bgp-in
[admin@A] > ip route print
Flags: X - disabled, A - active, D - dynamic,
C - connect, S - static, r - rip, b - bgp, o - ospf,
B - blackhole, U - unreachable, P - prohibit
# DST-ADDRESS PREF-SRC G GATEWAY DISTANCE INTERFACE
0 A S 0.0.0.0/0 10.0.0.1 1 ether1
1 ADb 3.0.0.0/8 192.65.184.3 200 ether1
2 Db 4.0.0.0/8 192.65.184.3 20 ether1
3 Db 4.21.104.0/24 192.65.184.3 20 ether1
4 Db 4.21.112.0/23 192.65.184.3 20 ether1
5 Db 4.21.130.0/23 192.65.184.3 20 ether1
Dynamic soft-reconfiguration
In this case, your BGP routing peer must support route refresh capability. Enter /routing bgp peer print status in
CLI to check this.
• + No additional memory is used
• - Peer must support this capability.
• - It's not done automatically. You must issue /routing bgp peer refresh command after changes in filters are
finished.
Example:
Original configuration (routes are discarded):
[admin@A] > routing filter add chain=bgp-in action=reject prefix=4.0.0.0/8 prefix-length=8-32
[admin@A] > ip route pr
Flags: X - disabled, A - active, D - dynamic,
C - connect, S - static, r - rip, b - bgp, o - ospf,
B - blackhole, U - unreachable, P - prohibit
# DST-ADDRESS PREF-SRC G GATEWAY DISTANCE INTERFACE
0 A S 0.0.0.0/0 10.0.0.1 1 ether1
1 ADb 3.0.0.0/8 192.65.184.3 200 ether1
Summary
• Do nothing unless the filter change changes discard status for some prefixes.
• Use routing bgp peer refresh comand after filter change if peer supports this capability.
• Use action=reject in filters in other cases.
NB: RouterOS version 3.13 or later with routing-test package is required for this to work
In these examples we show how to do load balancing when there are multiple equal cost links between
two BGP routers. The "multiple recursive next-hop resolution" feature is used to achieve that.
The BGP session is established between loopback interfaces; update-source configuration setting is used to bind the
BGP connection to the right interface.
Network Diagram
Configuration
On Router A:
# loopback interface
/interface bridge add name=lobridge
# addresses
/ip address add address=1.1.1.1/24 interface=ether1
/ip address add address=2.2.2.1/24 interface=ether2
/ip address add address=9.9.9.1/32 interface=lobridge
# BGP
Manual:BGP Load Balancing with two interfaces 193
On Router B:
# loopback interface
/interface bridge add name=lobridge
# addresses
/ip address add address=1.1.1.2/24 interface=ether1
/ip address add address=2.2.2.2/24 interface=ether2
/ip address add address=9.9.9.2/32 interface=lobridge
# BGP
/routing bgp instance set default as=65000
/routing bgp add name=peer1 remote-address=9.9.9.1 remote-as=65000 update-source=lobridge
# a route to advertise
/routing bgp network add network=4.4.4.0/24
Results
Check that BGP connection is established:
r 2.2.2.2 ether2
The route 4.4.4.0./24 is installed in Linux kernel now with two nexthops: 1.1.1.2 (on ether1) and 2.2.2.2 (on ether2).
Network Diagram
Configuration
Here the example given above is further developed for eBGP case. By default, eBGP peers are required to be directly
reachable. If we are using loopback interfaces, they technically are not, so multihop=yes configuration setting must
be specified.
On Router A:
/routing bgp instance set default as=65000
/routing bgp set peer1 remote-address=9.9.9.2 remote-as=65001 update-source=lobridge multihop=yes
On Router B:
/routing bgp instance set default as=65001
/routing bgp set peer1 remote-address=9.9.9.1 remote-as=65000 update-source=lobridge multihop=yes
Manual:BGP Load Balancing with two interfaces 195
Results
If we now print the route table on Router A, we see that the route from Router B is there, but it's not active:
...
2 Db dst-address=4.4.4.0/24 gateway=9.9.9.2 interface="" gateway-state=unreachable
distance=20 scope=40 target-scope=10 bgp-as-path="65001" bgp-origin=igp
received-from=9.9.9.2
...
This is because eBGP routes are installed with lesser target-scope by default. To solve this, setup routing filter that
sets larger target-scope:
Notes
• BGP itself as protocol does not supports ECMP routes. When a recursively resolved BGP route is propagated
further in the network, only one nexthop can be selected (as described here) and included in the BGP UPDATE
message.
• Corresponding Cisco syntax can be found here: Load Sharing with BGP in Single and Multihomed Environments:
Sample Configurations [1]
References
[1] http:/ / www. cisco. com/ en/ US/ tech/ tk365/ technologies_configuration_example09186a00800945bf. shtml
Manual:Routing/MME 196
Manual:Routing/MME
Applies to RouterOS: v3, v4+
Summary
Sub-menu: /routing mme
Packages required: routing
MME (Mesh Made Easy) is a MikroTik routing protocol suited for IP level routing in wireless mesh networks. It is
based on ideas from B.A.T.M.A.N. (Better Approach To Mobile Ad-hoc Networking) routing protocol.
This is MME configuration reference only; for description of the protocol and configuration examples see
Manual:MME wireless routing protocol.
General Setup
Property Description
origination-interval (time; Default: 5s) Interval between originator messages. Obviously, this value should be less than timeout value.
timeout (time; Default: 1m) Node timeout. If no messages at all are received from an originator node during this interval, that
node is purged from protocol tables, and so are all routes it has announced.
bidirectional-timeout (integer; Default: 2) How many originator messages from a node can be lost in sequence, while still considering it a
bidirectional neighbor. We are assuming that every node originates messages with the same rate as
this router (i.e. the value from origination-interval).
ttl (integer; Default: 50) How many times to forward originator messages.
gateway-class (none | 56-KBit | 64-KBit | Announce internet gateway capability in the originator messages sent by this node.
128-KBit | 256-KBit | 512-KBit | 1-MBit |
2-MBit | 3-MBit | 5-MBit | 6-MBit | >6-MBit |
integer; Default: none)
gateway-keepalive (time; Default: 1m) The time interval between successive gateway keepalive messages. For gateway client, this
specifies how often to send out keepalive messages. For gateway server, as client hold time is used
3 * gateway-keepalive seconds. If the server does not receive keepalive messages from a client
during this time interval, the client is considered dead. All state information associated with it are
deleted, including the dynamic IPIP tunnel.
preferred-gateway (IP; Default: 0.0.0.0) Always prefer this node as internet gateway to any others, if it is present in originator tables.
Note: The node running MME with gateway-class option is supposed to have a link to Internet and a default
route to that.
The symbolic values of gateway-class are compatible with B.A.T.M.A.N. This table describes the
mapping from integers to symbolic values:
• 0 no gateway
Manual:Routing/MME 197
• 1 modem
• 2 ISDN
• 3 Double ISDN
• 4 256 KBit
• 5 UMTS/ 0.5 MBit
• 6 1 MBit
• 7 2 MBit
• 8 3 MBit
• 9 5 MBit
• 10 6 MBit
• 11 >6 MBit
Entering integer value > 11 means even better gateway class.
Interfaces
Sub-menu: /routing mme interface
List of interfaces on which to run the MME protocol.
Property Description
passive (yes | no ; If true, do not send originator messages via this interface, only receive.
Default: no)
primary (yes | no Include routing information (i.e. network announcements) in self-originated packets send via this interface. (For forwared
; Default: no) packets the information is always included.) Only one interface can be primary. If no interfaces are configured as primary, one
is selected automatically in a random fashion.
Command /routing mme interface print status allows to view status of interfaces.
Property Description
messages-tx (integer) Originator messages transmitted via this interface. For all interface: cumulative statistics
messages-rx (integer) Originator messages received via this interface. For all interface: cumulative statistics.
Networks
Sub-menu: /routing mme network
MME Networks is a list of networks to be advertised.
Property Description
Note: The usage of MME networks is similar to BGP networks, and different from IGP (i.e. RIP and OSPF)
networks. They determine which networks to announce via MME, not on which networks to run the protocol.
Originators
Sub-menu: /routing mme originators
This submenu contains information about active neighbor nodes.
Manual:Routing/MME 198
Property Description
gateway-class (none | 56-KBit | 64-KBit | 128-KBit | 256-KBit | 512-KBit | If none, then this node is not a gateway server. Otherwise this node
1-MBit | 2-MBit | 3-MBit | 5-MBit | 6-MBit | >6-MBit | integer) is a gateway server with specified gateway bandwidth.
[Back to Content]
Overview
MME (Mesh Made Easy) is a MikroTik routing protocol suited for IP level routing in wireless mesh networks. It is
based on ideas from B.A.T.M.A.N. (Better Approach To Mobile Ad-hoc Networking) routing protocol. See https:/ /
www.open-mesh.net for more information about B.A.T.M.A.N.
MME works by periodically broadcasting so called originator messages. Routing information contained in a message
consists of IP address of it's originator and optional list of IP prefixes - network announcements. If a node receives
an originator message it hasn't seen before, it rebroadcasts that message. (There also are some other cases when the
message can be rebroadcasted - see below.)
Unlike OLSR or other "traditional" proactive routing protocols, MME does not maintain network topology
information. Consequently, MME is not able to calculate routing table, and does not need to. Instead, it keeps tracks
of packets received and their sequence numbers - to tell how many packets were lost. This way, from message loss
statistics for all combinations of originators and single-hop neighbors, MME is able to find the best gateway to a
particular destination.
The main ideas behind MME are based on these observations made in mobile mesh networks:
• it can be impossible to know the exact topology of all network, because it is rapidly changing;
• if topology changes trigger routing table recalulation for all nodes in the network; and for embedded systems, the
routing table calculation CPU overhead can be significant.
To avoid these problems, a MME node:
• cares only about the best single-hop neighbor in path to a particular destination;
• avoids routing table calculations.
Secondary functions of the MME protocol are: to carry information about gateways to the Internet, and to
dynamically setup default routes. The part of MME responsible for that is dubbed "the gateway protocol".
MME protocol is using UDP port 1966 for originator message traffic. The gateway protocol is using TCP port 1968.
It is assumed in a normal operation of the protocol, a large number of these messages will get lost due to bad link
quality. This assumption is important if we are talking about protocol overhead. Theoretically protocol's own traffic
consumption is at least as big as for RIP, and obvioulsy worse than that of link state routing protocols (OSPF,
OLSR) unless the topology is constantly changing.
Manual:MME wireless routing protocol 199
Technical side
Basic principles of the main protocol
The main functions of the MME protocol are:
• automatic neighbor MME router (so called "originator") discovery (including multihop neighbors);
• originator message origination and flooding on each interface in every origination-interval seconds;
• originator message rebroadcasting based on a few simple rules;
• best gateway selection for each originator and the routes it has advertised.
Originator message rebroadcasting rules:
• do not rebroadcast self originated messages;
• do not rebroadcast messages that has unidirectional flag set;
• rebroadcast messages from single-hop neighbors; rebroadcast with unidirectional flag set if and only if:
• the neighbor relation is not bidirectional;
• OR the neighbor is not the best gateway to himself (i.e. there exists a better multihop path towards this node).
• rebroadcast messages that are not duplicate; a message is considered duplicate if message with this sequence
number already was received before;
• rebroadcast duplicate messages if and only if:
• they came from a neighbor that is the gateway for the originator;
• the TTL in the packet is equal to last TTL for this neighbor and originator combination.
MME makes routing decisions based no more than last 64 messages received, but this number can be significantly
less in case of packet loss. The node can tell that some packets were lost based on their sequence numbers. The more
originator messages are received from a node, the better the statistics of that node is.
The MME protocol does not incorporate best route selection logic. If the same network information is configured in
two different nodes, there currently is no way how to tell which one to prefer. Both routes will be installed in routing
table and one of the selected in a random fashion. Obviously, such configuration is not recommended.
Packet format
The one and only packet type used in MME is originator message. The message contains:
• originator IP;
• current ttl value;
• sequence number;
• gateway class;
• protocol version;
• host and network announcements (0..n IP prefixes).
Gateway protocol clients and servers also exchange keep-alive messages, but they contain no information and have
undefined format. At the moment, however, a keep-alive message is considered invalid, it if contains fewer than 1 or
more than 6 octets.
Configuration examples
Starting the protocol on a single interface:
To change some attributes for routes learned via MME you can use the mme-in routing filter. Example:
If you want to redistribute some routes via MME, add them to MME networks. Example:
Observe the results (on client). Dynamic IPIP interface should be added automatically:
Default route that goes through this tunnel should be added added automatically:
# loopback interface
On Router C:
On Router D:
/ip address add address=10.3.3.4/24 interface=ether2
# loopback interface
Client's sites
On Router A:
On Router E:
LDP
On Router B:
On Router C:
On Router D:
Setting transport address for LDP is not required, but very recommended. If the address is not set, the router will
pick any address at random, which may be an address belonging to VRF, and as such not connectible from internal P
routers.
Results
[admin@C] > /mpls ldp neighbor print
Flags: X - disabled, D - dynamic, O - operational, T - sending-targeted-hello, V - vpls
# TRANSPORT LOCAL-TRANSPORT PEER SEN ADDRESSES
0 O 10.9.9.2 10.9.9.3 10.1.1.2:0 no 10.1.1.2
10.2.2.2
10.9.9.2
1 10.3.3.4 no
2 O 10.9.9.4 10.9.9.3 10.3.3.4:0 no 10.3.3.4
10.4.4.4
10.9.9.4
BGP
On Router B:
/routing bgp instance vrf add instance=default routing-mark=vrf1 redistribute-connected=yes \
redistribute-ospf=yes
/routing bgp peer add remote-address=10.9.9.3 remote-as=65530 address-families=vpnv4 \
update-source=lobridge
On Router C:
Manual:Layer-3 MPLS VPN example 204
On Router D:
/routing bgp instance vrf add instance=default routing-mark=vrf1 redistribute-connected=yes \
redistribute-ospf=yes
/routing bgp peer add remote-address=10.9.9.3 remote-as=65530 address-families=vpnv4 \
update-source=lobridge
Note that route reflection here is used for the sake of an example. A simpler configuration would work as well - one
where there is a BGP session between B and D and C is not running BGP at all.
Results
Check for routes on PE routers:
and
OSPF
On Router A:
On Router B:
On Router D:
On Router E:
Results
Routing table on CE router A:
Test
On Router A:
Ping from CE1 -> to PE1:
No failures here.
Connecting from PE to CE
In this case routing-table must be specified manually.
Ping from PE1 -> to CE1:
CE1
/ip address add address=10.1.1.1/24 interface=ether1
# static route to redistribute
/ip route add dst-address=10.10.1.0/24 gateway=x.x.x.x
/routing ospf instance set default redistribute-static=as-type-1 router-id=0.0.0.1
/routing ospf network add area=backbone network=1.1.1.0/24
CE2
/ip address add address=10.3.3.4/24 interface=ether1
# static route to redistribute
/ip route add dst-address=10.10.4.0/24 gateway=y.y.y.y
/routing ospf instance set default redistribute-static=as-type-1 router-id=0.0.0.4
/routing ospf network add area=backbone network=10.3.3.0/24
PE1 (Cisco)
ip vrf vrf1
rd 1.1.1.1:111
route-target export 1.1.1.1:111
route-target import 1.1.1.1:111
exit
interface Loopback0
ip address 10.5.5.2 255.255.255.255
interface FastEthernet0/0
ip vrf forwarding vrf1
ip address 10.1.1.2 255.255.255.0
interface FastEthernet1/0
ip address 10.2.2.2 255.255.255.0
mpls ip
PE2
/interface bridge add name=lobridge
/ip address
address-families=vpnv4 update-source=lobridge
domain-id=0.0.0.1 domain-tag=3333
Manual:MPLS/Overview
MPLS Overview
MPLS stands for MultiProtocol Label Switching. It kind of replaces IP routing - packet forwarding decision
(outgoing interface and next hop router) is no longer based on fields in IP header (usually destination address) and
routing table, but on labels that are attached to packet. This approach speeds up forwarding process because next hop
lookup becomes very simple compared to routing lookup (finding longest matching prefix).
Efficiency of forwarding process is the main benefit of MPLS, but it must be taken into account that MPLS
forwarding disables processing of network layer (e.g. IP) headers, therefore no network layer based actions like NAT
and filtering can be applied to MPLS forwarded packets. Any network layer based actions should be taken on ingress
or egress of MPLS cloud, with preferred way being ingress - this way, e.g. traffic that is going to be dropped anyway
does not travel through MPLS backbone.
In the simplest form MPLS can be thought of like improved routing - labels are distributed by means of LDP
protocol for routes that are active and labeled packet takes the same path it would take if it was not labeled. Router
that routes unlabeled packet using some route for which it has received label from next hop, imposes label on packet
and send it to next hop - it gets MPLS switched further along its path. Router that receives packet with label it has
assigned to some route changes packet label with one received from next hop of particular route and sends packet to
next hop. Label switched path ensures delivery of data to the MPLS cloud egress point. Applications of MPLS are
based on this basic MPLS concept of label switched paths.
Another way of establishing label switching path is traffic engineering tunnels (TE tunnels) by means of RSVP TE
protocol. Traffic engineering tunnels allow explicitly routed LSPs and constraint based path selection (where
constraints are interface properties and available bandwidth).
Taking into account complexity, new protocols and applications that MPLS introduces and differences of concepts
that MPLS adds to routed/bridged network, it is recommended to have in depth understanding of MPLS concepts
before implementing MPLS in production network. Some suggested reading material:
• Multiprotocol Label Switching http://en.wikipedia.org/wiki/Multiprotocol_Label_Switching
• RFC3031 Multiprotocol Label Switching Architecture http://www.ietf.org/rfc/rfc3031.txt
• MPLS Fundamentals by Luc De Ghein http://www.amazon.com/MPLS-Fundamentals-Luc-Ghein/dp/
1587051974
Manual:MPLS/Overview 211
Manual:Interface/Virtual-ethernet
Applies to RouterOS: v4.x
Summary
To connect your virtual routers to RouterOS host system you either have to assign interface for your guest (possible
only on MetaROUTER) or you can add virtual Ethernet interface that is described in this document.
May contain either static or dynamic interface. Static interfaces should be configured here if under /kvm interface
(for KVM or /metarouter interface for MetaROUTER. Dynamic interfaces will be recreated automatically each
reboot and will contain new MAC address.
Requirements
This menu becomes available:
• on x86 architeecture you have to have kvm packge installed
• on mipsbe architecture RouterBOARDS
• on ppc architecture RouterBOARDS, except RB333, RB600 and variants.
Property Desciption
copy-from (number) Item number to copy settings from to create new item
mac-address (MAC address MAC address of interface. If automatically generated, then this pattern will be used
default: automatically generated) 02:XX:XX:XX:XX:XX
name (text default: tapX or vifX) Interface name where, if auto-generated, X is inreased if previous valid number already exists,
starts with 1. tap is on x86 vif is on RouterBOARD platform.
See Also
• KVM
• MetaROUTER
Setup
Ilustration below shows simple multihomed BGP setup. This setup can be used for load sharing
between ISPs or one ISP as main and other ISP as backup link.
Manual:Simple BGP Multihoming 214
Lets say that local Internet registry assigned to us two /24 networks: 10.1.1.0/24 and 10.1.2.0/24 and our AS is 30
(Private AS cannot be used in such setups). First network entirely is used for workstations in our corporate network.
Part of the other network is also used for workstation and another part is reserved for server. At this point our
company has only one server with address 10.1.2.130
The goal is advertise our assigned networks to BGP peers and use only one provider as main link, ISP2 link is for
backup only.
Note: This example does not show how to provide connectivity between core router, local networks and
servers
BGP Peering
Consider that IP connectivity between ISPs edge routers and Our Core router is already set up and
working properly. So we can start to establish BGP peering to both ISPs.
If everything is set up properly, peer should have E (established) flag and router should receive bunch of BGP routes
from both ISPs
Manual:Simple BGP Multihoming 215
/routing filter
#accept our networks
add chain=isp1-out prefix=10.1.1.0/24 action=accept
add chain=isp1-out prefix=10.1.2.0/24 action=accept
#discard the rest
add chain=isp1-out action=discard
/routing filter
#accept our networks and prepend AS path three times
add chain=isp2-out prefix=10.1.1.0/24 action=accept set-bgp-prepend=3
add chain=isp2-out prefix=10.1.2.0/24 action=accept set-bgp-prepend=3
#discard the rest
add chain=isp2-out action=discard
We also do not need any routes from both ISPs, because default route is used to force outgoing traffic through ISP1
and leave ISP2 as backup.
/routing filter
add chain=isp1-in action=discard
add chain=isp2-in action=discard
Manual:Simple BGP Multihoming 216
/ip route
add gateway=192.168.1.1 check-gateway=ping
add gateway=192.168.2.1 distance=30 check-gateway=ping
The same as in previous setup BGP AS prepend will be used to achieve our goal. This time we will advertise one of
the netowrks to ISP1 without prepend and another network prepended three times. The opposite for ISP2.
Outgoing filters to ISP1:
/routing filter
#accept our networks and prepend second network
add chain=isp1-out prefix=10.1.1.0/24 action=accept
add chain=isp1-out prefix=10.1.2.0/24 action=accept set-bgp-prepend=3
#discard the rest
add chain=isp1-out action=discard
/routing filter
#accept our networks and prepend first network
add chain=isp2-out prefix=10.1.1.0/24 action=accept set-bgp-prepend=3
add chain=isp2-out prefix=10.1.2.0/24 action=accept
#discard the rest
add chain=isp2-out action=discard
Manual:Simple BGP Multihoming 217
Configuration above is only for packets going to our network. There are several options how to deal with packets
going from our network:
• leave gateways as in main/backup configuration - this will result in only one link utilized and asymmetric routing
• use policy routing to force outgoing packets over the same link as incoming
• use BGP to receive full routing tables from both peers and using BGP attributes make part of the routes available
through one link and other part through another link. For example, traffic local to your country is sent over ISP1
the rest is sent over ISP2.
All those methods are covered in other articles and will not be shown here.
[Back to Content]
Manual:Bonding Examples
ARP Link Monitoring HowTo
About
This is an example of aggregating multiple network interfaces into a single pipe. In particular, it is shown how to
aggregate multiple virtual (EoIP) interfaces to get maximum throughput (MT) with emphasis on availability.
Objective
You will learn how to connect remote locations via multiple physical links. The combined pipe will deliver higher
throughput and availability then the individual links.
Network Diagram
Two routers R1 and R2 are interconnected via multihop wireless links. Wireless interfaces on both sides have
assigned IP addresses.
Manual:Bonding Examples 218
Getting started
Bonding could be used only on OSI layer 2 (Ethernet level) connections. Thus we need to create EoIP interfaces on
each of the wireless links. This is done as follows:
• on router R1:
• and on router R2
The second step is to add bonding interface and specify EoIP interfaces as slaves:
• on router R1:
[admin@MikroTik] > / interface bonding add slaves=eoip-tunnel1,eoip-tunnel2 mode=balance-rr
• and on router R2
You should see that traffic is distributed equally across both EoIP interfaces:
Link Monitoring
It is easy to notice that with the configuration above as soon as any of individual link fails, the bonding interface
throughput collapses. That's because no link monitoring is performed, consequently, the bonding driver is unaware
of problems with the underlying links. Enabling link monitoring is a must in most bonding configurations. To enable
ARP link monitoring (recommended), do the following:
• on router R1:
[admin@MikroTik] > / interface bonding set bonding1 link-monitoring=arp arp-ip-targets=192.168.0.2
Tip: Refer to the following page for information about different link monitoring types.
Manual:Connection Rate 220
Manual:Connection Rate
Applies to RouterOS: 3, v4
Introduction
Connection Rate is a firewall matcher that allow to capture traffic based on present speed of the connection.
Theory
Each entry in connection tracking table represents bidirectional communication. Every time packet gets associated to
particular entry, packet size value (including IP header) is added to "connection-bytes" value for this entry. (in
another words "connection-bytes" includes both - upload and download)
Connection Rate calculates speed of connection based on change of "connection-bytes". Connection Rate is
recalculated every second and does not have any averages.
Both options "connection-bytes" and "connection-rate" work only with TCP and UDP traffic. (you need to specify
protocol to activate these options)
In "connection-rate" you can specify range of speed that you like to capture.
Example
These rules will capture TCP/UDP traffic that was going trough the router when connection speed was below
100kbps
Notes
Connection Rate is available in RouterOS since v3.30. This option was introduced to allow capture traffic intensive
connections.
/queue tree
add name=upload parent=public max-limit=6M
add name=other_upload parent=upload limit-at=4M max-limit=6M \
packet-mark=other_traffic priority=1
add name=heavy_upload parent=upload limit-at=2M max-limit=6M \
packet-mark=heavy_traffic priority=8
add name=download parent=local max-limit=6M
add name=other_download parent=download limit-at=4M max-limit=6M \
packet-mark=other_traffic priority=1
add name=heavy_download parent=download limit-at=2M max-limit=6M \
packet-mark=heavy_traffic priority=8
Explanation
In mangle we need to separate all connections into two groups, then mark packets from there 2 groups. As we are
talking about client's traffic most logical place for marking would be mangle chain forward.
Keep in mind that as soon as "heavy" connection will have lower priority and queue will hit max-limit - heavy
connection will drop speed, and connection-rate will be lower. This will result in a change to higher priority and
connection will be able to get more traffic for a short while, when again connection-rate will raise and that again will
result in change to lower priority). To avoid this we must make sure that once detected "heavy connections" will
remain marked as "heavy connections" for all times.
Manual:Connection Rate 222
IP Firewall mangle
/ip firewall mangle
add chain=forward action=mark-connection connection-mark=!heavy_traffic_conn \
new-connection-mark=all_conn
This rule will ensure that that "heavy" connections will remain heavy". and mark rest of the connections with default
connection mark.
These two rules will mark all heavy connections based on our standarts, that every connection that after first 500kB
still have more than 200kbps speed can be assumed as "heavy"
Last two rules in mangle will simple mark all traffic from corresponding connections.
Queue
This is a simple queue tree that is placed on the Interface HTB - "public" is interface where your ISP is connected,
"local" where are your clients. If you have more than 1 "public" or more than 1 "local" you will need to mangle
upload and download separately and place queue tree in global-out.
/queue tree
add name=upload parent=public max-limit=6M
add name=other_upload parent=upload limit-at=4M max-limit=6M \
packet-mark=other_traffic priority=1
add name=heavy_upload parent=upload limit-at=2M max-limit=6M \
packet-mark=heavy_traffic priority=8
add name=download parent=local max-limit=6M
add name=other_download parent=download limit-at=4M max-limit=6M \
packet-mark=other_traffic priority=1
add name=heavy_download parent=download limit-at=2M max-limit=6M \
packet-mark=heavy_traffic priority=8
Manual:Load balancing multiple same subnet links 223
This example demonstrates how to set up load balancing if provider is giving IP addresses from the
same subnet for all links.
Provider is giving us two links with IP addresses from the same network range (10.1.101.10/24 and 10.1.101.18/24).
Gateway for both of these links is the same 10.1.101.1
Here is the whole configuration for those who want to copy&paste
/ip address
add address=10.1.101.18/24 interface=ether1
add address=10.1.101.10/24 interface=ether2
add address=192.168.1.1/24 interface=Local
add address=192.168.2.1/24 interface=Local
/ip route
add gateway=10.1.101.1
add gateway=10.1.101.1%ether1 routing-mark=first
add gateway=10.1.101.1%ether2 routing-mark=other
In previous RouterOS version multiple IP addresses from the same subnet on different interfaces were not allowed.
Fortunately v4 allows such configurations.
In this example our provider assigned two upstream links, one connected to ether1 and other to ether2. Our local
network has two subnets 192.168.1.0/24 and 192.168.2.0/24
/ip address
add address=10.1.101.18/24 interface=ether1
add address=10.1.101.10/24 interface=ether2
add address=192.168.1.1/24 interface=Local
add address=192.168.2.1/24 interface=Local
After IP address is set up, connected route will be installed as ECMP route
In our example very simple policy routing is used. Clients from 192.168.1.0/24 subnet is marked
to use "first" routing table and 192.168.2.0/24 to use "other" subnet.
Note: The same can be achieved by setting up route rules instead of mangle.
Warning: You will also have to deal with traffic coming to and from the router itself. For explanations look
at PCC configuration example.
We are adding two gateways, one to resolve in "first" routing table and another to "other"
routing table.
Manual:Load balancing multiple same subnet links 225
/ip route
add gateway=10.1.101.1%ether1 routing-mark=first
add gateway=10.1.101.1%ether2 routing-mark=other
Interesting part of these routes is how we set gateway. gateway=10.1.101.1%ether1 means that gateway 10.1.101.1
will be explicitly reachable over ether1
1 A S dst-address=0.0.0.0/0 gateway=10.1.101.1%ether1
gateway-status=10.1.101.1 reachable ether1 distance=1 scope=30
target-scope=10 routing-mark=first
Finally, we have one additional entry specifying that traffic from the router itself (the traffic without any routing
marks) will be resolved in main routing table.
/ip route
add gateway=10.1.101.1
Manual:OSPFv3 with Quagga 226
Router A
/ipv6 address
add address=2003::1:0:0:0:1/64 advertise=no interface=ether2
add address=2003::4:0:0:0:1/64 advertise=no interface=ether1
add address=2003::1/64 advertise=no interface=ToInternet
/routing ospf-v3
set router-id=0.0.0.1 distribute-default=always-as-type-1
/routing ospf-v3 interface
add interface=ether1 area=backbone
add interface=ether2 area=backbone
Router B
/ipv6 address
add address=2003::1:0:0:0:2/64 advertise=no interface=ether1
add address=2003::2:0:0:0:2/64 advertise=no interface=ether2
/routing ospf-v3
Manual:OSPFv3 with Quagga 227
set router-id=0.0.0.2
/routing ospf-v3 area
add area-id=0.0.0.1 name=area1
/routing ospf-v3 interface
add interface=ether1 area=backbone
add interface=ether2 area=area1
Quagga Router
debian:~# ip -6 addr add 2003:0:0:3::4/64 dev eth1
debian:~# ip -6 addr add 2003:0:0:4::4/64 dev eth2
debian:~#
debian:~# cat /etc/quagga/ospf6d.conf
...
interface eth1
ipv6 ospf6 cost 10
interface eth2
ipv6 ospf6 cost 10
router ospf6
router-id 0.0.0.4
interface eth1 area 0.0.0.1
interface eth2 area 0.0.0.0
debian:~# telnet ::1 2606
Hello, this is Quagga (version 0.99.11).
Copyright 1996-2005 Kunihiro Ishiguro, et al.
...
quagga# show ipv6 ospf6 route
*N E1 ::/0 fe80::1200:ff:fe00:100 eth2 00:33:50
*N IA 2003:0:0:1::/64 fe80::1200:ff:fe00:100 eth2 00:32:55
*N IE 2003:0:0:2::/64 fe80::1200:ff:fe00:100 eth2 00:02:44
*N IA 2003:0:0:2::/64 fe80::1200:ff:fe00:301 eth1 00:02:37
*N IE 2003:0:0:3::/64 fe80::1200:ff:fe00:100 eth2 00:02:39
N IA 2003:0:0:3::/64 :: eth1 00:02:46
*N IA 2003:0:0:4::/64 :: eth2 00:33:50
Router C
/ipv6 address
add address=2003::2:0:0:0:3/64 advertise=no interface=ether1
add address=2003::3:0:0:0:3/64 advertise=no interface=ether2
/routing ospf-v3
set router-id=0.0.0.3
/routing ospf-v3 area
Manual:OSPFv3 with Quagga 228
Ping an "Internet" address from Router C (traffic will go through ECMP route):
Manual:Queues - PCQ Examples Source: http://wiki.mikrotik.com/index.php?oldid=16950 Contributors: Eep, Janisk, Marisb, Normis, Rieks, SergejsB, Wiki1981
Manual:Queues - PCQ Source: http://wiki.mikrotik.com/index.php?oldid=19822 Contributors: Eep, Janisk, Marisb, Megis, Normis
Manual:Queue Source: http://wiki.mikrotik.com/index.php?oldid=16916 Contributors: Eep, Janisk, Marisb, Megis, Normis, SergejsB
Manual:Virtual Routing and Forwarding Source: http://wiki.mikrotik.com/index.php?oldid=16975 Contributors: Eep, Janisk, Marisb, Normis, Route
Manual:BGP based VPLS Source: http://wiki.mikrotik.com/index.php?oldid=19700 Contributors: Eep, Janisk, Marisb, Mplsguy, Normis
Manual:BGP HowTo & FAQ Source: http://wiki.mikrotik.com/index.php?oldid=16877 Contributors: Janisk, Marisb, Route
Manual:BGP soft reconfiguration alternatives in RouterOS Source: http://wiki.mikrotik.com/index.php?oldid=18350 Contributors: Atis, Eep, Janisk, Marisb, SergejsB
Manual:BGP Load Balancing with two interfaces Source: http://wiki.mikrotik.com/index.php?oldid=16878 Contributors: Janisk, Marisb, Route
Manual:MME wireless routing protocol Source: http://wiki.mikrotik.com/index.php?oldid=17441 Contributors: Atis, Eep, Marisb, Normis, SergejsB
Manual:Layer-3 MPLS VPN example Source: http://wiki.mikrotik.com/index.php?oldid=16990 Contributors: Janisk, Marisb, Normis, Route
Manual:OSPF as PE-CE routing protocol Source: http://wiki.mikrotik.com/index.php?oldid=16913 Contributors: Janisk, Marisb, Route
Manual:Bonding Examples Source: http://wiki.mikrotik.com/index.php?oldid=19357 Contributors: Eep, Eugene, Marisb, Normis, Peson
Manual:Load balancing multiple same subnet links Source: http://wiki.mikrotik.com/index.php?oldid=16963 Contributors: Janisk, Marisb
Article Sources and Contributors 230