Mikrotik Manual

Download as pdf or txt
Download as pdf or txt
You are on page 1of 232

Manual:CD Install 1

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

Post Installation procedures


8. MikroTik RouterOS is successfully installed, do not forget to eject CD installation disk and set PC to boot from
Hard Drive,

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

Reset RouterOS configuration with CD Intstall


To reset the RouterOS configuration with CD Install, follow the procedure and on the step 6, set no for the answer
'Do you want to keep old configuration ?'.

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.

Quick Setup Guide


To configure MikroTik RouterOS to be a PPPoE client, just add a pppoe-client:

/interface pppoe-client
add name=pppoe-user-mike user=user password=passwd interface=wlan1 \
service-name=internet disabled=no

To configure MikroTik RouterOS to be an Access Concentrator (PPPoE Server):


• add an address pool for the clients from 10.1.1.62 to 10.1.1.72;
• add ppp profile;
• add ppp secret (username/password);
• add pppoe server itself.

/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

/interface pppoe-server server


add service-name=internet interface=wlan1 default-profile=pppoe-profile
Manual:Interface/PPPoE 9

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

Used Packet Types

Packet Description

PADI PPPoE Active Discovery Initialization


The PPPoE client sends out a PADI packet to the broadcast address. This packet can also populate the "service-name" field if a service
name has been entered on the dial-up networking properties of the PPPoE broadband connectoid. If a service name has not been entered,
this field is not populated

PADO PPPoE Active Discovery Offer


The PPPoE server, or Access Concentrator, should respond to the PADI with a PADO if the Access Concentrator is able to service the
"service-name" field that had been listed in the PADI packet. If no "service-name" field had been listed, the Access Concentrator will
respond with a PADO packet that has the "service-name" field populated with the service names that the Access Concentrator can service.
The PADO packet is sent to the unicast address of the PPPoE client

PADR PPPoE Active Discovery Request


When a PADO packet is received, the PPPoE client responds with a PADR packet. This packet is sent to the unicast address of the Access
Concentrator. The client may receive multiple PADO packets, but the client responds to the first valid PADO that the client received. If the
initial PADI packet had a blank "service-name" field filed, the client populates the "service-name" field of the PADR packet with the first
service name that had been returned in the PADO packet.

PADS PPPoE Active Discovery Session confirmation


When the PADR is received, the Access Concentrator generates a unique session identification (ID) for the Point-to-Point Protocol (PPP)
session and returns this ID to the PPPoE client in the PADS packet. This packet is sent to the unicast address of the client.

PADT PPPoE Active Discovery Terminate


might be sent anytime after a session is established to indicate that a PPPoE session terminated. It can be sent by either server or client.

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

interface (string; Default: ) interface name on which client will run

max-mru (integer; Default: 1460) Maximum Receive Unit

max-mtu (integer; Default: 1460) Maximum Transmission Unit

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

password (string; Default: ) password used to authenticate

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

user (string; Default: "") username used for authentication

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

ac-name (string) name of the Access Concentrator

encoding (string) encryption and encoding (if asymmetric, separated with '/') being used in this connection

mru (integer) effective MRU of the link

mtu (integer) effective MTU of the link

service-name (string) used service name

status (string) current link status. Available values are:


• dialing,
• verifying password...,
• connected,
• disconnected.

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

service (string) Service name configured on server

mac-address (MAC) Mac address of detected server

ac-name (string) name of the Access Concentrator

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

[admin@MikroTik] interface pppoe-client> monitor pppoe-out1


status: "connected"
uptime: 6s
idle-time: 6s
encoding: "MPPE128 stateless"
service-name: "testSN"
ac-name: "MikroTik"
ac-mac: 00:0C:42:04:00:73
mtu: 1480
mru: 1480
Manual:Interface/PPPoE 13

Additional Resources
PPPoE Clients:
• RASPPPoE [1]for Windows 95, 98, 98SE, ME, NT4, 2000, XP, .NET

PPPoE Server Setup (Access Concentrator)


Sub-menu: /interface pppoe-server server
The PPPoE server (access concentrator) supports multiple servers for each interface - with differing service names.
Currently the throughput of the PPPoE server has been tested to 160 Mb/s on a Celeron 600 CPU. Using higher
speed CPUs, throughput should increase proportionately.
The access concentrator name and PPPoE service name are used by clients to identity the access concentrator to
register with. The access concentrator name is the same as the identity of the router displayed before the command
prompt. The identity may be set within the /system identity submenu.
Note that if no service name is specified in WindowsXP, it will use only service with no name. So if you want to
serve WindowsXP clients, leave your service name empty.

Properties

Property Description

authentication ( mschap2 | mschap1 | chap | Authentication algorithm


pap; Default: "mschap2, mschap1, chap,
pap")

default-profile (string; Default: "default") Default user profile to use

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

service-name (string; Default: "") The PPPoE service name.


Manual:Interface/PPPoE 14

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:

[admin@MikroTik] interface pppoe-server server> add interface=ether1 service-name=ex


one-session-per-host=yes
[admin@MikroTik] interface pppoe-server server> print
Flags: X - disabled
0 X service-name="ex" interface=ether1 mtu=1480 mru=1480 mrru=disabled
authentication=mschap2,mschap,chap,pap keepalive-timeout=10
one-session-per-host=yes max-sessions=0 default-profile=default
[admin@MikroTik] interface pppoe-server server>

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:

[admin@MikroTik] interface pppoe-server> print


Flags: X - disabled, D - dynamic, R - running
# NAME USER SERVICE REMOTE... ENCODING UPTIME
0 DR <pppoe-ex> user ex 00:0C:... MPPE12... 40m45s
[admin@MikroTik] interface pppoe-server>

To disconnect the user ex:

[admin@MikroTik] interface pppoe-server> remove [find user=ex]


[admin@MikroTik] interface pppoe-server> print
[admin@MikroTik] interface pppoe-server>

Application Examples

PPPoE in a multipoint wireless 802.11g network


In a wireless network, the PPPoE server may be attached to an Access Point (as well as to a regular station of
wireless infrastructure). Either our RouterOS client or Windows PPPoE clients may connect to the Access Point for
PPPoE authentication. Further, for RouterOS clients, the radio interface may be set to MTU 1600 so that the PPPoE
interface may be set to MTU 1500. This optimizes the transmission of 1500 byte packets and avoids any problems
associated with MTUs lower than 1500. It has not been determined how to change the MTU of the Windows
wireless interface at this moment.
Let us consider the following setup where the MikroTik Wireless AP offers wireless clients transparent access to the
local network with authentication:

First of all, the wireless interface should be configured:


Manual:Interface/PPPoE 16

[admin@PPPoE-Server] interface wireless> set 0 mode=ap-bridge \


frequency=2442 band=2.4ghz-b/g ssid=mt disabled=no
[admin@PPPoE-Server] interface wireless> print
Flags: X - disabled, R - running
0 X name="wlan1" mtu=1500 mac-address=00:0C:42:18:5C:3D arp=enabled
interface-type=Atheros AR5413 mode=ap-bridge ssid="mt" frequency=2442
band=2.4ghz-b/g scan-list=default antenna-mode=ant-a wds-mode=disabled
wds-default-bridge=none wds-ignore-ssid=no default-authentication=yes
default-forwarding=yes default-ap-tx-limit=0 default-client-tx-limit=0
hide-ssid=no security-profile=default compression=no
[admin@PPPoE-Server] interface wireless>

Now, configure the Ethernet interface, add the IP address and set the default route:

[admin@PPPoE-Server] ip address> add address=10.1.0.3/24 interface=Local


[admin@PPPoE-Server] ip address> print
Flags: X - disabled, I - invalid, D - dynamic
# ADDRESS NETWORK BROADCAST INTERFACE
0 10.1.0.3/24 10.1.0.0 10.1.0.255 Local
[admin@PPPoE-Server] ip address> /ip route
[admin@PPPoE-Server] ip route> add gateway=10.1.0.1
[admin@PPPoE-Server] 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 G GATEWAY DISTANCE INTER...
0 ADC 10.1.0.0/24 10.1.0.3 0 Local
1 A S 0.0.0.0/0 r 10.1.0.1 1 Local
[admin@PPPoE-Server] ip route> /interface ethernet
[admin@PPPoE-Server] interface ethernet> set Local arp=proxy-arp
[admin@PPPoE-Server] interface ethernet> print
Flags: X - disabled, R - running
# NAME MTU MAC-ADDRESS ARP
0 R Local 1500 00:0C:42:03:25:53 proxy-arp
[admin@PPPoE-Server] interface ethernet>

We should add PPPoE server to the wireless interface:

[admin@PPPoE-Server] interface pppoe-server server> add interface=wlan1 \


service-name=mt one-session-per-host=yes disabled=no
[admin@PPPoE-Server] interface pppoe-server server> print
Flags: X - disabled
0 service-name="mt" interface=wlan1 max-mtu=1480 max-mru=1480 mrru=disabled
authentication=pap,chap,mschap1,mschap2 keepalive-timeout=10
one-session-per-host=yes max-sessions=0 default-profile=default
[admin@PPPoE-Server] interface pppoe-server server>

Finally, we can set up PPPoE clients:


Manual:Interface/PPPoE 17

[admin@PPPoE-Server] ip pool> add name=pppoe ranges=10.1.0.100-10.1.0.200


[admin@PPPoE-Server] ip pool> print
# NAME RANGES
0 pppoe 10.1.0.100-10.1.0.200
[admin@PPPoE-Server] ip pool> /ppp profile
[admin@PPPoE-Server] ppp profile> set default use-encryption=yes \
local-address=10.1.0.3 remote-address=pppoe
[admin@PPPoE-Server] ppp profile> print
Flags: * - default
0 * name="default" local-address=10.1.0.3 remote-address=pppoe
use-compression=no use-vj-compression=no use-encryption=yes only-one=no
change-tcp-mss=yes

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

shows "verifying password - unknown error"


• I want to have logs for PPPoE connection establishment
Configure the logging feature under the /system logging facility and enable the PPP type logs. Read more >>
[Back to Content]

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

arp (disabled | enabled | proxy-arp | reply-only; Address Resolution Protocol mode


Default: enabled)

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>>

mtu (integer; Default: 1500) Layer3 Maximum transmission unit

name (string; Default: ) Interface name

use-service-tag (yes | no; Default: ) 802.1ad compatible Service Tag

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

Configuration for R2 and R4 is shown below:


R2:

[admin@MikroTik] /interface vlan> add name=VLAN2 vlan-id=2 interface=ether1 disabled=no

[admin@MikroTik] /interface vlan> print


Flags: X - disabled, R - running, S - slave
# NAME MTU ARP VLAN-ID INTERFACE
0 R VLAN2 1500 enabled 2 ether1

R4:

[admin@MikroTik] /interface vlan> add name=VLAN2 vlan-id=2 interface=ether1 disabled=no

[admin@MikroTik] /interface vlan> print


Flags: X - disabled, R - running, S - slave
# NAME MTU ARP VLAN-ID INTERFACE
0 R VLAN2 1500 enabled 2 ether1

The next step is to assign IP addresses to the VLAN interfaces.


R2:

[admin@MikroTik] ip address> add address=10.10.10.3/24 interface=VLAN2


[admin@MikroTik] ip address> print
Flags: X - disabled, I - invalid, D - dynamic
# ADDRESS NETWORK BROADCAST INTERFACE
0 10.0.1.4/24 10.0.1.0 10.0.1.255 ether1
1 10.20.0.1/24 10.20.0.0 10.20.0.255 pc1
2 10.10.10.3/24 10.10.10.0 10.10.10.255 vlan2

[admin@MikroTik] ip address>

R4:
Manual:Interface/VLAN 22

[admin@MikroTik] ip address> add address=10.10.10.5/24 interface=VLAN2


[admin@MikroTik] ip address> print
Flags: X - disabled, I - invalid, D - dynamic
# ADDRESS NETWORK BROADCAST INTERFACE
0 10.0.1.5/24 10.0.1.0 10.0.1.255 ether1
1 10.30.0.1/24 10.30.0.0 10.30.0.255 pc2
2 10.10.10.5/24 10.10.10.0 10.10.10.255 vlan2

[admin@MikroTik] ip address>

At this point it should be possible to ping router R4 from router R2 and vice versa:

'''Ping from R2 to R4:'''

[admin@MikroTik] ip address> /ping 10.10.10.5

10.10.10.5 64 byte ping: ttl=255 time=4 ms

10.10.10.5 64 byte ping: ttl=255 time=1 ms

2 packets transmitted, 2 packets received, 0% packet loss

round-trip min/avg/max = 1/2.5/4 ms

'''From R4 to R2:'''

[admin@MikroTik] ip address> /ping 10.10.10.3


10.10.10.3 64 byte ping: ttl=255 time=6 ms
10.10.10.3 64 byte ping: ttl=255 time=1 ms
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 1/3.5/6 ms

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:'''

[admin@MikroTik] ip address> /ping 10.10.10.2


10.10.10.2 ping timeout
10.10.10.2 ping timeout
3 packets transmitted, 0 packets received, 100% packet loss
Manual:Interface/VLAN 23

Create trunks and implement routing between VLANs


If separate VLANs are implemented on a switch, then router is required to provide communication between VLANs.
Switch works at OSI layer 2 so it uses only Ethernet header to forward and does not check IP header. For this reason
we must use the router that is working as a gateway for each VLAN. Without a router host is unable to communicate
outside its own VLAN. Routing process between VLANs described above is called inter-VLAN communication.
To illustrate inter-VLAN communication, we will create a trunk that will carry traffic from three VLANs (VLAN2
and VLAN3, VLAN4) across a single link between Mikrotik router and a manageable switch that supports VLAN
trunking.

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

Add IP addresses to VLANs:

/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

RouterOS /32 and IP unnumbered addresses


In RouterOS to create point-to-point tunnel with addresses you have to use address with network mask /32 that
effectively brings you same features as some vendors unnumbered IP address.
There are 2 routers RouterA and RouterB that each is part of networks 10.22.0.0/24 and 10.23.0.0/24 respectively, to
connect these router using VLAN as carrier with the following configuration:

RouterA:

/ip address add address=10.22.0.1/24 interface=ether1


/interface vlan add interface=ether2 vlan-id=1 name=vlan1
/ip address add address=10.22.0.1/32 interface=vlan1 network=10.23.0.1
/ip route add gateway=10.23.0.1 dst-address=10.23.0.0/24

RouterB:

/ip address add address=10.23.0.1/24 interface=ether1


/interface vlan add interface=ether2 vlan-id=1 name=vlan1
/ip address add address=10.23.0.1/32 interface=vlan1 network=10.22.0.1
/ip route add gateway=10.22.0.1 dst-address=10.22.0.0/24

[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)

Quick Setup Guide


RouterOS has built in command that lets you easily set up DHCP server. Lets say we want to configure DHCP server
on ether1 interface to lend addresses from 192.168.0.2 to 192.168.0.254 which belong to the 192.168.0.0/24
network. The gateway and DNS server is 192.168.0.1.
From /ip dhcp-server menu run setup command and follow instructions:

[admin@MikroTik] ip dhcp-server> setup


Select interface to run DHCP server on

dhcp server interface: ether1


Select network for DHCP addresses

dhcp address space: 192.168.0.0/24


Select gateway for given network

gateway for dhcp network: 192.168.0.1


Select pool of ip addresses given out by DHCP server

addresses to give out: 192.168.0.2-192.168.0254


Select DNS servers

dns servers: 192.168.0.1


Select 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> print


Flags: X - disabled, I - invalid
# NAME INTERFACE RELAY ADDRESS-POOL LEASE-TIME ADD-ARP
0 dhcp1 ether1 0.0.0.0 dhcp_pool1 3d no

[admin@MikroTik] ip dhcp-server> network print


# ADDRESS GATEWAY DNS-SERVER WINS-SERVER DOMAIN
0 192.168.0.0/24 192.168.0.1 192.168.0.1

[admin@MikroTik] ip dhcp-server> /ip pool print


# NAME RANGES
0 dhcp_pool1 192.168.0.2-192.168.0.254

[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.

always-broadcast (yes | no; Always send replies as broadcasts.


Default: no)

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

boot-support (none | static | Support for BOOTP clients:


dynamic; Default: static) • none - do not respond to BOOTP requests
• static - offer only static leases to BOOTP clients
• dynamic - offer static and dynamic leases for BOOTP clients

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)

interface (string; Default: ) Interface on which server will be running.

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.

name (string; Default: ) Reference name

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

Menu specific commands

Property Description

setup () Start DHCP server setup wizard, which guides you through the steps to easily create all necessary configuration. Read more>>

Lease Store Configuration


Sub-menu: /ip dhcp-server config
This sub-menu allows to configure how often DHCP leases will be stored on disk. If they would be saved on disk on
every lease change, a lot of disk writes would happen which is very bad for Compact Flash (especially, if lease times
are very short). To minimize writes on disk, all changes are saved on disk every store-leases-disk seconds.
Additionally leases are always stored on disk on graceful shutdown and reboot.
This sub-menu has only one configurable property:

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: )

boot-file-name (string; Boot file name


Default: )

dhcp-option (string; Add additional DHCP options from option list.


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.

gateway (IP; Default: The default gateway to be used by DHCP Client.


0.0.0.0)

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)

next-server (IP; Default: ) IP address of next server to use in bootstrap.

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

always-broadcast (yes | no; Default: ) Send all repies as broadcasts

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

src-mac-address (MAC; Default: ) Source MAC address

use-src-mac (MAC; Default: ) Use this source MAC address instead

Read only properties


Manual:IP/DHCP Server 30

Property Description

active-address (IP) Actual IP address for this lease

active-client-id (string) Actual client-id of the client

active-mac-address Actual MAC address of the client


(MAC)

active-server (list) Actual dhcp server, which serves this client

agent-circuit-id (string) Circuit ID of DHCP relay agent

agent-remote-id (string) Remote ID, set by DHCP relay agent

blocked ( flag ) Whether the lease is blocked

expires-after (time) Time until lease expires

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

server (string) Server name which serves this client

status (waiting | testing | Lease status:


authorizing | busy | • waiting - not used static lease
offered | bound) • testing - testing whether this address is used or not (only for dynamic leases) by pinging it with timeout of 0.5s
• authorizing - waiting for response from radius server
• busy - this address is assigned statically to a client or already exists in the network, so it can not be leased
• offered - server has offered this lease to a client, but did not receive confirmation from the client
• bound - server has received client's confirmation that it accepts offered address, it is using it now and will free the
address not later, than the lease time will be over

Menu specific commands

Property Description

check-status (id) Check status of a given busy dynamic lease, and free it in case of no response

make-static (id) Convert a dynamic lease to a static one

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:

[admin@MikroTik] ip dhcp-server alert>/log print


00:34:23 dhcp,critical,error,warning,info,debug dhcp alert on Public:
discovered unknown dhcp server, mac 00:02:29:60:36:E7, ip 10.5.8.236
[admin@MikroTik] ip dhcp-server alert>
Manual:IP/DHCP Server 31

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.

valid-server (string; Default: ) List of MAC addresses of valid DHCP servers.

Read only properties

Property Description

unknown-server (string) List of MAC addresses of detected unknown DHCP servers. Server is removed from this list after alert-timeout

Menu specific commands

Property Description

reset-alert (id) Clear all alerts on an interface

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]

name (string; Default: ) Descriptive name of the option

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

/ip dhcp-server option


add code=121 name=classless value=0x18A000000A016501000A016501
/ip dhcp-server network
set 0 dhcp-option=classless

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

name (string; Default: ) Descriptive name for relay

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> print


Flags: X - disabled, I - invalid, D - dynamic
# ADDRESS NETWORK BROADCAST INTERFACE
0 192.168.0.1/24 192.168.0.0 192.168.0.255 To-DHCP-Relay
1 10.1.0.2/24 10.1.0.0 10.1.0.255 Public
Manual:IP/DHCP Relay 34

[admin@DHCP-Server] ip address>

IP addresses of DHCP-Relay:

[admin@DHCP-Relay] ip address> print


Flags: X - disabled, I - invalid, D - dynamic
# ADDRESS NETWORK BROADCAST INTERFACE
0 192.168.0.1/24 192.168.0.0 192.168.0.255 To-DHCP-Server
1 192.168.1.1/24 192.168.1.0 192.168.1.255 Local1
2 192.168.2.1/24 192.168.2.0 192.168.2.255 Local2
[admin@DHCP-Relay] ip address>

To setup 2 DHCP Servers on DHCP-Server router add 2 pools. For networks 192.168.1.0/24 and 192.168.2.0:

/ip pool add name=Local1-Pool ranges=192.168.1.11-192.168.1.100


/ip pool add name=Local1-Pool ranges=192.168.2.11-192.168.2.100
[admin@DHCP-Server] ip pool> print
# NAME RANGES
0 Local1-Pool 192.168.1.11-192.168.1.100
1 Local2-Pool 192.168.2.11-192.168.2.100
[admin@DHCP-Server] ip pool>

Create DHCP Servers:

/ip dhcp-server add interface=To-DHCP-Relay relay=192.168.1.1 \


address-pool=Local1-Pool name=DHCP-1 disabled=no
/ip dhcp-server add interface=To-DHCP-Relay relay=192.168.2.1 \
address-pool=Local2-Pool name=DHCP-2 disabled=no
[admin@DHCP-Server] ip dhcp-server> print
Flags: X - disabled, I - invalid
# NAME INTERFACE RELAY ADDRESS-POOL LEASE-TIME ADD-ARP
0 DHCP-1 To-DHCP-Relay 192.168.1.1 Local1-Pool 3d00:00:00
1 DHCP-2 To-DHCP-Relay 192.168.2.1 Local2-Pool 3d00:00:00
[admin@DHCP-Server] ip dhcp-server>

Configure respective networks:

/ip dhcp-server network add address=192.168.1.0/24 gateway=192.168.1.1 \


dns-server=159.148.60.20
/ip dhcp-server network add address=192.168.2.0/24 gateway=192.168.2.1 \
dns-server 159.148.60.20
[admin@DHCP-Server] ip dhcp-server network> print
# ADDRESS GATEWAY DNS-SERVER WINS-SERVER DOMAIN
0 192.168.1.0/24 192.168.1.1 159.148.60.20
1 192.168.2.0/24 192.168.2.1 159.148.60.20
[admin@DHCP-Server] ip dhcp-server network>

Configuration of DHCP-Server is done. Now let's configure DHCP-Relay:

/ip dhcp-relay add name=Local1-Relay interface=Local1 \


dhcp-server=192.168.0.1 local-address=192.168.1.1 disabled=no
/ip dhcp-relay add name=Local2-Relay interface=Local2 \
Manual:IP/DHCP Relay 35

dhcp-server=192.168.0.1 local-address=192.168.2.1 disabled=no


[admin@DHCP-Relay] ip dhcp-relay> print
Flags: X - disabled, I - invalid
# NAME INTERFACE DHCP-SERVER LOCAL-ADDRESS
0 Local1-Relay Local1 192.168.0.1 192.168.1.1
1 Local2-Relay Local2 192.168.0.1 192.168.2.1
[admin@DHCP-Relay] ip dhcp-relay>

[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.

Quick setup example


Add a DHCP client on ether1 interface:

/ip dhcp-client add interface=ether1 disabled=no

After interface is added, you can use rint" or "print detail" command to see what parameters DHCP client acquired:

[admin@MikroTik] ip dhcp-client> print detail


Flags: X - disabled, I - invalid
0 interface=ether1 add-default-route=yes use-peer-dns=yes use-peer-ntp=yes
status=bound address=192.168.0.65/24 gateway=192.168.0.1
dhcp-server=192.168.0.1 primary-dns=192.168.0.1 primary-ntp=192.168.0.1
expires-after=9m44s
[admin@MikroTik] ip dhcp-client>

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

default-route-distance (integer:0..255; Distance of default route. Applicable if add-default-route is set to yes.


Default: )

host-name (string; Default: ) Host name of the client sent to a DHCP server. If not specified, client's system identity will be used.

interface (string; Default: ) Interface on which DHCP client will be running.

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

dhcp-server (IP) IP address of the DHCP server.

expires-after (time) Time when the lease expires (specified by the DHCP server).

gateway (IP) IP address of the gateway which is assigned by DHCP server

invalid (yes | no) Shows whether configuration is invalid.

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)

Menu specific commands


Manual:IP/DHCP Client 37

Property Description

release Release current binding and restart DHCP client


(numbers)

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-range (Disabled | Auto bandwidth adjustment range. Read more >>


Min[bps][-Max[bps]]; Default: 0bps)

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 >>

comment (string; Default: ) Short description of the item

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.

mtu (integer; Default: )

name (string; Default: ) Name of the interface

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.

to-address (IP; Default: 0.0.0.0) Remote end of TE tunnel.

Monitoring
To verify TE tunnel's status monitor command can be used.

[admin@R3] /interface traffic-eng> monitor 0


tunnel-id: 12
primary-path-state: on-hold
secondary-path-state: established
secondary-path: static
active-path: static
active-lspid: 3
active-label: 66
explicit-route: "S:192.168.55.10/32,L:192.168.55.13/32,L:192.168.55.17/32"
recorded-route: "192.168.55.13[66],192.168.55.17[59],192.168.55.18[3]"
reserved-bandwidth: 5.0Mbps

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.

[admin@R3] /interface traffic-eng> monitor 0


tunnel-id: 12
primary-path-state: established
primary-path: dyn
secondary-path-state: not-necessary
active-path: dyn
active-lspid: 1
active-label: 67
explicit-route: "S:192.168.55.10/32,S:192.168.55.13/32,S:192.168.55.14/32,
S:192.168.55.17/32,S:192.168.55.18/32"
recorded-route: "192.168.55.13[67],192.168.55.17[60],192.168.55.18[3]"
reserved-bandwidth: 5.0Mbps
Manual:Interface/Traffic Engineering 39

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.

[admin@R3] /interface traffic-eng> reoptimize 0

[admin@R3] /interface traffic-eng> monitor 0


tunnel-id: 12
primary-path-state: established
primary-path: dyn
secondary-path-state: not-necessary
active-path: dyn
active-lspid: 2
active-label: 81
explicit-route: "S:192.168.55.5/32,S:192.168.55.2/32,S:192.168.55.1/32"
recorded-route: "192.168.55.2[81],192.168.55.1[3]"
reserved-bandwidth: 5.0Mbps

Notice how explicit-route and recorded-route changed to shorter 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.

Example 1 : Usual case

• Queue01 limit-at=0Mbps max-limit=10Mbps


• Queue02 limit-at=4Mbps max-limit=10Mbps
• Queue03 limit-at=6Mbps max-limit=10Mbps priority=1
• Queue04 limit-at=2Mbps max-limit=10Mbps priority=3
• Queue05 limit-at=2Mbps max-limit=10Mbps priority=5

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

Example 2 : Usual case with max-limit

• Queue01 limit-at=0Mbps max-limit=10Mbps


• Queue02 limit-at=4Mbps max-limit=10Mbps
• Queue03 limit-at=2Mbps max-limit=10Mbps priority=3
• Queue04 limit-at=2Mbps max-limit=10Mbps priority=1
• Queue05 limit-at=2Mbps max-limit=10Mbps priority=5
Manual:HTB 43

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.

Example 3 : Inner queue limit-at

• Queue01 limit-at=0Mbps max-limit=10Mbps


• Queue02 limit-at=8Mbps max-limit=10Mbps
• Queue03 limit-at=2Mbps max-limit=10Mbps priority=1
• Queue04 limit-at=2Mbps max-limit=10Mbps priority=3
• Queue05 limit-at=2Mbps max-limit=10Mbps priority=5

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

Example 4 : Leaf queue limit-at

• Queue01 limit-at=0Mbps max-limit=10Mbps


• Queue02 limit-at=4Mbps max-limit=10Mbps
• Queue03 limit-at=6Mbps max-limit=10Mbps priority=1
• Queue04 limit-at=2Mbps max-limit=10Mbps priority=3
• Queue05 limit-at=12Mbps max-limit=15Mbps priority=5

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

Queue Size Example


This example was created to highlight queue size impact on traffic that was queued by specific queue.
In Mikrotik RouterOS queue size can be specified in the "/queue type" menu. Each queue type have a different
option for specifying queue size (pfifo-limit, bfifo-limit, pcq-limit, pcq-total-limit, red-limit), but all principles are
the same - queue size is main option that decide should the package be dropped or scheduled for later time.
In real time environment this process is happening continuously without any stops, steps or other interruptions, but in
order to show it as an example we will divide it into steps, where it is possible to know exactly how many packets
will be received/transited in every step.
We will not go into specific details of TCP and dropped packet retransmission - consider these packets as simple
UDP stream.

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

Default-small queue type


It is also possible to choose the middle way, when queue use both of these queuing aspects (shaping and scheduling)
By default most of the queues in RouterOS have queue size of 10.

There were 320 (19,9%) packets dropped and 80 (5,0%) packets had 1 step delay.

Default queue type


Other popular queue size in RouterOS is 50

There were 190 (11,8%) packets dropped and 400 (24,8%) packets had 1 step delay.
Manual:Queues - PCQ Examples 48

Manual:Queues - PCQ Examples


Per Connection Queue (PCQ) is a queuing discipline that can be used to dynamically equalize or shape traffic for
multiple users, using little administration. It is possible to divide PCQ scenarios into three major groups: equal
bandwidth for a number of users, certain bandwidth equal distribution between users, unknown bandwidth equal
distribution between users.

Equal Bandwidth for a Number of Users


Use PCQ type queue when you need to equalize the bandwidth [and set max limit] for a number of users. We will set
the 64kbps download and 32kbps upload limits.

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:

/queue type add name="PCQ_download" kind=pcq pcq-rate=64000 pcq-classifier=dst-address


/queue type add name="PCQ_upload" kind=pcq pcq-rate=32000 pcq-classifier=src-address

3. Finally, two queue rules are required, one for download and one for upload:

/queue tree add parent=global-in queue=PCQ_download packet-mark=all


/queue tree add parent=global-out queue=PCQ_upload packet-mark=all

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

/queue simple add queue=PCQ_upload/PCQ_download target-addresses=192.168.0.0/24

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 Rate Examples


Here it is possible to see what happens if PCQ-rate is, or isn't specified. I must noted that if both limits (pcq-rate and
max-limit) are unspecified, queue behavior can be imprecise. So it is strongly suggested to have at least one of these
options set.

New PCQ implementation (v5.0RC5)


PCQ was rewritten in v5.0RC4 to optimize it high throughput both in Mbps and pps. This implementation properly
utilize all new Linux Kernel features, this makes PCQ faster and less resource demanding.
Now as soon as new stream activates it will get 1/4th of rate with highest priority. If rate is "0" sub-stream will not
have this feature (as 1/4th of "0" is "0")
This is necessary to know for one good reason: Lets assume that sub-stream's rate is 10Mbps, so in the moment when
new sub-stream will request traffic it will get first 2500k of traffic without limitation. This may result in higher that
expected results in such programs as Speedtest.net. To avoid that make sure that Speedtest.net is not the first
program that utilize bandwidth that you run on PC.
Also starting from v5.0RC5 PCQ have new features
Manual:Queues - PCQ 52

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

Time average-rate burst actual-rate

0 (0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0)/16=0Kbps average-rate < burst-threshold → Burst is allowed 4Mbps

1 (0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+4)/16=250Kbps average-rate < burst-threshold → Burst is allowed 4Mbps

2 (0+0+0+0+0+0+0+0+0+0+0+0+0+0+4+4)/16=500Kbps average-rate < burst-threshold → Burst is allowed 4Mbps

3 (0+0+0+0+0+0+0+0+0+0+0+0+0+4+4+4)/16=750Kbps average-rate < burst-threshold → Burst is allowed 4Mbps

4 (0+0+0+0+0+0+0+0+0+0+0+0+4+4+4+4)/16=1000Kbps average-rate < burst-threshold → Burst is allowed 4Mbps

5 (0+0+0+0+0+0+0+0+0+0+0+4+4+4+4+4)/16=1250Kbps average-rate < burst-threshold → Burst is allowed 4Mbps

6 (0+0+0+0+0+0+0+0+0+0+4+4+4+4+4+4)/16=1500Kbps average-rate = burst-threshold → Burst not allowed 2Mbps

7 (0+0+0+0+0+0+0+0+0+4+4+4+4+4+4+2)/16=1625Kbps average-rate > burst-threshold → Burst not allowed 2Mbps

8 (0+0+0+0+0+0+0+0+4+4+4+4+4+4+2+2)/16=1750Kbps average-rate > burst-threshold → Burst not allowed 2Mbps

9 (0+0+0+0+0+0+0+4+4+4+4+4+4+2+2+2)/16=1750Kbps average-rate > burst-threshold → Burst not allowed 2Mbps

10 (0+0+0+0+0+0+4+4+4+4+4+4+2+2+2+2)/16=1875Kbps average-rate > burst-threshold → Burst not allowed 0Mbps


Manual:Queues - Burst 54

11 (0+0+0+0+0+4+4+4+4+4+4+2+2+2+2+0)/16=1875Kbps average-rate > burst-threshold → Burst not allowed 0Mbps

12 (0+0+0+0+4+4+4+4+4+4+2+2+2+2+0+0)/16=1875Kbps average-rate > burst-threshold → Burst not allowed 0Mbps

13 (0+0+0+4+4+4+4+4+4+2+2+2+2+0+0+0)/16=1875Kbps average-rate > burst-threshold → Burst not allowed 0Mbps

14 (0+0+4+4+4+4+4+4+2+2+2+2+0+0+0+0)/16=1875Kbps average-rate > burst-threshold → Burst not allowed 0Mbps

15 (0+4+4+4+4+4+4+2+2+2+2+0+0+0+0+0)/16=1875Kbps average-rate > burst-threshold → Burst not allowed 0Mbps

16 (4+4+4+4+4+4+2+2+2+2+0+0+0+0+0+0)/16=1875Kbps average-rate > burst-threshold → Burst not allowed 0Mbps

17 (4+4+4+4+4+2+2+2+2+0+0+0+0+0+0+0)/16=1625Kbps average-rate > burst-threshold → Burst not allowed 2Mbps

18 (4+4+4+4+2+2+2+2+0+0+0+0+0+0+0+2)/16=1500Kbps average-rate = burst-threshold → Burst not allowed 2Mbps

19 (4+4+4+2+2+2+2+0+0+0+0+0+0+0+2+2)/16=1375Kbps average-rate < burst-threshold → Burst is allowed 4Mbps

20 (4+4+2+2+2+2+0+0+0+0+0+0+0+2+2+4)/16=1375Kbps average-rate < burst-threshold → Burst is allowed 4Mbps

21 (4+2+2+2+2+0+0+0+0+0+0+0+2+2+4+4)/16=1375Kbps average-rate < burst-threshold → Burst is allowed 4Mbps

22 (2+2+2+2+0+0+0+0+0+0+0+2+2+4+4+4)/16=1375Kbps average-rate < burst-threshold → Burst is allowed 4Mbps

23 (2+2+2+0+0+0+0+0+0+0+2+2+4+4+4+4)/16=1500Kbps average-rate = burst-threshold → Burst not allowed 2Mbps

24 (2+2+0+0+0+0+0+0+0+2+2+4+4+4+4+2)/16=1500Kbps average-rate = burst-threshold → Burst not allowed 2Mbps

25 (2+0+0+0+0+0+0+0+2+2+4+4+4+4+2+2)/16=1500Kbps average-rate = burst-threshold → Burst not allowed 2Mbps

26 (0+0+0+0+0+0+0+2+2+4+4+4+4+2+2+2)/16=1500Kbps average-rate = burst-threshold → Burst not allowed 2Mbps

27 (0+0+0+0+0+0+2+2+4+4+4+4+2+2+2+2)/16=1625Kbps average-rate > burst-threshold → Burst not allowed 2Mbps

28 (0+0+0+0+0+2+2+4+4+4+4+2+2+2+2+2)/16=1750Kbps average-rate > burst-threshold → Burst not allowed 2Mbps

29 (0+0+0+0+2+2+4+4+4+4+2+2+2+2+2+2)/16=1875Kbps average-rate > burst-threshold → Burst not allowed 0Mbps

30 (0+0+0+2+2+4+4+4+4+2+2+2+2+2+2+0)/16=1875Kbps average-rate > burst-threshold → Burst not allowed 0Mbps

31 (0+0+2+2+4+4+4+4+2+2+2+2+2+2+0+0)/16=1875Kbps average-rate > burst-threshold → Burst not allowed 0Mbps

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.

Time average-rate burst actual-rate

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

- starting point for packets generated by router itself

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 firewall connection tracking

- /ip firewall filter

- /ip firewall nat

- /ip firewall mangle


Manual:Packet Flow 59

- /queue simple and /queue tree

- /ip ipsec policy

- /ip accounting

- /interface bridge settings - available only for traffic that go through the bridge. For all other
traffic default value is Yes

- /interface bridge filter

- /interface bridge nat

Automated processes and decisions

- 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

- this is a workaround, allows to use "out-bridge-port" before actual bridge decision.

- 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

Bridging with use-ip-firewall=yes

Routing - from Ethernet to Ethernet interface


Manual:Packet Flow 61

Routing from one Bridge interface to different Bridge interface

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

List of reference sub-pages Case studies List of examples

<splist showparent=yes />

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

PFIFO and BFIFO


These queuing disciplines are based on the FIFO algorithm (First-In First-Out). The difference between PFIFO and
BFIFO is that one is measured in packets and the other one in bytes.
• pfifo-limit (number) : Maximum number of packets that the PFIFO queue can hold
• bfifo-limit (number) : Maximum number of bytes that the BFIFO queue can hold
Every packet that cannot be enqueued (if the queue is full), is dropped. Large queue sizes can increase latency, but
utilize channel better.

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

Quick Setup Guide


Let us assume that we have 2 NICs in each router (Router1 and Router2) and want to get maximum data rate
between 2 routers. To make this possible, follow these steps:
• Make sure that you do not have IP addresses on interfaces which will be enslaved for bonding interface!
• Add bonding interface on Router1:

[admin@Router1] interface bonding> add slaves=ether1,ether2

And on Router2:

[admin@Router2] interface bonding> add slaves=ether1,ether2

Add addresses to bonding interfaces:

[admin@Router1] ip address> add address=172.16.0.1/24 interface=bonding1


[admin@Router2] ip address> add address=172.16.0.2/24 interface=bonding1

Test the link from Router1:

[admin@Router1] interface bonding> /pi 172.16.0.2


172.16.0.2 ping timeout
172.16.0.2 ping timeout
172.16.0.2 ping timeout
172.16.0.2 64 byte ping: ttl=64 time=2 ms
172.16.0.2 64 byte ping: ttl=64 time=2 ms

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

[admin@Router1] interface bonding> set 0 link-monitoring=arp arp-ip-targets=172.16.0.2


[admin@Router2] interface bonding> set 0 link-monitoring=arp arp-ip-targets=172.16.0.1

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.

[admin@Router1] interface bonding> /pi 172.16.0.2


172.16.0.2 ping timeout
172.16.0.2 64 byte ping: ttl=64 time=2 ms
172.16.0.2 ping timeout
172.16.0.2 64 byte ping: ttl=64 time=2 ms
172.16.0.2 ping timeout
172.16.0.2 64 byte ping: ttl=64 time=2 ms
172.16.0.2 64 byte ping: ttl=64 time=2 ms
172.16.0.2 64 byte ping: ttl=64 time=2 ms

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:

[admin@Router1] interface bonding> set 0 link-monitoring=mii-type-2


[admin@Router2] interface bonding> set 0 link-monitoring=mii-type-2

We will leave mii-interval to it's default value (100ms)


When unplugging one of the cables, notice that failure was detected almost instantly compared to ARP link
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

Note: layer-3-and-4 mode is not fully compatible with LACP.

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:

Intelligent Switch : Trunk Configuration


==================
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 M1 M2
1 - v - v - - - - - - - - - - - - - - - - - - - - - -
2 - - - - - - - - - - - - - - - - - - - - - - - - - -
3 - - - - - - - - - - - - - - - - - - - - - - - - - -
4 - - - - - - - - - - - - - - - - - - - - - - - - - -
5 - - - - - - - - - - - - - - - - - - - - - - - - - -
6 - - - - - - - - - - - - - - - - - - - - - - - - - -
7 - - - - - - - - - - - - - - - - - - - - - - - - - -

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

Intelligent Switch : LACP Port State Active Configuration


==================

Port State Activity Port State Activity


--------------------------- ---------------------------
2 Active
4 Active

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.

Intelligent Switch : LACP Group Status


==================

Group
[Actor] [Partner]

Priority: 1 65535

MAC : 000E2E2206A9 000C42409426

Port_No Key Priority Active Port_No Key Priority


2 513 1 selected 1 9 255
4 513 1 selected 2 9 255

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:

[admin@test-host] /interface> monitor-traffic ether1,ether2,bonding1


rx-packets-per-second: 8158 8120 16278
rx-drops-per-second: 0 0 0
rx-errors-per-second: 0 0 0
rx-bits-per-second: 98.8Mbps 98.2Mbps 197.0Mbps
tx-packets-per-second: 4833 4560 9394
tx-drops-per-second: 0 0 0
tx-errors-per-second: 0 0 0
tx-bits-per-second: 2.7Mbps 3.0Mbps 5.8Mbps

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

/interface bonding add mode=balance-tlb slaves=ether1,ether2 primary=ether1


Manual:Interface/Bonding 74

No additional configuration is required for the switch.

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

secondary link to communicate with router.

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)

mode (802.3ad | active-backup | Specifies one of the bonding policies


balance-alb | balance-rr |
balance-tlb | balance-xor |
broadcast; Default: balance-rr)

• 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>

mtu (integer; Default: 1500) Maximum Transmit Unit in bytes

name (string; Default: ) descriptive name of bonding interface


Manual:Interface/Bonding 76

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

Manual:TE Tunnels Example


Application example
Consider following setup:

IP Connectivity and LDP


R1
ether1 connects to R2, ether2 connects to R5

/system identity set name=R1

/interface bridge add name=lo0

/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

/routing ospf instance


set default router-id=10.255.1.1

/routing ospf network


add network=192.168.55.0/24 area=backbone
add network=10.255.1.0/24 area=backbone

/mpls ldp
set enabled=yes lsr-id=10.255.1.1 transport-address=10.255.1.1

/mpls ldp interface


add interface=ether1
add interface=ether2
Manual:TE Tunnels Example 78

R2
ether1 connects to R1, ether2 connects to R3

/system identity set name=R2

/interface bridge add name=lo0

/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

/routing ospf instance


set default router-id=10.255.1.2

/routing ospf network


add network=192.168.55.0/24 area=backbone
add network=10.255.1.0/24 area=backbone

/mpls ldp
set enabled=yes lsr-id=10.255.1.2 transport-address=10.255.1.2

/mpls ldp interface


add interface=ether1
add interface=ether2

R3
ether1 connects to R2, ether2 connects to R4

/system identity set name=R3

/interface bridge add name=lo0

/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

/routing ospf instance


set default router-id=10.255.1.3

/routing ospf network


add network=192.168.55.0/24 area=backbone
add network=10.255.1.0/24 area=backbone

/mpls ldp
Manual:TE Tunnels Example 79

set enabled=yes lsr-id=10.255.1.3 transport-address=10.255.1.3

/mpls ldp interface


add interface=ether1
add interface=ether2

R4
ether1 connects to R3, ether2 connects to R5

/system identity set name=R4

/interface bridge add name=lo0

/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

/routing ospf instance


set default router-id=10.255.1.4

/routing ospf network


add network=192.168.55.0/24 area=backbone
add network=10.255.1.0/24 area=backbone

/mpls ldp
set enabled=yes lsr-id=10.255.1.4 transport-address=10.255.1.4

/mpls ldp interface


add interface=ether1
add interface=ether2

R5
ether1 connects to R4, ether2 connects to R1

/system identity set name=R5

/interface bridge add name=lo0

/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

/routing ospf instance


set default router-id=10.255.1.5
Manual:TE Tunnels Example 80

/routing ospf network


add network=192.168.55.0/24 area=backbone
add network=10.255.1.0/24 area=backbone

/mpls ldp
set enabled=yes lsr-id=10.255.1.5 transport-address=10.255.1.5

/mpls ldp interface


add interface=ether1
add interface=ether2

After OSPF and LDP setup ensure that ospf is working properly

[admin@R1] /routing ospf neighbor> print


0 instance=default router-id=10.255.1.5 address=192.168.55.17 interface=ether2
priority=1 dr-address=192.168.55.17 backup-dr-address=192.168.55.18
state="Full" state-changes=5 ls-retransmits=0 ls-requests=0 db-summaries=0
adjacency=32m17s

1 instance=default router-id=10.255.1.2 address=192.168.55.2 interface=ether1


priority=1 dr-address=192.168.55.2 backup-dr-address=192.168.55.1
state="Full" state-changes=5 ls-retransmits=0 ls-requests=0 db-summaries=0
adjacency=32m17s
[admin@R1] /routing ospf neighbor>

[admin@R1] /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 ADC 10.1.101.0/24 10.1.101.9 ether3 0
2 ADC 10.255.1.1/32 10.255.1.1 lo0 0
3 ADo 10.255.1.2/32 192.168.55.2 110
4 ADo 10.255.1.3/32 192.168.55.2 110
5 ADo 10.255.1.4/32 192.168.55.17 110
6 ADo 10.255.1.5/32 192.168.55.17 110
7 ADC 192.168.55.0/30 192.168.55.1 ether1 0
8 ADo 192.168.55.4/30 192.168.55.2 110
9 ADo 192.168.55.8/30 192.168.55.2 110
192.168.55.17
10 ADo 192.168.55.12/30 192.168.55.17 110
11 ADC 192.168.55.16/30 192.168.55.18 ether2 0
[admin@R1] /ip route>

Also make sure MPLS forwarding-table has label bindings

[admin@R1] /mpls forwarding-table> print


Flags: L - ldp, V - vpls, T - traffic-eng
# IN-LABEL OUT-LABELS DESTINATION I NEXTHOP
Manual:TE Tunnels Example 81

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 bridge add name=vpn

/interface vpls
add remote-peer=10.255.1.3 vpls-id=3:3

/interface bridge port


add interface=ether4 bridge=vpn
add interface=vpls1 bridge=vpn

R3

/interface bridge add name=vpn

/interface vpls
add remote-peer=10.255.1.1 vpls-id=3:3

/interface bridge port


add interface=ether4 bridge=vpn
add interface=vpls1 bridge=vpn

Make sure that VPLS tunnel is established and running

[admin@R1] /interface vpls> monitor 0 once


remote-label: 23
local-label: 23
remote-status:
transport: 10.255.1.3/32
transport-nexthop: 192.168.55.2
imposed-labels: 21,23

[admin@R1] /interface vpls>


Manual:TE Tunnels Example 82

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

# add interfaces on which to run RSVP


/mpls traffic-eng interface
add interface=ether1 bandwidth=10Mbps
add interface=ether2 bandwidth=10Mbps

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.

blockade-k-factor (integer; Default: 3) Value used to calculate blockade state timeout.

comment (string; Default: ) Short description of the item

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)

igp-flood-period (time; Default: 3m)

interface (string; Default: ) Name of an interface on which to run RSVP.

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.

resource-class (integer[0..FFFFFFFF]; Default: 0)

te-metric (integer; Default: 1)

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

remaining-bw (integer[bps]) Shows currently unallocated bandwidth.

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.

comment (string; Default: ) Short description of the item

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 >>

name (string; Default: ) Descriptive name of tunnel 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 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

bandwidth (integer[bps]) Bandwidth required for the path

dst (address:integer) Shows TE path destination address and tunnel ID.

egress (yes | no) Shows if router is egress router of the path

forwarding (yes | no) Shows if router is forwarding router of the path

in-interface (string) Interface on which path message is received.

in-previous-hop (IP) Recorded previous hop

label (integer)

locally-originated (yes | no) Shows if router is ingress router of the path

out-interface (string) Interface through which path message is sent out.

out-label (integer)

out-next-hop (IP)

path-in-explicit-route ()

path-in-record-route (List of IPs) Received recorded routes along the path.

path-out-explicit-route ()

path-out-record-route () List of recorded routes along the path that is sent out to next hop.

resv-bandwidth (integer[bps]) bandwidth that TE path is reserving.

resv-out-record-route ()

sending-path (yes | no) Whether path messages are being sent

sending-resv (yes | no) Whether resv messages are being sent

src (Address:ID) Shows source address and LSP ID number

Resv State
Sub-menu: /mpls traffic-eng resv-state
Available read only properties:

Property Description

active (yes | no) Shows whether reservation is active.

bandwidth Bandwidth that RSVP session is allocating.


(integer[bps])

dst (address:ID) Shows TE destination address and tunnel ID from RSVP session.

egress (yes | no) Shows if router is egress router of the path

interface (string) Shows an interface on which bandwidth is reserved

label (integer)

next-hop ()

non-output (yes | no)

recorded-route Shows recorded routes and labels along LSP.


(IP[label])

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.

Forwarding traffic onto TE tunnels


RSVP TE tunnel head-end appears as interface in RouterOS. Note that RSVP TE tunnels are unidirectional - it is not
necessary to have matching tunnel for reverse direction on tail-end router. When tail-end router receives data sent
over tunnel, it either receives it with TE tunnel label stripped off by penultimate hop (non-default behaviour) or with
explicit-null label, which gets stripped and packet is further inspected (if tunnel label is last label in stack, packet
gets routed, otherwise it is processed based on next label in stack, for example, as VPLS packet). Bidirectional
tunnel can be simulated by creating one tunnel in one direction and other in other direction between the same
endpoints. Still no data will be accounted as received over TE tunnel, as in reality both tunnels are unrelated.
One way to forward traffic onto tunnel is to use routing, but this limits TE tunnel to be used only for routing IP
packets.
Additionally, several types of traffic can be forwarded onto TE tunnel automatically, if it is known to be destined to
the endpoint of tunnel and if tunnel is active:
• traffic that is routed using route route learned from BGP, if BGP NextHop is tunnel endpoint (this default
behaviour can be changed by setting route porperty "use-te-nexthop" to "no"), both - regular IP and VPNv4
(MP-BGP IP VPN) routes fit in this category;
• traffic for VPLS interfaces, if remote endpoint of VPLS pseudowire is the same as TE tunnel endpoint.
For example, for IP BGP route having BGP NextHop x.x.x.x, forwarding method will be chosen according to the
following rules:
• if TE tunnel with endpoint x.x.x.x is active, use it;
• otherwise if LDP label mapping from next hop towards x.x.x.x is received, use it;
• otherwise use regular routing (no MPLS encapsulation).
In similar way, if remote address of VPLS pseudowire is x.x.x.x, forwarding method will be chosen in the following
order:
• if TE tunnel with endpoint x.x.x.x is active, use it;
• otherwise if LDP label mapping from next hop towards x.x.x.x is received, use it;
• otherwise VPLS tunnel can not be active.
Note that RSVP TE tunnels as a way to establish LSPs can be used together with LDP. Using RSVP TE does not
replace or disable LDP, but LSP established by TE is usually preferred over one established using LDP.
Manual:TE Tunnels 87

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.

Prerequisites for MPLS TE


In general, prerequisites for using MPLS TE are the same as mentioned in MPLSVPLS, but there are a few details:
• by default TE tunnel tail-end router advertises explicit null label, therefore penultimate hop popping does not
happen (the purpose of using explicit null label is to communicate QoS information in MPLS label Exp field), so
main purpose of having "loopback" IP address for every router is to have tunnel endpoints unaffected by link state
changes;
• in order to use CSPF path selection for tunnels, OSPF must be configured and running in network.

Enabling TE support
In order for OSPF to distribute TE information, TE related OSPF parameters must be set:

[admin@R1] > /routing ospf set mpls-te-area=backbone mpls-te-router-id=lobridge

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):

[admin@R1] > /mpls traffic-eng interface add interface=ether3 bandwidth=100000


Manual:TE Tunnels 88

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
...

Creating basic TE tunnel


Assume that we want to create TE tunnel from R1 to R5. In order to do this, tunnel path specification must be
created:

[admin@R1] > /mpls traffic-eng tunnel-path add use-cspf=yes name=dyn

This creates path template for purely dynamic path that will use CSPF.
Next, TE tunnel itself must be created:

[admin@R1] /interface traffic-eng> add name=te1 bandwidth=1000 primary-path=dyn \


from-address=9.9.9.1 to-address=9.9.9.5 disabled=no record-route=yes

We can monitor tunnel to see its state:


[admin@R1] /interface traffic-eng> monitor 0
tunnel-id: 7
primary-path-state: established
primary-path: dyn
secondary-path-state: not-necessary
active-path: dyn
active-lspid: 1
active-label: 29
explicit-route: "S:1.1.1.2/32,S:2.2.2.2/32,S:2.2.2.3/32,S:4.4.4.3/32,S:4.4.4.5/32"
recorded-route: "1.1.1.2[30],2.2.2.3[29],4.4.4.5[0]"
Manual:TE Tunnels 89

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:

[admin@R1] /interface vpls> monitor 0


remote-label: 24
local-label: 25
remote-status:
transport: te1
transport-nexthop: 1.1.1.2
imposed-labels: 30,24

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:

[admin@R2] > /mpls traffic-eng interface print


Flags: X - disabled, I - invalid
# INTERFACE BANDWIDTH TE-METRIC REMAINING-BW
0 ether1 100000 1 100000
1 ether2 100000 1 99000
Manual:TE tunnel auto bandwidth 90

Manual:TE tunnel auto bandwidth


Overview
By default MPLS TE tunnels do not apply any rate limitation on traffic that gets sent over tunnel. That way
"bandwidth" settings for MPLS TE enabled interfaces and TE tunnels are only used for reservation accounting.
There are also no means to adjust bandwidth that gets reserved for tunnel other than changing tunnel configuration
no matter what is actual amount of traffic sent over tunnel. To make TE tunnels more flexible and easy to use, the
following features have been introduced:
• Bandwidth limitation
• Automatic bandwidth adjustment
These features operate on tunnel head end (ingress) router. These features can either be used alone or in combination.

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:

[admin@R1] /interface traffic-eng> add name=te1 from-address=9.9.9.1 to-address=9.9.9.5 \


bandwidth=100000 bandwidth-limit=120 primary-path=stat

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:

[admin@R1] /interface traffic-eng> monitor te1


tunnel-id: 3
primary-path-state: established
primary-path: stat
secondary-path-state: not-necessary
active-path: stat
active-lspid: 1
active-label: 20
reserved-bandwidth: 100.0kbps
rate-limit: 120.0kbps
rate-measured-last: 0bps
rate-measured-highest: 0bps

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

Automatic bandwidth adjustment


Auto bandwidth adjustment feature enables MPLS TE network to follow the changes of amount of data transmitted
over tunnel. Bandwidth adjustment feature works as follows:
• Actual amount of data entering tunnel during averaging interval (auto-bandwidth-avg-interval) is measured,
producing average rate.
• Tunnel keeps track of highest average rate seen during update interval (auto-bandwidth-update-interval)
• When update interval expires, TE tunnel bandwidth is updated to highest observed average rate, taking into
account specified range over which bandwidth is allowed to change (auto-bandwidth-range)
Auto bandwidth adjustment feature gets enabled by specifying auto-bandwidth-range. For example, adding the
following tunnel:

[admin@R1] /interface traffic-eng> add name=te1 from-address=9.9.9.1 to-address=9.9.9.5 \


bandwidth=100000 primary-path=stat auto-bandwidth-range=10000-500000 \
auto-bandwidth-avg-interval=10s auto-bandwidth-update-interval=1m

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:

[admin@R1] /interface traffic-eng> monitor te1


tunnel-id: 3
primary-path-state: established
primary-path: stat
secondary-path-state: not-necessary
active-path: stat
active-lspid: 2
active-label: 21
reserved-bandwidth: 10.0kbps
rate-limit: 12.0kbps
rate-measured-last: 0bps
rate-measured-highest: 0bps

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:

[admin@R1] /interface traffic-eng> set te1 auto-bandwidth-reserve=30

In the beginning tunnel reserves its initially specified bandwidth:

[admin@R1] /interface traffic-eng> monitor te1


tunnel-id: 6
primary-path-state: established
primary-path: stat
secondary-path-state: not-necessary
active-path: stat
active-lspid: 1
Manual:TE tunnel auto bandwidth 92

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:

[admin@R1] /interface traffic-eng> monitor te1


tunnel-id: 6
primary-path-state: established
primary-path: stat
secondary-path-state: not-necessary
active-path: stat
active-lspid: 2
active-label: 28
reserved-bandwidth: 64.4kbps
rate-limit: 77.3kbps
rate-measured-last: 48.8kbps
rate-measured-highest: 48.8kbps

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:

[admin@R1] /interface traffic-eng> monitor te1


tunnel-id: 6
primary-path-state: established
primary-path: stat
secondary-path-state: not-necessary
active-path: stat
active-lspid: 2
active-label: 34
reserved-bandwidth: 63.4kbps
rate-limit: 12.0kbps
rate-measured-last: 0bps
rate-measured-highest: 0bps

After previous reservation (63.4kbps) is torn down, reserved-bandwidth correctly changes to 10kbps:

[admin@R1] /interface traffic-eng> monitor 1


tunnel-id: 6
primary-path-state: established
primary-path: stat
secondary-path-state: not-necessary
active-path: stat
active-lspid: 2
Manual:TE tunnel auto bandwidth 93

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.

Combining bandwidth limitation with automatic bandwidth adjustment


Auto bandwidth adjustment can be used in combination with bandwidth limit feature - bandwidth-limit setting will
apply to bandwidth actually reserved for tunnel. In order to successfully cobine both features, actual bandwidth must
be allowed to fluctuate to some extent - e.g. if bandwidth-limit will be configured to 100% (this effectively means
that rate will be limited to the bandwidth reserved for tunnel), tunnel will not have any chance to increase its
reservation. Therefore either bandwidth-limit should be configured to more than 100%, or
auto-bandwidth-reserve should be configured to more than 0%.

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

Firewall not work, because they rely on this feature.

List of features affected by connection tracking


• NAT
• firewall:
• connection-bytes
• connection-mark
• connection-type
• connection-state
• connection-limit
• connection-rate
• layer7-protocol
• p2p
• new-connection-mark
• p2p matching in simple queues

Manual:Routing Table Matcher


Sometimes ISP's are giving different local and overseas bandwidth. To set up QoS you had to make static address list
of local IP addresses, keep track of Ip ranges used in your country and update address list accordingly. Here you can
find article describing mentioned approach.
With introduction of routing-table matcher it is possible to match packet which destination address is resolved in
specific routing table. So we just need BGP peering with ISP and ask them to send all routes local to your country,
add them to routing table and set up mangle rules accordingly.
Note: It is not possible to match source address against routing table.

Consider following setup:

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

[admin@MikroTik] /ip route> print where bgp


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
..
1 ADb 10.10.1.0/24 10.1.101.1 20
2 ADb 10.10.10.4/32 10.1.101.1 20
Manual:Routing Table Matcher 95

Next step is to add all received BGP rotues to another routing table, to do that we set up routing filters

#at first we have to specify input filter chain


/routing bgp peer set 0 in-filter=bbgp

#now we set up filter itself


/routing filter
add action=passthrough chain=bbgp set-routing-mark=local

As you can see now routes are added to "local" routing table

[admin@MikroTik] /ip route> print detail where routing-mark="local"


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

...

1 ADb dst-address=10.10.1.0/24 gateway=10.1.101.1


gateway-status=10.1.101.1 reachable ether1 distance=20 scope=255
target-scope=255 routing-mark=local
bgp-as-path="3001,3001,3010,3002,3000" bgp-origin=incomplete
received-from=ISP

2 ADb dst-address=10.10.10.4/32 gateway=10.1.101.1


gateway-status=10.1.101.1 reachable ether1 distance=20 scope=255
target-scope=255 routing-mark=local
bgp-as-path="3001,3001,3010,3002,3000" bgp-origin=incomplete
bgp-communities=3000:120,3000:200 received-from=ISP

Following mangle rule will match all packets that destination is resolved in "local" routing table.

/ip firewall mangle


add action=log chain=forward routing-table=local

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.

/ip route rule


add action=lookup src-address=192.168.1.0/24 table=local

To verify if packets are actually matched:

[admin@MikroTik] /ip firewall mangle> print stats


Flags: X - disabled, I - invalid, D - dynamic
# CHAIN ACTION BYTES PACKETS
0 forward log 28736 449

Also check log messages

[admin@MikroTik] /log> print


...
Manual:Routing Table Matcher 96

11:06:31 firewall,info forward: in:bridge1 out:ether1, src-mac 00:0c:42:21:f1:ec


, proto ICMP (type 8, code 0), 192.168.1.10->10.10.10.4, len 44
11:06:32 firewall,info forward: in:bridge1 out:ether1, src-mac 00:0c:42:21:f1:ec
, proto ICMP (type 8, code 0), 192.168.1.10->10.10.10.4, len 44
...

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

Simple L7 usage example


First, add Regexp strings to the protocols menu, to define strings you will be looking for. In this example we will use
pattern to match bittorent packets.

/ip firewall layer7-protocol


add comment="" name=bittorrent regexp="^(\\x13bittorrent protocol|azver\\x01\$\
|get /scrape\\\?info_hash=get /announce\\\?info_hash=|get /client/bitcomet\
/|GET /data\\\?fid=)|d1:ad2:id20:|\\x08'7P\\)[RP]"

Then, use the defined protocols in firewall.

/ip firewall filter

# add few known protocols to reduce mem usage


add action=accept chain=forward comment="" disabled=no port=80 protocol=tcp
add action=accept chain=forward comment="" disabled=no port=443 protocol=tcp

# 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.

/ip firewall layer7-protocol


add comment="" name=telnet regexp=\
"^\\xff[\\xfb-\\xfe].\\xff[\\xfb-\\xfe].\\xff[\\xfb-\\xfe]"

Note that we need both directions that is why we need also l7 rule in output chain that sees outgoing packets.

/ip firewall filter

add action=accept chain=input comment="" disabled=no layer7-protocol=telnet \


protocol=tcp

add action=passthrough chain=output comment="" disabled=no layer7-protocol=telnet \


protocol=tcp

[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.

comment (string; Default: ) Descriptive comment for the rule.

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

content (string; Default: ) Match packets that contain specified text

dscp (integer: 0..63; Default: ) Matches DSCP IP header field.

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

hotspot (auth | from-client | http | local-dst | to-client; Default: )

icmp-options (integer:integer; Default: ) Matches ICMP type:code fileds

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

ipv4-options (any | loose-source-routing | no-record-route | Matches IPv4 header options.


no-router-alert | no-source-routing | no-timestamp | none | • any - match packet with at least one of the ipv4 options
record-route | router-alert | strict-source-routing | timestamp; Default: • loose-source-routing - match packets with loose source routing option.
) This option is used to route the internet datagram based on information
supplied by the source
• no-record-route - match packets with no record route option. This
option is used to route the internet datagram based on information
supplied by the source
• no-router-alert - match packets with no router alter option
• no-source-routing - match packets with no source routing option
• no-timestamp - match packets with no timestamp option
• record-route - match packets with record route option
• router-alert - match packets with router alter option
• strict-source-routing - match packets with strict source routing option
• timestamp - match packets with timestamp

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

out-interface (; Default: ) Interface the packet is leaving the router

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

tcp-mss (integer: 0..65535; Default: ) Matches TCP MSS value of an IP packet

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

ttl (integer: 0..255; Default: ) Matches packets TTL value

/ip firewall nat print stats will show additional read-only properties

Property Description

bytes (integer) Total amount of bytes matched by the rule

packets (integer) Total amount of packets matched by the rule

By default print is equivalent to print static and shows only static rules.

[admin@dzeltenais_burkaans] /ip firewall mangle> print stats


Flags: X - disabled, I - invalid, D - dynamic
# CHAIN ACTION BYTES PACKETS
0 prerouting mark-routing 17478158 127631
1 prerouting mark-routing 782505 4506

To print also dynamic rules use print all.


Manual:IP/Firewall/NAT 103

[admin@dzeltenais_burkaans] /ip firewall mangle> print all stats


Flags: X - disabled, I - invalid, D - dynamic
# CHAIN ACTION BYTES PACKETS
0 prerouting mark-routing 17478158 127631
1 prerouting mark-routing 782505 4506
2 D forward change-mss 0 0
3 D forward change-mss 0 0
4 D forward change-mss 0 0
5 D forward change-mss 129372 2031

Or to print only dynamic rules use print dynamic

[admin@dzeltenais_burkaans] /ip firewall mangle> print stats dynamic


Flags: X - disabled, I - invalid, D - dynamic
# CHAIN ACTION BYTES PACKETS
0 D forward change-mss 0 0
1 D forward change-mss 0 0
2 D forward change-mss 0 0
3 D forward change-mss 132444 2079

Property Description

reset-counters (id) Reset statistics counters for specified firewall rules.

reset-counters-all () Reset statistics counters for all firewall rules.

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:

/ip firewall nat add chain=srcnat action=masquerade out-interface=Public

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:

/ip address add address=10.5.8.200/32 interface=Public

Add rule allowing access to the internal server from external networks:

/ip firewall nat add chain=dstnat dst-address=10.5.8.200 action=dst-nat \


to-addresses=192.168.0.109

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

/ip firewall nat add chain=srcnat src-address=192.168.0.109 action=src-nat \


to-addresses=10.5.8.200

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.

/ip firewall nat add chain=dstnat dst-address=11.11.11.1-11.11.11.254 \


action=netmap to-addresses=2.2.2.1-2.2.2.254

/ip firewall nat add chain=srcnat src-address=2.2.2.1-2.2.2.254 \


action=netmap to-addresses=11.11.11.1-11.11.11.254

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.

comment (string; Default: ) Descriptive comment for the rule.

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

content (string; Default: ) Match packets that contain specified text

dscp (integer: 0..63; Default: ) Matches DSCP IP header field.

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

hotspot (auth | from-client | http | local-dst | to-client; Default: )

icmp-options (integer:integer; Default: ) Matches ICMP type:code fileds

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

ipv4-options (any | loose-source-routing | no-record-route | Matches IPv4 header options.


no-router-alert | no-source-routing | no-timestamp | none | • any - match packet with at least one of the ipv4 options
record-route | router-alert | strict-source-routing | timestamp; Default: • loose-source-routing - match packets with loose source routing option.
) This option is used to route the internet datagram based on information
supplied by the source
• no-record-route - match packets with no record route option. This
option is used to route the internet datagram based on information
supplied by the source
• no-router-alert - match packets with no router alter option
• no-source-routing - match packets with no source routing option
• no-timestamp - match packets with no timestamp option
• record-route - match packets with record route option
• router-alert - match packets with router alter option
• strict-source-routing - match packets with strict source routing option
• timestamp - match packets with timestamp

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

new-connection-mark (string; Default: )

new-dscp (integer: 0..63; Default: )

new-mss (integer; Default: )

new-packet-mark (string; Default: )

new-priority (integer; Default: )

new-routing-mark (string; Default: )

new-ttl (decrement | increment | set:integer; Default: )

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

out-interface (; Default: ) Interface the packet is leaving the router

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

tcp-mss (integer: 0..65535; Default: ) Matches TCP MSS value of an IP packet

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

bytes (integer) Total amount of bytes matched by the rule

packets (integer) Total amount of packets matched by the rule

By default print is equivalent to print static and shows only static rules.

[admin@dzeltenais_burkaans] /ip firewall mangle> print stats


Flags: X - disabled, I - invalid, D - dynamic
# CHAIN ACTION BYTES PACKETS
0 prerouting mark-routing 17478158 127631
1 prerouting mark-routing 782505 4506

To print also dynamic rules use print all.

[admin@dzeltenais_burkaans] /ip firewall mangle> print all stats


Flags: X - disabled, I - invalid, D - dynamic
# CHAIN ACTION BYTES PACKETS
0 prerouting mark-routing 17478158 127631
1 prerouting mark-routing 782505 4506
2 D forward change-mss 0 0
3 D forward change-mss 0 0
4 D forward change-mss 0 0
5 D forward change-mss 129372 2031

Or to print only dynamic rules use print dynamic

[admin@dzeltenais_burkaans] /ip firewall mangle> print stats dynamic


Flags: X - disabled, I - invalid, D - dynamic
# CHAIN ACTION BYTES PACKETS
0 D forward change-mss 0 0
1 D forward change-mss 0 0
2 D forward change-mss 0 0
3 D forward change-mss 132444 2079

Menu specific commands


Property Description

reset-counters (id) Reset statistics counters for specified firewall rules.

reset-counters-all () Reset statistics counters for all firewall 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

add chain=forward protocol=tcp port=!80 dst-address-list=first action=mark-packet new-packet-mark=first

add chain=forward protocol=udp dst-address-list=second action=mark-packet new-packet-mark=second

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

add chain=forward protocol=tcp port=!80 dst-address-list=first connection-state=new action=mark-connection \

new-connection-mark=first

add chain=forward connection-mark=first action=mark-packet new-packet-mark=first passthrough=no

add chain=forward protocol=udp dst-address-list=second connection-state=new action=mark-connection \

new-connection-mark=second

add chain=forward connection-mark=second action=mark-packet new-packet-mark=second passthrough=no

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.

comment (string; Default: ) Descriptive comment for the rule.

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

content (string; Default: ) Match packets that contain specified text

dscp (integer: 0..63; Default: ) Matches DSCP IP header field.

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

hotspot (auth | from-client | http | local-dst | to-client; Default: )

icmp-options (integer:integer; Default: ) Matches ICMP type:code fileds

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>>

ipv4-options (any | loose-source-routing | no-record-route | Matches IPv4 header options.


no-router-alert | no-source-routing | no-timestamp | none | • any - match packet with at least one of the ipv4 options
record-route | router-alert | strict-source-routing | timestamp; Default: • loose-source-routing - match packets with loose source routing option.
) This option is used to route the internet datagram based on information
supplied by the source
• no-record-route - match packets with no record route option. This
option is used to route the internet datagram based on information
supplied by the source
• no-router-alert - match packets with no router alter option
• no-source-routing - match packets with no source routing option
• no-timestamp - match packets with no timestamp option
• record-route - match packets with record route option
• router-alert - match packets with router alter option
• strict-source-routing - match packets with strict source routing option
• timestamp - match packets with timestamp

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

out-interface (; Default: ) Interface the packet is leaving the router

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.

reject-with (; Default: ) Specifies error to be sent back if packet is rejected. Applicable if


action=reject

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

tcp-mss (integer: 0..65535; Default: ) Matches TCP MSS value of an IP packet

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 (integer: 0..255; Default: ) Matches packets TTL value


Manual:IP/Firewall/Filter 116

Stats
/ip firewall filter print stats will show additional read-only properties

Property Description

bytes (integer) Total amount of bytes matched by the rule

packets (integer) Total amount of packets matched by the rule

By default print is equivalent to print static and shows only static rules.

[admin@dzeltenais_burkaans] /ip firewall mangle> print stats


Flags: X - disabled, I - invalid, D - dynamic
# CHAIN ACTION BYTES PACKETS
0 prerouting mark-routing 17478158 127631
1 prerouting mark-routing 782505 4506

To print also dynamic rules use print all.

[admin@dzeltenais_burkaans] /ip firewall mangle> print all stats


Flags: X - disabled, I - invalid, D - dynamic
# CHAIN ACTION BYTES PACKETS
0 prerouting mark-routing 17478158 127631
1 prerouting mark-routing 782505 4506
2 D forward change-mss 0 0
3 D forward change-mss 0 0
4 D forward change-mss 0 0
5 D forward change-mss 129372 2031

Or to print only dynamic rules use print dynamic

[admin@dzeltenais_burkaans] /ip firewall mangle> print stats dynamic


Flags: X - disabled, I - invalid, D - dynamic
# CHAIN ACTION BYTES PACKETS
0 D forward change-mss 0 0
1 D forward change-mss 0 0
2 D forward change-mss 0 0
3 D forward change-mss 132444 2079
Manual:IP/Firewall/Filter 117

Menu specific commands


Property Description

reset-counters (id) Reset statistics counters for specified firewall rules.

reset-counters-all () Reset statistics counters for all firewall 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.

/ip firewall filter


add chain=input connection-state=invalid action=drop \
comment="Drop Invalid connections"
add chain=input connection-state=established action=accept \
comment="Allow Established connections"
add chain=input protocol=icmp action=accept \
comment="Allow ICMP"
add chain=input src-address=192.168.0.0/24 action=accept \
in-interface=!ether1
add chain=input action=drop comment="Drop everything else"

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:

/ip firewall filter


add chain=forward protocol=tcp connection-state=invalid \
action=drop comment="drop invalid connections"
add chain=forward connection-state=established action=accept \
comment="allow already established connections"
add chain=forward connection-state=related action=accept \
comment="allow related connections"

Block "bogon" IP addresses

add chain=forward src-address=0.0.0.0/8 action=drop


add chain=forward dst-address=0.0.0.0/8 action=drop
add chain=forward src-address=127.0.0.0/8 action=drop
add chain=forward dst-address=127.0.0.0/8 action=drop
add chain=forward src-address=224.0.0.0/3 action=drop
add chain=forward dst-address=224.0.0.0/3 action=drop

Make jumps to new chains:

add chain=forward protocol=tcp action=jump jump-target=tcp


add chain=forward protocol=udp action=jump jump-target=udp
Manual:IP/Firewall/Filter 118

add chain=forward protocol=icmp action=jump jump-target=icmp

Create tcp chain and deny some tcp ports in it:

add chain=tcp protocol=tcp dst-port=69 action=drop \


comment="deny TFTP"
add chain=tcp protocol=tcp dst-port=111 action=drop \
comment="deny RPC portmapper"
add chain=tcp protocol=tcp dst-port=135 action=drop \
comment="deny RPC portmapper"
add chain=tcp protocol=tcp dst-port=137-139 action=drop \
comment="deny NBT"
add chain=tcp protocol=tcp dst-port=445 action=drop \
comment="deny cifs"
add chain=tcp protocol=tcp dst-port=2049 action=drop comment="deny NFS"
add chain=tcp protocol=tcp dst-port=12345-12346 action=drop comment="deny NetBus"
add chain=tcp protocol=tcp dst-port=20034 action=drop comment="deny NetBus"
add chain=tcp protocol=tcp dst-port=3133 action=drop comment="deny BackOriffice"
add chain=tcp protocol=tcp dst-port=67-68 action=drop comment="deny DHCP"

Deny udp ports in udp chain:

add chain=udp protocol=udp dst-port=69 action=drop comment="deny TFTP"


add chain=udp protocol=udp dst-port=111 action=drop comment="deny PRC portmapper"
add chain=udp protocol=udp dst-port=135 action=drop comment="deny PRC portmapper"
add chain=udp protocol=udp dst-port=137-139 action=drop comment="deny NBT"
add chain=udp protocol=udp dst-port=2049 action=drop comment="deny NFS"
add chain=udp protocol=udp dst-port=3133 action=drop comment="deny BackOriffice"

Allow only needed icmp codes in icmp chain:

add chain=icmp protocol=icmp icmp-options=0:0 action=accept \


comment="echo reply"
add chain=icmp protocol=icmp icmp-options=3:0 action=accept \
comment="net unreachable"
add chain=icmp protocol=icmp icmp-options=3:1 action=accept \
comment="host unreachable"
add chain=icmp protocol=icmp icmp-options=4:0 action=accept \
comment="allow source quench"
add chain=icmp protocol=icmp icmp-options=8:0 action=accept \
comment="allow echo request"
add chain=icmp protocol=icmp icmp-options=11:0 action=accept \
comment="allow time exceed"
add chain=icmp protocol=icmp icmp-options=12:0 action=accept \
comment="allow parameter bad"
add chain=icmp action=drop comment="deny all other types"
Manual:IP/Firewall/Filter 119

Brute force protection


Bruteforce_login_prevention_(FTP_&_SSH)
[Back to Content]

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)

name (name; Default: none) Service name

port (integer: 1..65535; Default: ) The port particular service listens on

Example
For example allow telnet only from specific IPv6 address range

[admin@dzeltenais_burkaans] /ip service> set api address=10.5.101.0/24,2001:db8:fade::/64


[admin@dzeltenais_burkaans] /ip service> print
Flags: X - disabled, I - invalid
# NAME PORT ADDRESS CERTIFICATE
0 telnet 23
1 ftp 21
2 www 80
3 ssh 22
4 X www-ssl 443 none
5 api 8728 10.5.101.0/24
2001:db8:fade::/64
6 winbox 8291
Manual:IP/Services 121

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

FTP FTP service helper

h323 H323 service helper

irc

PPTP PPTP tunneling helper.

SIP

tftp

Protocols and ports


Table below shows the list of protocols and ports used by RouterOS.

Proto/Port Description

20/tcp FTP data connection

21/tcp FTP control connection

22/tcp Secure Shell (SSH) remote Login protocol

23/tcp Telnet protocol

53/tcp DNS
53/udp

67/udp Bootstrap protocol or DHCP Server

68/udp Bootstrap protocol or DHCP Client

80/tcp World Wide Web HTTP

123/udp Network Time Protocol ( NTP)

161/udp Simple Network Management Protocol (SNMP)

179/tcp Border Gateway Protocol ( BGP)

443/tcp Secure Socket Layer (SSL) encrypted HTTP

500/udp Internet Key Exchange (IKE) protocol

520/udp RIP routing protocol


521/udp

646/tcp LDP transport session

646/udp LDP hello protocol

1080/tcp SOCKS proxy protocol

1701/udp Layer 2 Tunnel Protocol ( L2TP)

1723/tcp Point-To-Point Tunneling Protocol ( PPTP)

1900/udp Universal Plug and Play ( uPnP)


2828/tcp
Manual:IP/Services 122

2000/tcp Bandwidth test server

5678/udp Mikrotik Neighbor Discovery Protocol

8080/tcp HTTP Web Proxy

8291/tcp Winbox

8728/tcp API

20561/udp MAC winbox

/1 ICMP

/4 IPIP encapsulation

/41 IPv6 (encapsulation)

/47 General Routing Encapsulation (GRE) - used for PPTP and EoIP tunnels

/50 Encapsulating Security Payload for IPv4 (ESP)

/51 Authentication Header for IPv4 (AH)

/89 OSPF routing protocol

/103 Multicast | IGMP

/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

address (IP/Mask; Default: ) IP address

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

interface (name; Default: ) Interface name the IP address is assigned to

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)

Read only properties

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

address (IP; Default: ) IP address to be mapped

interface (string; Default: ) Interface name the IP address is assigned to

mac-address (MAC; Default: 00:00:00:00:00:00) MAC address to be mapped to

Read only properties:

Property Description

dhcp (yes | no) Whether ARP entry is added by DHCP server

dynamic (yes | no) Whether entry is dynamically created

invalid (yes | no) Whether entry is not valid

Note: Maximal number of ARP entries is 8192.

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:

C:\> arp -s 10.5.8.254 00-aa-00-62-c6-09

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

Routing Information Base

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:

• address part of dst-address of


connected route is equal to network
of ip address item.
• netmask part of dst-address of
connected route is equal to netmask part of address of ip address item.
• pref-src of connected route is equal to address part of address of ip address item.
• interface of connected route is equal to actual-interface of ip address item (same as interface, except for bridge
interface ports).

Multipath (ECMP) routes

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.

Routes with interface as a gateway


Value of gateway can be specified as an interface name instead of the nexthop IP address. Such route has following
special properties:
• Unlike connected routes, routes with interface nexthops are not used for nexthop lookup.
• It is possible to assign several interfaces as a value of gateway, and create ECMP route. It is not possible to have
connected route with multiple gateway values.
Manual:IP/Route 128

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.

Criteria for selecting candidate routes


To participate in route selection process, route has to meet following criteria:
• route is not disabled.
• distance is not 255. Routes that are rejected by route filter have distance value of 255.
• pref-src is either not set or is a valid local address of the router.
• routing-mark is either not set or is referred by firewall or policy routing rules.
• If type of route is unicast and it is not a connected route, it must have at least one reachable nexthop.

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.

Recursive nexthop lookup example

• nexthop 10.2.0.1 is resolved through a connected route, it's status is reachable.


• nexthop 10.3.0.1 is resolved recursively through a 10.3.0.0/16 route, it's status is recursive, and it uses 10.2.0.1 as the immediate nexthop value
that is installed in the FIB.

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

Forwarding Information Base


FIB (Forwarding Information Base)
contains copy of information that is
necessary for packet forwarding:
• all active routes
• policy routing rules
By default (when no routing-mark
values are used) all active routes are in
the main table, and there is only one
hidden implicit rule ("catch all" rule)
that uses the main table for all
destination lookups.

Routing table lookup


FIB uses following information from
packet to determine it's destination:
• source address
• destination address
• source interface
• routing mark
• ToS (not used by RouterOS in policy routing rules, but it is a part of routing cache lookup key)
Possible routing decisions are:
• receive packet locally
• discard packet (either silently or by sending ICMP message to the sender of the packet)
• send packet to specific IP address on specific interface
Results of routing decision are remembered in the routing cache. This is done to improve forwarding performance.
When another packet with the same source address, destination address, source interface, routing mark and ToS
is routed, cached results are used. This also allows to implement per-connection load balancing using ECMP routes,
because values used to lookup entry in the routing cache are the same for all packets that belong to the same
connection and go in the same direction.
If there is no routing cache entry for this packet, it is created by running routing decision:
• check that packet has to be locally delivered (destination address is address of the router)
• process implicit policy routing rules
• process policy routing rules added by user
• process implicit catch-all rule that looks up destination in the main routing table
• return result is "network unreachable"
Manual:IP/Route 131

Result of routing decision can be:

• IP address of nexthop + interface


• point-to-point interface
• local delivery
• discard
• ICMP prohibited
• ICMP host unreachable
• ICMP network unreachable

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.

connect (C) connected route.

static (S) static route.

rip (r) RIP route.

bgp (b) BGP route.

ospf (o) OSPF route.

mme (m) MME route.

blackhole (B) Silently discard packet forwarded by this route.

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.

comment (string; Default: Description of particular route


"")

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.

vrf-interface (string; VRF interface name


Default: "10")
Manual:IP/Route 133

Other Read-only properties

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-metric Used OSPF metric for particular route


(integer)

ospf-type (string)

BGP Route Properties


These properties contain information that is used by BGP routing protocol. However, values of these properties can
be set for any type of route, including static and connected. It can be done either manually (for static routes) or using
route filters.

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-atomic-aggregate (yes | no; Default: ) Value of BGP ATOMIC_AGGREGATE attribute.

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-ext-communities Value of BGP extended communities attribute


(string)

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.

Manual:Virtual Routing and Forwarding


Applies to RouterOS: 3, v4

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

prefixes distributed in BGP.


Please note that a VPNv4 route will be distributed only if it has a valid MPLS label. You need to install mpls-test
package and configure valid label range for this to work. (Default configuration has valid label range.)

Examples

The simplest MPLS VPN setup

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

PE2 Router (Cisco)


ip vrf cust-one
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.3 255.255.255.255

mpls ldp router-id Loopback0 force


mpls label protocol ldp

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

router bgp 65000


neighbor 10.5.5.2 remote-as 65000
neighbor 10.5.5.2 update-source Loopback0
address-family vpnv4
neighbor 10.5.5.2 activate
neighbor 10.5.5.2 send-community both
exit-address-family
address-family ipv4 vrf cust-one
redistribute connected
exit-address-family

ip route 10.5.5.2 255.255.255.255 10.2.2.2

Results
Check that VPNv4 route redistribution is working:

[admin@PE1] > /routing bgp vpnv4-route print detail


Flags: L - label present
0 L route-distinguisher=1.1.1.1:111 dst-address=10.3.3.0/24 gateway=10.5.5.3
interface=ether2 in-label=17 out-label=17 bgp-local-pref=100 bgp-med=0
bgp-origin=incomplete bgp-ext-communities="RT:1.1.1.1:111"

1 L route-distinguisher=1.1.1.1:111 dst-address=10.1.1.0/24 interface=ether1


in-label=16 bgp-ext-communities="RT:1.1.1.1:111"

Check that the 10.3.3.0 is installed in IP routes, in cust-one route table:


Manual:Virtual Routing and Forwarding 137

[admin@PE1] > /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 ADC 10.1.1.0/24 10.1.1.2 ether1 0
1 ADb 10.3.3.0/24 10.5.5.3 recursi... 20
2 ADC 10.2.2.0/24 10.2.2.2 ether2 0
3 ADC 10.5.5.2/32 10.5.5.2 lobridge 0
4 A S 10.5.5.3/32 10.2.2.3 reachab... 1

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.

[admin@PE1] /ip route> print detail where routing-mark=cust-one


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
0 ADC dst-address=10.1.1.0/24 pref-src=10.1.1.2 gateway=ether1 distance=0 scope=10
routing-mark=cust-one

1 ADb dst-address=10.3.3.0/24 gateway=10.5.5.3 recursive via 10.2.2.3 ether2


distance=20 scope=40 target-scope=30 routing-mark=cust-one
bgp-local-pref=100 bgp-origin=incomplete
bgp-ext-communities="RT:1.1.1.1:111"

The same for Cisco:

PE2#show ip bgp vpnv4 all


BGP table version is 5, local router ID is 10.5.5.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

Network Next Hop Metric LocPrf Weight Path


Route Distinguisher: 1.1.1.1:111 (default for vrf cust-one)
*>i10.1.1.0/24 10.5.5.2 100 0 ?
*> 10.3.3.0/24 0.0.0.0 0 32768 ?

PE2#show ip route vrf cust-one

Routing Table: cust-one


Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
Manual:Virtual Routing and Forwarding 138

ia - IS-IS inter area, * - candidate default, U - per-user static route


o - ODR, P - periodic downloaded static route

Gateway of last resort is not set

10.0.0.0/24 is subnetted, 1 subnets


B 10.1.1.0 [200/0] via 10.5.5.2, 00:05:33
10.0.0.0/24 is subnetted, 1 subnets
C 10.3.3.0 is directly connected, FastEthernet1/0

You should be able to ping from CE1 to CE2 and vice versa.

[admin@CE1] > /ping 10.3.3.4


10.3.3.4 64 byte ping: ttl=62 time=18 ms
10.3.3.4 64 byte ping: ttl=62 time=13 ms
10.3.3.4 64 byte ping: ttl=62 time=13 ms
10.3.3.4 64 byte ping: ttl=62 time=14 ms
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max = 13/14.5/18 ms

A more complicated setup (changes only)

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

CE1 Router, cust-one


/ip route add dst-address=10.4.4.0/24 gateway=10.1.1.2

CE2 Router, cust-one


/ip route add dst-address=10.4.4.0/24 gateway=10.3.3.3

CE1 Router, cust-two


/ip address add address=10.4.4.5 interface=ether1
/ip route add dst-address=10.1.1.0/24 gateway=10.3.3.3
/ip route add dst-address=10.3.3.0/24 gateway=10.3.3.3

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

PE2 Router (Cisco)


ip vrf cust-one
rd 1.1.1.1:111
route-target export 1.1.1.1:111
route-target import 1.1.1.1:111
route-target import 2.2.2.2:222
exit

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

router bgp 65000


address-family ipv4 vrf cust-two
redistribute connected
exit-address-family
Manual:Virtual Routing and Forwarding 140

Variation: replace the Cisco with another MT

PE2 Mikrotik config


/interface bridge add name=lobridge
/ip address
add address=10.2.2.3/24 interface=ether1
add address=10.3.3.3/24 interface=ether2
add address=10.4.4.3/24 interface=ether3
add address=10.5.5.3/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,2.2.2.2:222 \
interfaces=ether2
add disabled=no routing-mark=cust-two route-distinguisher=2.2.2.2:222 \
export-route-targets=2.2.2.2:222 import-route-targets=1.1.1.1:111,2.2.2.2:222 \
interfaces=ether3
/mpls ldp set enabled=yes transport-address=10.5.5.3
/mpls ldp interface add interface=ether1
/routing bgp instance set default as=65000
/routing bgp instance vrf add instance=default routing-mark=cust-one redistribute-connected=yes
/routing bgp instance vrf add instance=default routing-mark=cust-two redistribute-connected=yes
/routing bgp peer add remote-address=10.5.5.2 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.2/32 gateway=10.2.2.2

Results
The output of /ip route print now is interesting enough to deserve detailed observation.

[admin@PE2] /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 ADb 10.1.1.0/24 10.5.5.2 recurs... 20
1 ADC 10.3.3.0/24 10.3.3.3 ether2 0
2 ADb 10.4.4.0/24 20
3 ADb 10.1.1.0/24 10.5.5.2 recurs... 20
4 ADb 10.3.3.0/24 20
5 ADC 10.4.4.0/24 10.4.4.3 ether3 0
6 ADC 10.2.2.0/24 10.2.2.3 ether1 0
7 A S 10.5.5.2/32 10.2.2.2 reacha... 1
8 ADC 10.5.5.3/32 10.5.5.3 lobridge 0

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.)

[admin@PE2] /ip route> print detail where routing-mark=cust-one


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
0 ADb dst-address=10.1.1.0/24 gateway=10.5.5.2 recursive via 10.2.2.2 ether1
distance=20 scope=40 target-scope=30 routing-mark=cust-one
bgp-local-pref=100 bgp-origin=incomplete
bgp-ext-communities="RT:1.1.1.1:111"

1 ADC dst-address=10.3.3.0/24 pref-src=10.3.3.3 gateway=ether2 distance=0 scope=10


routing-mark=cust-one

2 ADb dst-address=10.4.4.0/24 distance=20 scope=40 target-scope=10


routing-mark=cust-one bgp-ext-communities="RT:2.2.2.2:222"

Static inter-VRF routes


In general it is recommended that all routes between VRF should be exchanged using BGP local import and export
functionality. If that is not enough, static routes can be used to achieve this so-called route leaking.
There are two ways to install a route that has gateway in different routing table than the route itself.
The first way is to explicitly specify routing table in gateway field when adding route. This is only possible for the
"main" routing table. Example:

# 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:

add dst-address=1.2.3.0/24 gateway=ether2 routing-mark=main


Manual:Virtual Routing and Forwarding 142

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-other-ospf (as-type-1 | redistribute routes learned by other OSPF instances


as-type-2 | no; Default: no)

redistribute-rip (as-type-1 | as-type-2 | no; redistribute routes learned by the RIP protocol
Default: no)

redistribute-static (as-type-1 | as-type-2 | redistribute static routes


no; 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

state (down | running) shows if OSPF is running or not

effective-router-id (IP address) Router-ID chosen by OSPF.

dijkstras (integer) shows how many times Dijkstra's algorithm was executed (i.e. OSPF routes were recalculated)

db-exchanges (integer) number of OSPF database exchanges currently going on

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)

name (string; Default: ) the name of the area

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

type (default | nssa | stub; Default: area type


default)
Manual:Routing/OSPF 145

Status
/routing ospf area print status will show additional read-only properties

Property Description

interfaces (integer;) count of interfaces assigned to this area

active-interfaces (integer;) count of interfaces in operating state assigned to this area

neighbors (integer;) count of OSPF neighbors in this area

adjacent-neighbors (integer;) count of adjacent OSPF neighbors in this area

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)

range (IP prefix; Default: ) the network prefix of 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

interface (string | all; Default: all) the interface name


• all - for all interfaces without specific configuration

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

ip-address (IP address;) Ip address assigned to this interface

state (backup | designated-router;) current interface state

instance (instance name;) OSPF instance that is using this interface

area (area name;) area to which interface is assigned

neighbors (integer;) count of OSPF neighbors found on this interface

adjacent-neighbors (integer;) count of OSPF neighbors found on this interface that have formed adjacencies

designated-router (IP address;) router-ID of elected designated router (DR)

backup-designated-router (IP address;) router-ID of elected backup designated router (BDR)

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

address (IP address; Default: ) the unicast IP address of the neighbor

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

authentication-key-id (integer; Default: 1) key id used in MD5 authentication

neighbor-id (IP address; Default: 0.0.0.0) specifies router-id of the neighbour

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

instance (string) Instance name where LSA is used.

area (string)

type (string)

id (IP address) LSA record ID

originator (IP address) LSA record originator

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

checksum (string) LSA checksum

options (string)

body (string)

Neighbor
Sub-menu: /routing ospf Neighbor
Read only properties:

Property Description

router-id (IP address) neighbor router's RouterID

address (IP address) IP address of neighbor router that is used to form OSPF connection

interface (string) interface that neighbor router is connected to

priority (integer) priority configured on neighbor

dr-address (IP address) IP address of Designated Router

backup-dr-address (IP address) IP address of Backup Designated Router


Manual:Routing/OSPF 149

state (down | attempt | init | 2-way | • Down - no Hello packets received


ExStart | Exchange | Loading | full) • Attempt - applies only to NBMA clouds. State indicates that no recent information was received
from neighbor.
• Init - Hello packet received from the neighbor, but bidirectional communication is not established.
• 2-way - router has seen itself in Hello packet of neighbor router. DR and BDR election occur during
this state, routers build adjacencies based on whether router is DR or BDR, link is point-to-point or a
virtual link.
• ExStart - routers try to establish the initial sequence number that is used for the packets information
exchange.
• Exchange - routers exchange database description (DD) packets.
• Loading - Link State Request packets are sent to neighbors to request any new LSAs that were
found during Exchange state.
• Full - adjacency is complete, neighbor routers are fully adjacent. LSA information is synchronized
between adjacent routers.

state-changes (integer) Total count of OSPF state changes since neighbor identification

ls-retransmits (integer)

ls-requests (integer)

db-summaries (integer)

adjacency (time) Elapsed time since adjacency was formed

OSPF Router
Sub-menu: /routing ospf ospf-router
List of all area border routers (ABRs).
Read only properties:

Property Description

area (string)

router-id (IP address)

state (string)

gateway (IP address)

cost (integer)

Route
Sub-menu: /routing ospf route
Read only properties:
Manual:Routing/OSPF 150

Property Description

instance (string) Which OSPF instance route belongs to

dst-address (IP prefix) Destination prefix

state (intra-area | inter-area | ext-1 | ext-2 | imported-ext-1 | imported-ext-2) State representing origin of the route

gateway (IP address) used gateway

interface (string) used interface

cost (integer) Cost 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

cost (integer: 1..65535 ) cost of the link

dst-address (IP address) loopback address of link's remote router

src-address (IP address) loopback address of link's local router

See More
• OSPF case studies
• OSPF Configuration Examples
[Back to Content]
Manual:OSPF Case Studies 151

Manual:OSPF Case Studies


Applies to RouterOS: v3, v4

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

• Broadcast - Network that allows broadcasting, for example Ethernet.


• Point-to-point - Network type eliminates the need for DRs and BDRs
• Router-ID - IP address used to identify OSPF router. If the OSPF Router-ID is not configured manually, router
uses one of the IP addresses assigned to the router as its Router-ID.
All of these terms are important for understanding the operation of the OSPF and they are used throughout the
article.

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

Communication between OSPF routers


OSPF runs directly over the IP network layer using protocol number 89.
Destination IP address is set to neighbor's IP address or to one of the OSPF multicast addresses AllSPFRouters
(224.0.0.5) or AllDRRouters (224.0.0.6). Use of these addresses are described later in this article.
Every OSPF packet begins with standard 24-byte header.
Manual:OSPF Case Studies 153

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

Router ID one of router's IP addresses unless configured manually

Area ID Allows OSPF router to associate the packet to the proper OSPF area.

Checksum Allows receiving router to determine if packet was damaged in transit.

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

network mask The IP mask of the originating router's interface IP address.

hello interval period between Hello packets (default 10s)

options OSPF options for neighbor information

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)

DR the router-id of the current DR

BDR the router-id of the current BDR

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.

Discovery on Broadcast Subnets

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:

• Automatic neighbor discovery by multicasting or broadcasting Hello packets.


• Less bandwidth usage compared to other subnet types. On broadcast segment there are n*(n-1)/2 neighbor
relations, but those relations are maintained by sending only n Hellos.
• If broadcast has multicast capability, then OSPF operates without disturbing non-OSPF nodes on the
broadcast segment. If multicast capability is not supported all routers will receive broadcasted Hello packet
even if node is not OSPF router.

Discovery on NBMA Subnets


Nonbroadcast multiaccess (NBMA) segments similar to broadcast supports more than two routers, only difference is
that NBMA do not support data-link broadcast capability. Due to this limitation OSPF neighbors must be discovered
initially through configuration. On RouterOS NBMA configuration is possible in/routig ospf nbma-neighbor menu.
To reduce the amount of Hello traffic, most routers attached to NBMA subnet should be assigned Router Priority of
0 (set by default in RouterOS). Routers that are eligible to become Designated Routers should have priority values
other than 0. It ensures that during election of DR and BDR Hellos are sent only to eligible routers.
Manual:OSPF Case Studies 155

Discovery on PTMP Subnets


On PTMP subnets Hello protocol is used only to detect active OSPF neighbors and to detect bidirectional
communication between neighbors. Routers on PTMP subnets send Hello packets to all other routers that are directly
connected to them. Designated Routers and Backup Designated routers are not elected on Point-to-multipoint
subnets.

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:

• initial database synchronization


• reliable flooding.
When the connection between two neighbors first come up, initial database synchronization will happen.
Unsynchronized databases may lead to calculation of incorrect routing table, resulting in routing loops or black
holes.
OSPF is using explicit database download when neighbor connections first come up. This procedure is called
Database exchange. Instead of sending the entire database, OSPF router sends only its LSA headers in a sequence
of OSPF Database Description (DD) packets. Router will send next DD packet only when previous packet is
acknowledged. When entire sequence of DD packets has been received, router knows which LSAs it does not have
and which LSAs are more recent. The router then sends Link-State Request (LSR) packets requesting desired
LSAs, and the neighbor responds by flooding LSAs in Link-State Update (LSU) packets. After all updates are
received neighbors are said to be fully adjacent.
Reliable flooding is another database synchronization method. It is used when adjacencies are already established
and OSPF router wants to inform other routers about LSA changes. When OSPF router receives such Link State
Update, it installs new LSA in link-state database, sends an acknowledgement packet back to sender, repackages
LSA in new LSU and sends it out all interfaces except the one that received the LSA in the first place.
OSPF determines if LSAs are up to date by comparing sequence numbers. Sequence numbers start with
0×80000001, the larger the number, the more recent the LSA is. Sequence number is incremented each time the
record is flooded and neighbor receiving update resets Maximum age timer. LSAs are refreshed every 30 minutes,
but without a refresh LSA remains in the database for maximum age of 60 minutes.
Databases are not always synchronized between all OSPF neighbors, OSPF decides whether databases needs to be
synchronized depending on network segment, for example, on point-to-point links databases are always
synchronized between routers, but on ethernet networks databases are synchronized between certain neighbor pairs.
Manual:OSPF Case Studies 156

Synchronization on Broadcast Subnets

On broadcast segment there are


n*(n-1)/2 neighbor relations, it will be
huge amount of Link State Updates
and Acknowledgements sent over the
subnet if OSPF router will try to
synchronize with each OSPF router on
the subnet.
This problem is solved by electing one
Designated Router and one Backup
Designated Router for each broadcast
subnet. All other routers are
synchronizing and forming adjacencies
only with those two elected routers.
This approach reduces amount of adjacencies from n*(n-1)/2 to only 2n-1.

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.

Synchronization on NBMA Subnets


Database synchronization on NBMA networks are similar as on broadcast networks. DR and BDR are elected,
databases initially are exchanged only with DR and BDR routers and flooding always goes through the DR. The only
difference is that Link State Updates must be replicated and sent to each adjacent router separately.

Synchronization on PTMP Subnets


On PTMP subnets OSPF router becomes adjacent to all other routes with which it can communicate directly.

Routing table calculation


When link-state databases are synchronized OSPF routers are able to calculate routing table.
Link state database describes the routers and links that interconnect them and are appropriate for forwarding. It also
contains the cost (metric) of each link. This metric is used to calculate shortest path to destination network.
Each router can advertise a different cost for the router's own link direction, making it possible to have asymmetric
links (packets to destination travels over one path, but response travels different path). Asymmetric paths are not
very popular, because it makes harder to find routing problems.
The Cost in RouterOS is set to 10 on all interfaces by default. Value can be changed in ospf interface configuration
menu, for example to add ether2 interface with cost of 100:
Manual:OSPF Case Studies 157

/routing ospf interface add interface=ether2 cost=100

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:

/ip address add address=172.16.0.1/24 interface=ether1


/routing ospf network add network=172.16.0.0/24 area=backbone

R2 configuration:

/ip address add address=172.16.0.2/24 interface=ether1


/routing ospf network add network=172.16.0.0/24 area=backbone

R3 configuration:

/ip address add address=172.16.0.3/24 interface=ether1


/routing ospf network add network=172.16.0.0/24 area=backbone

To verify if OSPF instance is running on router:

[admin@MikroTik] /routing ospf> monitor once


state: running
router-id: 172.16.0.1
dijkstras: 6
db-exchanges: 0
db-remote-inits: 0
db-local-inits: 0
external-imports: 0

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.

[admin@MikroTik] /routing ospf interface> print


Flags: X - disabled, I - inactive, D - dynamic, P - passive
# INTERFACE COST PRIORITY NETWORK-TYPE AUTHENTICATION AUTHENTICATION-KEY
0 D ether1 10 1 broadcast none

Next step is to verify, that both neighbors are found, DR and BDR is elected and adjacencies are established:

[admin@MikroTik] /routing ospf neighbor> print


0 router-id=172.16.0.2 address=172.16.0.2 interface=ether1 priority=1
dr-address=172.16.0.3 backup-dr-address=172.16.0.2 state="Full" state-changes=5
ls-retransmits=0 ls-requests=0 db-summaries=0 adjacency=9m2s

1 router-id=172.16.0.3 address=172.16.0.3 interface=ether1 priority=1


dr-address=172.16.0.3 backup-dr-address=172.16.0.2 state="Full" state-changes=5
ls-retransmits=0 ls-requests=0 db-summaries=0 adjacency=6m42s

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

[admin@MikroTik] /routing ospf lsa> print


AREA TYPE ID ORIGINATOR SEQUENCE-NUMBER AGE
backbone router 172.16.0.1 172.16.0.1 0x80000003 587
backbone router 172.16.0.2 172.16.0.2 0x80000003 588
backbone router 172.16.0.3 172.16.0.3 0x80000002 592
backbone network 172.16.0.3 172.16.0.3 0x80000002 587

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

Each area is identified by 32-bit Area


ID and has its own link-state database,
consisting of router-LSAs and
network-LSAs describing how all
routers within that area are
interconnected. Detailed knowledge of
area's topology is hidden from all other
areas; router-LSAs and network-LSAs
are not flooded beyond the area's
borders. Area Border Routers (ABRs)
leak addressing information from one
area into another in OSPF
summary-LSAs. This allows to pick
the best area border router when
forwarding data to destinations from
another area and is called intra-area
routing.

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.

External Routing Information


On the edge of an OSPF routing
domain, you can find routers called AS
boundary routers (ASBRs) that run
one of other routing protocols. The job
of those routers are to import routing
information learned from other routing
protocols into the OSPF routing
domain. External routes can be
imported at two separate levels
depending on metric type.

• 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.
OSPF provides several area types:
backbone area, standard area, stub area and not-so-stubby area. All areas are covered later in the article.
Manual:OSPF Case Studies 161

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.

Simple multi-area network


Consider the multi-area network shown below.

R1 configuration:

/ip address add address=10.0.3.1/24 interface=ether1


/ip address add address=10.0.2.1/24 interface=ether2
/routing ospf area add name=area1 area-id=1.1.1.1
/routing ospf network add network=10.0.2.0/24 area=backbone
/routing ospf network add network=10.0.3.0/24 area=area1

R2 configuration:

/ip address add address=10.0.1.1/24 interface=ether2


/ip address add address=10.0.2.2/24 interface=ether1
/routing ospf network add network=10.0.2.0/24 area=backbone

R3 configuration:

/ip address add address=10.0.3.2/24 interface=ether2


/ip address add address=10.0.4.1/24 interface=ether1
/routing ospf area add name=area1 area-id=1.1.1.1
/routing ospf network add network=10.0.3.0/24 area=area1

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:

/routing ospf set redistribute-connected=as-type-1


Manual:OSPF Case Studies 162

Check routing table to see that both networks are redistributed.

[admin@MikroTik] /ip route> print

Let's add another network to R3:

/ip address add address=10.0.5.1/24 interface=ether1

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 filter add chain=ospf-out prefix=10.0.5.0/24 action=discard

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.

No physical connection to backbone

Area may not have physical connection


to backbone, virtual link is used to
provide logical path to the backbone of
the disconnected area. Link has to be
established between two ABRs that
have common area with one ABR
connected to the backbone.
We can see that both R1 and R2
routers are ABRs and R1 is connected
to backbone area. Area2 will be used
as transit area and R1 is the entry
point into backbone area. Virtual link
has to be configured on both routers.

R1 configuration:

/routing ospf virtual-link add transit-area=area2 neighbor-id=2.2.2.2

R2 configuration:

/routing ospf virtual-link add transit-area=area2 neighbor-id=1.1.1.1


Manual:OSPF Case Studies 163

Partitioned backbone

OSPF allows to link discontinuous


parts of the backbone area using virtual
links. This might be required when two
separate OSPF networks are merged
into one large network. Virtual link can
be configured between separate ABRs
that touch backbone area from each
side and have a common area.
Additional area could be created to
become transit area, when common
area does not exist, it is illustrated in
the image above.
Virtual Links are not required for non-backbone areas, when they get partitioned. OSPF does not actively attempt to
repair area partitions, each component simply becomes a separate area, when an area becomes partitioned. The
backbone performs routing between the new areas. Some destinations are reachable via intra-area routing, the area
partition requires inter-area routing.
However, to maintain full routing after the partition, an address range has not to be split across multiple components
of the area partition.

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.

Inter-Area Route Summarization


Inter-area route summarization is done on ABRs, it does not apply to external routes injected into OSPF via
redistribution. Summarization configuration is done in OSPF area range menu.

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

Stub area has few restrictions, ASBR


routers cannot be internal to the area,
stub area cannot be used as transit area
for virtual links. The restrictions are
made because stub area is mainly
configured not to carry external routes.
Totally stubby area is an extension for
stub area. A totally stubby area blocks
external routes and summarized
(inter-area) routes from going into the
area. Only intra-area routes are
injected into the area.
inject-summary-lsa=no is used to
configure totally stubby area in the
RouterOS.
Let's consider the example above. Area1 is configured as stub area meaning that routers R2 and R3 will not receive
any routing information from backbone area except default route.
R1 configuration:

/routing ospf area add name=area1 area-id=1.1.1.1 type=stub inject-summary-lsa=yes


/routing ospf network
add network=10.0.0.0/24 area=backbone
add network=10.0.1.0/24 area=area1
add network=10.0.3.0/24 area=area1

R2 configuration:

/routing ospf area add name=area1 area-id=1.1.1.1 type=stub inject-summary-lsa=yes


/routing ospf network
add network=10.0.1.0/24 area=area1

R3 configuration:

/routing ospf area add name=area1 area-id=1.1.1.1 type=stub inject-summary-lsa=yes


/routing ospf network
add network=10.0.3.0/24 area=area1

NSSA
Manual:OSPF Case Studies 165

Not-so-stubby area (NSSA) is useful


when it is required to inject external
routes, but injection of type 5 LSA
routes is not required.
Look at the image above. There are
two areas (backbone and area1) and
RIP connection to area1. We need
Area1 to be configured as stub area,
but it is also required to inject external
routes from RIP protocol. Area1
should be configured as NSSA in this
case.
Configuration example does not cover RIP configuration.
R1 configuration:

/routing ospf area add name=area1 area-id=1.1.1.1 type=nssa


/routing ospf network
add network=10.0.0.0/24 area=backbone
add network=10.0.1.0/24 area=area1

R2 configuration:

/routing ospf set redistribute-rip=as-type-1


/routing ospf area add name=area1 area-id=1.1.1.1 type=nssa
/routing ospf network
add network=10.0.1.0/24 area=area1

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:

[admin@MikroTikR1]/ip address add address=10.10.1.1/24 interface=ether1


[admin@MikroTikR1]/ip address add address=10.10.1.5/24 interface=ether2
[admin@MikroTikR1]/ip address add address=210.13.1.0/28 interface=ether3
[admin@MikroTikR2]/ip address add address=10.10.1.6/24 interface=ether1
[admin@MikroTikR2]/ip address add address=10.10.1.9/24 interface=ether2
[admin@MikroTikR2]/ip address add address=172.16.1.0/16 interface=ether3
[admin@MikroTikR3]/ip address add address=10.10.1.2 /24 interface=ether1
[admin@MikroTikR3]/ip address add address=10.10.1.10/24 interface=ether2
[admin@MikroTikR3]/ip address add address=192.168.1.0/24 interface=ether3

There are three basic elements of OSPF configuration:


• Enable OSPF instance
• OSPF area configuration
• OSPF network configuration
General information is configured in /routing ospf instance menu. For advanced OSPF setups, it is possible to run
multiple OSPF instances. Default instance configuration is good to start, we just need to enable default instance.
R1:

[admin@MikroTikR1] /routing ospf instance> add name=default

R2:

[admin@MikroTikR2] /routing ospf instance> add name=default


Manual:OSPF-examples 167

R3:

[admin@MikroTikR3] /routing ospf instance> add name=default

Show OSPF instance information:

[admin@MikroTikR1] /routing ospf instance> print


Flags: X - disabled
0 name="default" router-id=0.0.0.0 distribute-default=never
redistribute-connected=as-type-1 redistribute-static=as-type-1
redistribute-rip=no redistribute-bgp=no redistribute-other-ospf=no
metric-default=1 metric-connected=20 metric-static=20 metric-rip=20
metric-bgp=auto metric-other-ospf=auto in-filter=ospf-in
out-filter=ospf-out

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”:

[admin@MikroTikR1] /interface bridge> add name=loopback

Add IP address:

[admin@MikroTikR1] > ip address add address=10.255.255.1/32 interface=loopback

Configure router-id as loopback:

[admin@MikroTikR1] /routing ospf instance> set 0 router-id=10.255.255.1

This can be done on other routers (R2, R3) as well.


Next step is to configure OSPF area. Backbone area is created during RouterOS installation and additional
configuration is not required.
Note: Remember that backbone area-id is always (zero) 0.0.0.0.

And the last step is to add network to the certain OSPF area.
On R1

[admin@MikroTikR1] /routing ospf network> add network=210.13.1.0/28 area=backbone


[admin@MikroTikR1] /routing ospf network> add network=10.10.1.0/30 area=backbone
[admin@MikroTikR1] /routing ospf network> add network=10.10.1.4/30 area=backbone

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:

[admin@MikroTikR1] /routing ospf network> add network=10.10.1.0/'''24''' area=backbone

R2:

[admin@MikroTikR2] /routing ospf network> add network=172.16.1.0/16 area=backbone


[admin@MikroTikR2] /routing ospf network> add network=10.10.1.0/24 area=backbone
Manual:OSPF-examples 168

R3:

[admin@MikroTikR3] /routing ospf network> add network=192.168.1.0/24 area=backbone


[admin@MikroTikR3] /routing ospf network> add network=10.10.1.0/24 area=backbone

You can verify your OSPF operation as follows:


• Look at the OSPF interface menu to verify that dynamic entry was created:

[admin@MikroTikR1] /routing ospf interface> print

• Check your OSPF neighbors, what DR and BDR is elected and adjacencies established:

[admin@MikroTikR1] /routing ospf neighbor> print

• Check router’s routing table (make sure OSPF routes are present):

[admin@MikroTik_CE1] > ip route print

Simple multi-area configuration


Backbone area is the core of all OSPF network, all areas have to be connected to the backbone area. Start
configuring OSPF from backbone and then expand network configuration to other areas.

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:

/routing ospf> add name=area1 area-id=0.0.0.1


/routing ospf> add network=10.0.1.0/24 area=backbone
/routing ospf> add network=10.1.1.0/30 area=area1

R2 configuration:

/routing ospf> add name=area2 area-id=0.0.0.2


/routing ospf> add network=10.0.1.0/24 area=backbone
/routing ospf> add network=10.1.2.0/30 area=area2

R3 configuration:
Manual:OSPF-examples 169

/routing ospf> add name=area1 area-id=0.0.0.1


/routing ospf> add network=10.1.1.0/30 area=area1

R4 configuration:

/routing ospf> add name=area2 area-id=0.0.0.2


/routing ospf> add network=10.1.2.0/30 area=area2

Now you can check routing table using command /ip route print
Routing table on router R3:

[admin@R3] > 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
1 ADo 10.0.1.0/24 10.1.1.1 110
2 ADC 10.1.1.0/30 10.1.1.2 ether1 110
3 ADo 10.1.2.0/30 10.1.1.1 110
4 ADC 192.168.1.0/24 192.168.1.1 ether2 0

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.

[admin@R3] /routing ospf instance> set 0 redistribute-connected=as-type-1


[admin@R3] /routing ospf instance> print
Flags: X - disabled
0 name="default" router-id=0.0.0.0 distribute-default=never
<u>redistribute-connected=as-type-1</u> redistribute-static=no
redistribute-rip=no redistribute-bgp=no redistribute-other-ospf=no
metric-default=1 metric-connected=20 metric-static=20 metric-rip=20
metric-bgp=auto metric-other-ospf=auto in-filter=ospf-in
out-filter=ospf-out

Now check router R3 to see if routes 192.168.2.0/24 and 172.16.0.0/16 are installed in routing table.

[admin@R3] > 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
1 ADo 10.0.1.0/24 10.1.1.1 110
2 ADC 10.1.1.0/30 10.1.1.2 ether1 110
3 ADo 10.1.2.0/30 10.1.1.1 110
4 ADo 172.16.0.0/16 10.1.1.1 110
5 ADC 192.168.1.0/24 192.168.1.1 ether2 0
6 ADo 192.168.2.0/24 10.1.1.1 110
Manual:OSPF-examples 170

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.

In this setup only C and D are allowed to become designated routers.


On all routers:

routing ospf network add network=10.1.1.0/24 area=backbone


routing ospf nbma-neighbor add address=10.1.1.1 priority=0
routing ospf nbma-neighbor add address=10.1.1.2 priority=0
routing ospf nbma-neighbor add address=10.1.1.3 priority=1
routing ospf nbma-neighbor add address=10.1.1.4 priority=1

(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:

routing ospf interface add interface=ether1 network-type=nbma priority=0

On routers C, D (they can become the designated router):

routing ospf interface add interface=ether1 network-type=nbma priority=1


Manual:OSPF-examples 171

Results
On Router A:

[admin@A] > routing ospf neighbor print


0 router-id=10.1.1.5 address=10.1.1.5 interface=ether1 priority=1 dr-address=10.1.1.4
backup-dr-address=10.1.1.3 state="Full" state-changes=6 ls-retransmits=0
ls-requests=0 db-summaries=0 adjacency=4m53s

1 router-id=10.1.1.3 address=10.1.1.3 interface=ether1 priority=1 dr-address=1.1.1.4


backup-dr-address=10.1.1.3 state="Full" state-changes=6 ls-retransmits=0
ls-requests=0 db-summaries=0 adjacency=4m43s

2 address=10.1.1.2 interface=ether1 priority=0 state="Down" state-changes=2

3 address=10.1.1.1 interface=ether1 priority=0 state="Down" state-changes=2

On Router D:

[admin@D] > routing ospf neighbor print


0 address=10.1.1.4 interface=ether1 priority=1 state="Down" state-changes=2

1 router-id=10.1.1.3 address=10.1.1.3 interface=ether1 priority=1 dr-address=10.1.1.4


backup-dr-address=10.1.1.3 state="Full" state-changes=6 ls-retransmits=0
ls-requests=0 db-summaries=0 adjacency=6m8s

2 router-id=10.1.1.2 address=10.1.1.2 interface=ether1 priority=0 dr-address=10.1.1.4


backup-dr-address=10.1.1.3 state="Full" state-changes=5 ls-retransmits=0
ls-requests=0 db-summaries=0 adjacency=6m4s

3 router-id=10.1.1.1 address=10.1.1.1 interface=ether1 priority=0 dr-address=10.1.1.4


backup-dr-address=10.1.1.3 state="Full" state-changes=5 ls-retransmits=0
ls-requests=0 db-summaries=0 adjacency=6m4s

OSPF Forwarding Address


OSPF may take extra hops at the boundary between OSPF routing domain and another Autonomous System. By
looking at the following illustration you can see that even if router R3 is directly connected, packets will travel
through the OSPF network and use router R1 as a gateway to other AS.
To overcome this problem, concept of OSPF forwarding-address was introduced. This concept allows to say "Send
traffic directly to router R1". This is achieved by setting forwarding address other than itself in LSA updates
indicating that there is an alternate next-hop. Mostly all the time forwarding address is left 0.0.0.0, suggesting that
the route is reachable only through the advertising router.
Sere the full example
[Back to Content]
Manual:Routing/BGP 172

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

as (integer: 0..4294967295; 32-bit BGP autonomous system number


Default: )

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)

name (string;) BGP instance name

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

vrf (string;) List of VRFs used for vpnv4 routes

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.

default-originate (always | specifies how to distribute default route


if-installed | never;)

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

instance (string;) the instance this peer belongs to

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.

name (string;) the name of the peer

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

remote-address (IP address;) address of the remote peer

remote-as (integer: 32-bit AS number of the remote peer


0..4294967295;)

remote-port (integer; Default: Remote peers port to establish tcp session


179)

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!

Read only status properties:


Manual:Routing/BGP 175

Property Description

remote-id (IP address) BGP router ID of the remote end

local-address (IP address) local address used for TCP connection

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

updates-sent (integer) total number of reachable routing prefixes advertised

updates-received (integer) total number of reachable routing prefixes received

withdrawn-sent (integer) total number of withdrawn routing prefixes advertised

withdrawn-received (integer) total number of withdrawn routing prefixes received

remote-hold-time (time) hold time value offered by the remote end

used-hold-time (time) negotiated hold time value

used-keepalive-time (time) negotiated keepalive message interval (used-hold-time / 3)

refresh-capability (yes | no)

as4-capability (yes | no) set to yes if peer supports 4-byte AS numbers

used-keepalive-time (time) negotiated keepalive message interval (used-hold-time / 3)

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

prefix (IP prefix) the NLRI prefix sent out

nexthop (IP address) the NEXT_HOP attribute value sent out

as-path (string) the AS_PATH attribute value sent out

origin (igp | egp | incomplete) the ORIGIN attribute value sent out

local-pref (integer) the LOCAL_PREF attribute value sent out

med (integer) the MULTI_EXIT_DISC attribute value sent out

atomic-aggregate (yes | no) the ATOMIC_AGGREGATE attribute value sent out

aggregator (IP address) the AGGREGATOR attribute value sent out

originator-id (IP address) the ORIGINATOR_ID attribute value sent out


Manual:Routing/BGP 176

cluster-list (string) the CLUSTER_LIST attribute value sent out

peer (string) the peer this information is advertised to

Network
Sub-menu: /routing bgp network
BGP network configuration. BGP Networks is a list of IP prefixes to be advertised.

Property Description

network (IP prefix;) the aggregate prefix

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)

instance (string;) the instance this network belongs to

prefix (IP prefix;) the aggregate prefix

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

Read only status property:

routes-used (integer) aggregated route statistics.


• in console- list of route console IDs used;
• in winbox- number of routes used.

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-as-path (string;) the AS_PATH attribute value

bgp-atomic-aggregate (string;) the ATOMIC_AGGREGATE attribute value

bgp-communities (;)

bgp-ext-communities (string;)

bgp-local-pref (string;) the LOCAL_PREF attribute value

bgp-med (string;) the MULTI_EXIT_DISC attribute value

bgp-origin (igp|egp|incomplete;) the ORIGIN attribute value

bgp-prepend (string;)

bgp-weight (string;)

dst-address (string;)

gateway (string;)

in-label (integer;) assigned MPLS in label

interface (string;)

out-label (integer;) assigned MPLS out label

route-distinguisher (string;)

[Back to Content]
Manual:BGP based VPLS 178

Manual:BGP based VPLS


Overview
MPLSVPLS page covers general introduction to VPLS service and configuration of LDP based VPLS tunnels. Due
to their static nature LDP based VPLS tunnels have scalability issues that arise when number of VPLSes and sites
participating in VPLSes grow. One of the problems is the requirement to maintan full mesh of LDP tunnels between
sites forming VPLS. In case number of sites in VPLS is high, adding new site to existing VPLS can become
burdensome for network administrator.
BGP based autodiscovery and signaling of VPLS tunnels can help to avoid complexity of configuration at the
expense of running BGP protocol between VPLS routers. In general, BGP based VPLS serves two purposes:
• autodiscovery: there is no need to configure each VPLS router with all remote endpoints of VPLS tunnels,
provided there are means to deliver BGP multiprotocol NLRIs between them - routers figure out remote endpoints
of tunnels from received BGP Updates;
• signaling: labels used for VPLS tunnels by remote endpoints are distributed in the same BGP Updates, this means
there is no need for targeted LDP sessions between tunnel endpoints as in case of LDP signaled VPLS.
For example, if LDP signaled VPLS is used, adding new site to existing VPLS would mean configuring router that
connects new site to establish tunnels with the rest of sites and also configure all other routers to establish tunnels
with router connecting this new site. BGP based VPLS, if configured properly eliminates need to adjust
configuration on all routers forming VPLS.
The requirement to exchange BGP NLRIs between VPLS routers means that either full mesh of BGP sessions need
to be established among routers forming VPLS or route reflector must be used. In case full mesh of BGP sessions are
established between VPLS routers, the benefits of BGP based VPLS over LDP signaled VPLS are questionable -
when new site is added to VPLS, BGP peer configuration still needs to be entered on every router forming given
VPLS. When BGP route reflector is used, adding new site to VPLS becomes more simple - router connecting new
site must only peer with route reflector and no additional configuration is required on other routers. Taking into
account that route reflector can also be one of routers forming VPLS, there is no need for additional separate
equipment. Of course, scalability and availability concerns still must be taken into account - multiple route reflectors
can be used for backup purposes as well as for distributing information load.
The drawback of running BGP based VPLS is requirement to configure BGP which requires that network
administrator has at least basic understanding of BGP, its multiprotocol capabilities and route reflectors. Therefore it
is advised to implement LDP signaled VPLS if amount of sites and VPLS networks is small, topology is more static
- that is, benefits of using BGP are not obvious.
Note that BGP based VPLS is a method only for VPLS tunnel label exchange, it does not deal with delivery of
traffic between VPLS tunnel endpoints, so general MPLS frame delivery between tunnel endpoints must be ensured
as discussed in MPLSVPLS.
Suggested reading material:
• RFC 4761, Virtual Private LAN Service (VPLS) Using BGP for Auto-Discovery and Signaling
• RFC 4456, BGP Route Reflection: An Alternative to Full Mesh Internal BGP (IBGP)
Manual:BGP based VPLS 179

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.

Configuring IBGP session for VPLS signaling


At first, BGP instance must be configured, default instance can also be used:
[admin@R1] /routing bgp instance> print
Flags: X - disabled
0 name="default" as=65530 router-id=0.0.0.0 redistribute-connected=no redistribute-static=no
redistribute-rip=no redistribute-ospf=no redistribute-other-bgp=no out-filter=""
client-to-client-reflection=yes ignore-as-path-len=no

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

[admin@R5] /routing bgp peer> add remote-address=9.9.9.1 remote-as=65530 address-families=l2vpn \


update-source=lobridge

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

There are several things to note about BGP peer configuration:


• there is no need to distribute any IP or IPv6 routes and even no need have IP or IP6 support over BGP connection
at all to be able to exchange VPLS NLRIs, it is sufficient to specify address-families=l2vpn
• "loopback" addresses of routers are used as BGP peer addresses (local address is configured by means of
update-source setting). BGP peer, when originating VPLS NLRI, specifies its local address as BGP NextHop
(for example, in given setup R1 originating BGP NLRIs will use address 9.9.9.1 as BGP NextHop address),
receiving VPLS router uses received BGP NextHop address as tunnel endpoint address and therefore uses
transport label that ensures delivery to BGP NextHop. In order for penultimate hop popping to work properly, it is
advised to use loopback IP address for this. See penultimate hop popping related discussion in MPLSVPLS.

Configuring Route Reflector


In its simplest sense BGP Route Reflector re-advertises received IBGP routes without changing BGP NextHop for
route. This feature can be used to avoid setting up full mesh of BGP connections. Note that for router be able to
operate as route reflector for VPLS NLRIs, it is not necessary for it to participate in any VPLS, it is even not
necessary for it to have MPLS support. Still it is mandatory for VPLS routers to be able to establish BGP sessions
with route reflector, therefore IP connectivity is a must.
Route reflector's BGP instance must be configured with client-to-client-reflection=yes setting:
[admin@R5] /routing bgp instance> print
Flags: X - disabled
0 name="default" as=65530 router-id=0.0.0.0 redistribute-connected=no redistribute-static=no
redistribute-rip=no redistribute-ospf=no redistribute-other-bgp=no out-filter=""
client-to-client-reflection=yes ignore-as-path-len=no

Additionaly, peers on route reflector must be configured with route-reflect=yes setting:


[admin@R5] /routing bgp peer> print
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=no hold-time=3m ttl=255 in-filter=""
out-filter="" address-families=l2vpn update-source=lobridge
[admin@R5] /routing bgp peer> set 0 route-reflect=yes
[admin@R5] /routing bgp peer> print
Flags: X - disabled
0 name="peer1" instance=default remote-address=9.9.9.1 remote-as=65530 tcp-md5-key=""
Manual:BGP based VPLS 181

nexthop-choice=default multihop=no route-reflect=yes hold-time=3m ttl=255 in-filter=""


out-filter="" address-families=l2vpn update-source=lobridge

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

1 name="peer2" instance=default remote-address=9.9.9.4 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=3.3.3.4
local-address=9.9.9.5 uptime=23s 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

But R1 and R4 must only peer with R5. On R1:


[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=6m33s 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

Configuring BGP signaled VPLS

Configuring ethernet bridging


BGP signalled VPLS tunnels are created dynamically when proper BGP NLRIs are received. Therefore there is no
need to configure any VPLS interfaces. Still, to transparently deliver packets from ethernet segment across VPLS
bridging must be configured. For example, on R1 two bridges are created, named "A" and "B" with appropriate
customer-facing ethernet interfaces added to them:
[admin@R1] /interface bridge> print
Flags: X - disabled, R - running
0 R name="lobridge" mtu=1500 arp=enabled mac-address=00:00:00:00:00:00 protocol-mode=none
priority=0x8000 auto-mac=yes admin-mac=00:00:00:00:00:00 max-message-age=20s
forward-delay=15s transmit-hold-count=6 ageing-time=5m

1 R name="A" mtu=1500 arp=enabled mac-address=00:01:50:E7:00:09 protocol-mode=none


auto-mac=yes admin-mac=00:00:00:00:00:00 max-message-age=20s forward-delay=15s
priority=0x8000 transmit-hold-count=6 ageing-time=5m

2 R name="B" mtu=1500 arp=enabled mac-address=00:01:50:E7:00:08 protocol-mode=none


auto-mac=yes admin-mac=00:00:00:00:00:00 max-message-age=20s forward-delay=15s
priority=0x8000 transmit-hold-count=6 ageing-time=5m
[admin@R1] /interface bridge> port print
Flags: X - disabled, I - inactive, D - dynamic
# INTERFACE BRIDGE PRIORITY PATH-COST HORIZON
0 ether2 A 0x80 10 none
1 ether1 B 0x80 10 none

Configuring BGP signaled VPLS instances


Configuring BGP signaled VPLS instance makes router advertise VPLS BGP NLRI that advertises that particular
router belongs to some VPLS. Upon receiving such advertisement, other members of same VPLS know to establish
VPLS tunnel with this router.
To configure VPLS for customers A and B, on R1 the following commands should be issued:
[admin@R1] /interface vpls bgp-vpls> add bridge=A bridge-horizon=1 route-distinguisher=1:1 \
site-id=1 import-route-targets=1:1 export-route-targets=1:1
[admin@R1] /interface vpls bgp-vpls> add bridge=B bridge-horizon=1 route-distinguisher=2:2 \
site-id=1 import-route-targets=2:2 export-route-targets=2:2

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:

[admin@R1] > /interface vpls print


Flags: X - disabled, D - dynamic, R - running, B - bgp-signaled
0 RDB name="vpls1" mtu=1500 mac-address=02:FA:33:C4:7A:A9 arp=enabled
disable-running-check=no remote-peer=9.9.9.4 cisco-style=no
cisco-style-id=0 vpls=bgp-vpls1
[admin@R1] > /interface bridge port print
Flags: X - disabled, I - inactive, D - dynamic
# INTERFACE BRIDGE PRIORITY PATH-COST HORIZON
0 ether2 A 0x80 10 none
1 ether1 B 0x80 10 none
2 D vpls1 A 0x80 50 1

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:

[admin@R1] > /interface vpls print


Flags: X - disabled, D - dynamic, R - running, B - bgp-signaled
0 RDB name="vpls1" mtu=1500 mac-address=02:FA:33:C4:7A:A9 arp=enabled
disable-running-check=no remote-peer=9.9.9.4 cisco-style=no
cisco-style-id=0 vpls=bgp-vpls1
1 RDB name="vpls2" mtu=1500 mac-address=02:FF:B7:0E:4B:97 arp=enabled
disable-running-check=no remote-peer=9.9.9.5 cisco-style=no
cisco-style-id=0 vpls=bgp-vpls1

And bridge port to get added with proper horizon value:

[admin@R1] > /interface bridge port print


Flags: X - disabled, I - inactive, D - dynamic
# INTERFACE BRIDGE PRIORITY PATH-COST HORIZON
0 ether2 A 0x80 10 none
1 ether1 B 0x80 10 none
Manual:BGP based VPLS 184

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:

[admin@R5] /interface vpls bgp-vpls> add site-id=5 route-distinguisher=2:2 bridge=B \


bridge-horizon=1 import-route-targets=2:2 export-route-targets=2:2

As the result we get full mesh of VPLS tunnels established, for example on R5:

[admin@R5] /interface vpls> print


Flags: X - disabled, D - dynamic, R - running, B - bgp-signaled

0 RDB name="vpls1" mtu=1500 mac-address=02:FA:5C:28:29:D3 arp=enabled


disable-running-check=no remote-peer=9.9.9.1 cisco-style=no
cisco-style-id=0 vpls=bgp-vpls1
1 RDB name="vpls2" mtu=1500 mac-address=02:EA:51:31:3E:2B arp=enabled
disable-running-check=no remote-peer=9.9.9.4 cisco-style=no
cisco-style-id=0 vpls=bgp-vpls1
2 RDB name="vpls3" mtu=1500 mac-address=02:F6:CF:06:1E:CB arp=enabled
disable-running-check=no remote-peer=9.9.9.1 cisco-style=no
cisco-style-id=0 vpls=bgp-vpls2

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:

[admin@R5] /interface vpls> monitor 2 once


remote-label: 45
local-label: 40
remote-status:
igp-prefix: 9.9.9.1/32
Manual:BGP based VPLS 185

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:

[admin@R5] > /mpls remote-bindings print


Flags: X - disabled, A - active, D - dynamic
# DST-ADDRESS NEXTHOP LABEL PEER
...
14 AD 9.9.9.1/32 4.4.4.3 17 9.9.9.3:0
...

Manual:BGP HowTo & FAQ


Problem: BGP session is not established
BGP uses TCP, so to discover the cause of the problem, you can start with testing TCP connectivity. One way to do
that is as simple as /system telnet <remote-ip> 179 and check if the TCP connection can be established, and BGP
port 179 is open and reachable.
If this is eBGP, make sure you have configured multihop=yes and TTL settings as needed. Use /routing bgp peer
print status to see the current state of BGP connection.
Also note that if the remote peer is not supporting BGP Capabilities Advertisement (RFC 2842), some extra time
will be needed for session establishment. The establishment will fail at the first time in this case, because of
unknown options in BGP OPEN message. It should succeed at second attempt (i.e. after about a minute) and in any
further attempts, because RouterOS will remember the offending options for that peer and not include them in BGP
OPEN messages anymore.

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.

Question: How to check if a specific route exists in IP routing table?


Finding a route by prefix is pretty fast:

/ip route print where dst-address = 193.23.33.0/24

To find all routes with prefixes falling in a range:

/ip route print where dst-address in 193.23.0.0/16

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

[atis@SM_BGP] > /ip route print detail where bgp-as-path ~ "30621\$"


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
0 ADb dst-address=12.151.74.0/23
gateway=x.x.x.x recursive via y.y.y.y ether1 distance=20
scope=40 target-scope=10 bgp-as-path="2588,42979,702,701,7018,30621"
bgp-origin=igp received-from=x.x.x.x
 
1 ADb dst-address=12.151.76.0/22
gateway=x.x.x.x recursive via y.y.y.y ether1 distance=20
scope=40 target-scope=10 bgp-as-path="2588,42979,702,701,7018,30621"
bgp-atomic-aggregate=yes bgp-origin=igp received-from=x.x.x.x

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.

Question: How to filter out something?


Use routing filters. For example, to filter out routes with a specific BGP community, add this rule:

/routing filter add bgp-communities=111:222 chain=bgp-in action=discard

Then tell BGP peer to use that filter chain:

/routing bgp peer set peer in-filter=bgp-in

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:

ip route print count-only

To see route count from a particular peer look at prefix-count property in:

route bgp peer print status

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:

routing bgp advertisements print

Or

routing bgp advertisements print <peer_name>


Manual:BGP HowTo & FAQ 187

Note: At the moment AS-PATH attribute is displayed without prepends!

To see routes received from a particular peer (similar to Cisco command show ip bgp neighbor
x.x.x.x received-routes) use:

ip route print where received-from=<peer_name>

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!

Question: Is load balancing possible with MT BGP?

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.

routing filter add chain=bgp-in set-in-nexthop=10.0.1.1,10.0.2.1

Another way is to resolve BGP next-hop (if it is not directly reachable) through a static or OSPF route with multiple
next-hops.

ip route add dst-address=x.x.x.x/y gateway=10.0.1.1,10.0.2.1

See also: BGP Load Balancing with two interfaces.

Question: How to announce routes?


If your don't have many routes to announce and want the best control over them, use BGP networks or aggregates.
Note that both maximal BGP network and aggregate count is limited to 200.
Otherwise use route redistribution options, configurable under BGP instance settings.

Question: What does BGP network synchronize option exactly mean?


Since version 3.30 routing-test it means "do not announce this network, unless there is a matching active IGP or
connected route in IP route table". "Matching" in this case means: with exactly the same prefix.

Question: How to control advertised routing information?


Use routing filters.
To advertise the same information (e.g. some BGP attribute value) to all peers, use BGP instance out-filter:

/routing filter add set-bgp-communities=111:222 chain=bgp-out


/routing bgp instance set default out-filter=bgp-out

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:

/routing filter add set-bgp-prepend=4 chain=bgp-out-peer1


/routing bgp peer set peer1 out-filter=bgp-out-peer1

Use /routing bgp advertisements print to see what routing information exactly is advertised to peers.
Manual:BGP HowTo & FAQ 188

Problem: Looks like my routing filter isn't working


Most likely prefix matcher is configured incorrectly. For example, say that you want to configure filter that will
discard all routes falling under prefix 1.1.1.0/24.
The correct way to do this is with specifying prefix-length matcher:

add prefix=1.1.1.0/24 prefix-length=24-32 action=discard chain=bgp-in

This rule is incorrect (default netmask is /32, so it will match only prefix 1.1.1.0/32):

add prefix=1.1.1.0 prefix-length=24-32 action=discard chain=bgp-in

This is incorrect too (because it will match only route with netmask 255.255.255.0)

add prefix=1.1.1.0/24 action=discard chain=bgp-in

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.

Question: How to aggregate IGP routes?


Since 3.30 you can specify include-igp in BGP aggregate configuration. Example:

ip route add dst-address=10.9.9.0/25 gateway=10.0.0.1


ip route add dst-address=10.9.9.128/25 gateway=10.0.0.2
routing bgp aggregate add instance=default prefix=10.9.9.0/24 include-igp=yes

Results:
[admin@MikroTik] > routing bgp advertisements print

PEER PREFIX NEXTHOP AS-PATH ORIGIN LOCAL-PREF

peer1 10.9.9.0/24 10.0.0.131 incomplete

Use routing filters to control which routes are aggregated. For example, if you don't want to aggregate connected
routes:

routing filter add chain=aggregate-out protocol=connect action=discard


routing bgp aggregate set [find] advertise-filter=aggregate-out
Manual:BGP HowTo & FAQ 189

Question: How to advertise the default route?


To send default route to a particular peer, set default-originate=always or if-installed for that peer.

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: Does MT BGP support 4-octet AS numbers?


Yes. For input, both ASPLAIN (i.e. xxxxxx) and ASDOT (i.e. xxx.xxx) formats are supported; for output,
ASPLAIN only.

Question: What are the specifics of MT BGP route selection algorithm?


The algorithm is described here. The algorithm follows BGP RFC closely, with a few differences:
• Cisco-style weight is used as the first and most important selection criteria;
• AS path length comparison can be turned off by a configuration parameter;
• locally originated BGP routes are preferred in case of same AS path length, weight, and local-preference values;
• interior cost calculation and comparison step is skipped.
The algorithm is used only to compare BGP routes from the same BGP instance. For different instances, only
"distance" attributes are compared.

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

Manual:BGP soft reconfiguration alternatives in


RouterOS
Applies to RouterOS: v3, v4

What is soft reconfiguration?


When a route is received from a dynamic routing protocol, it is passed through routing filters. These filters may
change some attributes of the route or discard it altogether.
When the routing filters change, they must be reapplied to routes from BGP (and other protocols, but we are
focusing on BGP here). One way to do is reset BGP session, that is, tear down the connection with peer and
re-establish it again. The disadvantage of this approach are obvious.
Soft reconfiguration means that filtering policy can be reapplied after a change without session reset. For RouterOS,
both dynamic and static variants are possible.

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

Change filters to less restrictive:


Manual:BGP soft reconfiguration alternatives in RouterOS 191

[admin@A] > routing filter disable 0


[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
2 ADb 4.0.0.0/8 192.65.184.3 200 ether1
3 ADb 4.21.104.0/24 192.65.184.3 200 ether1
4 ADb 4.21.112.0/23 192.65.184.3 200 ether1
5 ADb 4.21.130.0/23 192.65.184.3 200 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

Change filters to less restrictive and send refresh request:

[admin@A] > routing filter disable 0


[admin@A] > routing bgp peer refresh peer1
[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
2 ADb 4.0.0.0/8 192.65.184.3 200 ether1
3 ADb 4.21.104.0/24 192.65.184.3 200 ether1
4 ADb 4.21.112.0/23 192.65.184.3 200 ether1
Manual:BGP soft reconfiguration alternatives in RouterOS 192

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.

Manual:BGP Load Balancing with two interfaces


Applies to RouterOS: 3, v4

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.

Example with iBGP

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

# ECMP route to peer's loopback


/ip route add dst-address=9.9.9.2/32 gateway=1.1.1.2,2.2.2.2

# BGP
Manual:BGP Load Balancing with two interfaces 193

/routing bgp instance set default as=65000


/routing bgp add name=peer1 remote-address=9.9.9.2 remote-as=65000 update-source=lobridge

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

# ECMP route to peer's loopback


/ip route add dst-address=9.9.9.1/32 gateway=1.1.1.1,2.2.2.1

# 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:

[admin@B] > /routing bgp peer print status


Flags: X - disabled
0 name="peer1" instance=default remote-address=9.9.9.1 remote-as=65000
tcp-md5-key="" nexthop-choice=default multihop=no route-reflect=no hold-time=3m
ttl=255 in-filter="" out-filter="" address-families=ip
update-source=lobridge default-originate=no remote-id=1.1.1.1
local-address=9.9.9.2 uptime=28s prefix-count=0 updates-sent=1
updates-received=0 withdrawn-sent=0 withdrawn-received=0 remote-hold-time=3m
used-hold-time=3m used-keepalive-time=1m refresh-capability=yes
as4-capability=yes state=established

Route table on Router A:

[admin@A] > /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 G GATEWAY DISTANCE INTER...
0 ADC 1.1.1.0/24 1.1.1.1 0 ether1
1 ADC 2.2.2.0/24 2.2.2.1 0 ether2
2 ADb 4.4.4.0/24 r 9.9.9.2 200 ether1
ether2
3 ADC 9.9.9.1/32 9.9.9.1 0 lobridge
4 A S 9.9.9.2/32 r 1.1.1.2 1 ether1
Manual:BGP Load Balancing with two interfaces 194

r 2.2.2.2 ether2

[admin@A] > /ip route print detail


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
0 ADC dst-address=1.1.1.0/24 pref-src=1.1.1.1 interface=ether1 distance=0 scope=10

1 ADC dst-address=2.2.2.0/24 pref-src=2.2.2.1 interface=ether2 distance=0 scope=10

2 ADb dst-address=4.4.4.0/24 gateway=9.9.9.2 interface=ether1,ether2


gateway-state=recursive distance=200 scope=40 target-scope=30
bgp-local-pref=100 bgp-origin=igp received-from=9.9.9.2

3 ADC dst-address=9.9.9.1/32 pref-src=9.9.9.1 interface=lobridge distance=0 scope=10

4 A S dst-address=9.9.9.2/32 gateway=1.1.1.2,2.2.2.2 interface=ether1,ether2


gateway-state=reachable,reachable distance=1 scope=30 target-scope=10

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).

Example with eBGP

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:

/routing filter add chain=bgp-in set-target-scope=30


/routing bgp set peer1 in-filter=bgp-in

Or else, modify scope attribute of the static route:

/ip route set [find dst-address=9.9.9.2/32] scope=10

Either way, the route to 4.4.4.0/24 should be active now:

2 ADb dst-address=4.4.4.0/24 gateway=9.9.9.2 interface=ether1,ether2


gateway-state=recursive distance=20 scope=40 target-scope=10
bgp-as-path="65001" bgp-origin=igp received-from=9.9.9.2

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-selection (no-gateway | best-adjusted This node is a MME gateway protocol client.


| best-statistic; Default: no-gateway) • no-gateway - don't install default route via MME.
• best-adjusted - select best gateway node based on received message statistics and announced
gateway class;
• best-statistic - select best gateway node based only on received message statistics;

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

interface (string; Interface on which MME will run


Default: all) • all - is used for the interfaces not having any specific settings

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

network (IP prefix; Default: ) Network to advertise

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

originator (IP) IP address of the node.

gateway (IP) The nexthop for this node.

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.

last-packet-before (time) Seconds elapsed since last received packet.

[Back to Content]

Manual:MME wireless routing protocol


See also MME command reference
Note that MME is not a replacement for OSPF or RIP. It is meant to be used in mesh networks, and is best suited for
wireless nodes with one logical interface. When used in traditional networks, the protocol overhead will be greater
than even that of RIP.

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.

Basic principles of the gateway protocol


Second part of the MME is a default gateway selection protocol. Here two roles for a router are possible. A gateway
server is node that is willing to serve as internet gateway for other routers. Usually it means it has an ethernet
connection or some other way "out of the mesh".
A gateway client is a node that is willing to use this dynamic information to about gateways out of the mesh cloud. If
there are multiple gateways reachable, client selects the best one based on packet statistics, advertised gateway class,
and gateway-selection and preferred-gateway configuration values. After selecting the best gateway server the
client makes a TCP connection to the server. This connection is used for periodic keep-alive message sending. After
the connection is established, both the client and the server add dynamic IPIP tunnel interface. The client also adds
default route through this interface.
If the server stops announcing it's gateway capability, or becomes unreachable, the TCP connection and all tunnel
state is teared down on both sides. Client also removes the default route.
Note that it's not recommended to have a default route (i.e. prefix 0.0.0.0/0) in MME network announcement
configuration.
Manual:MME wireless routing protocol 200

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:

[admin@I] > /routing mme interface add interface=wlan1

To change some attributes for routes learned via MME you can use the mme-in routing filter. Example:

[admin@MikroTik] > routing filter add chain=mme-in set-routing-mark=mark1

If you want to redistribute some routes via MME, add them to MME networks. Example:

[admin@MikroTik] /routing mme> network add network=1.2.3.0/24


[admin@MikroTik] /routing mme> network p
Flags: X - disabled
# NETWORK
0 1.2.3.0/24

Using the gateway protocol


Setup gateway server:

[admin@I] /routing mme> set gateway-class=11

Setup gateway client:

[admin@MikroTik] /routing mme> set gateway-selection=best-statistic

Observe the results (on client). Dynamic IPIP interface should be added automatically:

[admin@MikroTik] > /interface print


Flags: X - disabled, D - dynamic, R - running
# NAME TYPE MTU
0 R ether1 ether 1500
1 R ether2 ether 1500
2 DR ipip1 ipip 1480

Default route that goes through this tunnel should be added added automatically:

[admin@MikroTik] > /ip route print


Flags: X - disabled, A - active, D - dynamic,
C - connect, S - static, r - rip, b - bgp, o - ospf, m - mme,
Manual:MME wireless routing protocol 201

B - blackhole, U - unreachable, P - prohibit


# DST-ADDRESS PREF-SRC G GATEWAY DISTANCE INTERFACE
0 ADm 0.0.0.0/0 r ipip1 130 ipip1

Manual:Layer-3 MPLS VPN example


This is a kind of "putting it all together" setup.
Technologies used:
• LDP for MPLS label distribution
• BGP for VPNv4 route distribution
• OSPF as CE - PE routing protocol
Software:
• PE and P routers have RouterOS 3.17 with routing-test and mpls-test packages.
• CE routers have RouterOS 3.17 with routing-test package. (routing package and older versions can be used here
as well.)
Manual:Layer-3 MPLS VPN example 202

IP addressing & routing


Provider's network
On Router B:
/ip address add address=10.1.1.2/24 interface=ether2

/ip address add address=10.2.2.2/24 interface=ether3

# put PE-CE interface in a VRF

/ip route vrf add routing-mark=vrf1 interfaces=ether2 \

route-distinguisher=10.1.1.1:111 import-route-targets=10.1.1.1:111 export-route-targets=10.1.1.1:111

# loopback interface

/interface bridge add name=lobridge

/ip address add address=10.9.9.2/32 interface=lobridge

# add routes to loopback addresses

# (static routing is used for destinations inside providers network)

/ip route add dst-address=10.9.9.3/32 gateway=10.2.2.3

/ip route add dst-address=10.9.9.4/32 gateway=10.2.2.3

On Router C:

/ip address add address=10.2.2.3/24 interface=ether3


/ip address add address=10.3.3.3/24 interface=ether2
 
# loopback interface
/interface bridge add name=lobridge
/ip address add address=10.9.9.3/32 interface=lobridge
 
# add routes to loopback addresses
/ip route add dst-address=10.9.9.2/32 gateway=10.2.2.2
/ip route add dst-address=10.9.9.4/32 gateway=10.3.3.4

On Router D:
/ip address add address=10.3.3.4/24 interface=ether2

/ip address add address=10.4.4.4/24 interface=ether3

# put PE-CE interface in a VRF

/ip route vrf add routing-mark=vrf1 interfaces=ether3 \

route-distinguisher=10.1.1.1:111 import-route-targets=10.1.1.1:111 export-route-targets=10.1.1.1:111

# loopback interface

/interface bridge add name=lobridge

/ip address add address=10.9.9.4/32 interface=lobridge

# add routes to loopback addresses

/ip route add dst-address=10.9.9.2/32 gateway=10.3.3.3

/ip route add dst-address=10.9.9.3/32 gateway=10.3.3.3


Manual:Layer-3 MPLS VPN example 203

Client's sites
On Router A:

/ip address add address=10.1.1.1/24 interface=<ToRouterB>

On Router E:

/ip address add address=10.4.4.5/24 interface=<ToRouterD>


/ip address add address=10.7.7.5/24 interface=<ToLocalNetwork>

LDP
On Router B:

/mpls ldp set enabled=yes transport-address=10.9.9.2


/mpls ldp interface add interface=ether3

On Router C:

/mpls ldp set enabled=yes transport-address=10.9.9.3


/mpls ldp interface add interface=ether2
/mpls ldp interface add interface=ether3

On Router D:

/mpls ldp set enabled=yes transport-address=10.9.9.4


/mpls ldp interface add interface=ether2

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

/routing bgp peer add remote-address=10.9.9.2 remote-as=65530 route-reflect=yes \


address-families=vpnv4 update-source=lobridge
/routing bgp peer add remote-address=10.9.9.4 remote-as=65530 route-reflect=yes \
address-families=vpnv4 update-source=lobridge
# client-to-client-reflection is on by default
#/routing bgp instance set default client-to-client-reflection=yes

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:

/routing bgp vpn vpnv4-route print

and

/ip route print where bgp

OSPF
On Router A:

/routing ospf network add network=10.1.1.0/24 area=backbone

On Router B:

/routing ospf instance set default routing-table=vrf1 redistribute-bgp=as-type-1


/routing ospf network add network=10.1.1.0/24 area=backbone

On Router D:

/routing ospf instance set default routing-table=vrf1 redistribute-bgp=as-type-1


/routing ospf network add network=10.4.4.0/24 area=backbone

On Router E:

/routing ospf network add network=10.4.4.0/24 area=backbone


/routing ospf network add network=10.7.7.0/24 area=backbone

Results
Routing table on CE router A:

[admin@A] > /ip route pr


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
Manual:Layer-3 MPLS VPN example 205

0 ADC 10.1.1.0/24 10.1.1.1 ether2 0


1 ADo 10.4.4.0/24 10.1.1.2 reachab... 110
2 ADo 10.7.7.0/24 10.1.1.2 reachab... 110

Routing table on CE router E:

[admin@E] > /ip route pr


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 ADo 10.1.1.0/24 10.4.4.4 reachab... 110
1 ADC 10.4.4.0/24 10.4.4.5 ether2 0
2 ADC 10.7.7.0/24 10.7.7.5 ether3 0

Test
On Router A:
Ping from CE1 -> to PE1:

[admin@A] > /ping 10.1.1.2


10.1.1.2 64 byte ping: ttl=64 time=8 ms
10.1.1.2 64 byte ping: ttl=64 time=4 ms
10.1.1.2 64 byte ping: ttl=64 time=5 ms
10.1.1.2 64 byte ping: ttl=64 time=5 ms
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max = 4/5.5/8 ms

Ping from CE1 -> to CE2:

[admin@A] > /ping 10.4.4.5


10.4.4.5 64 byte ping: ttl=61 time=12 ms
10.4.4.5 64 byte ping: ttl=61 time=5 ms
10.4.4.5 64 byte ping: ttl=61 time=6 ms
10.4.4.5 64 byte ping: ttl=61 time=8 ms
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max = 5/7.7/12 ms

[admin@A] > /ping 10.7.7.5

10.7.7.5 64 byte ping: ttl=61 time=14 ms


10.7.7.5 64 byte ping: ttl=61 time=4 ms
10.7.7.5 64 byte ping: ttl=61 time=8 ms
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 4/8.6/14 ms

[admin@A] > /tool traceroute 10.7.7.5


ADDRESS STATUS
1 10.1.1.2 3ms 6ms 2ms
2 0.0.0.0 timeout timeout timeout
3 10.3.3.4 4ms 3ms 3ms
4 10.7.7.5 3ms 3ms 3ms
Manual:Layer-3 MPLS VPN example 206

The second hop failure is normal.


To see whole MPLS cloud as one IP hop, configure propagate-ttl=no. This setting should be the same on all
provider's routers.
On Routers B,C,D:

/mpls set propagate-ttl=no

[admin@A] > /tool traceroute 10.7.7.5


ADDRESS STATUS
1 10.1.1.2 6ms 3ms 5ms
2 10.3.3.4 5ms 3ms 6ms
3 10.7.7.5 9ms 9ms 6ms

No failures here.

Connecting from PE to CE
In this case routing-table must be specified manually.
Ping from PE1 -> to CE1:

[admin@B] > ping 10.1.1.1 routing-table=vrf1


10.1.1.1 64 byte ping: ttl=64 time=9 ms
10.1.1.1 64 byte ping: ttl=64 time=6 ms
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 6/7.5/9 ms

Manual:OSPF as PE-CE routing protocol


Software:
• PE1 router is Cisco 7200
• PE2 is MT and has RouterOS 3.23 with routing-test and mpls-test packages.
• CE1 and CE2 have any RouterOS version.

Configuration with inter-area routing


Manual:OSPF as PE-CE routing protocol 207

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

mpls ldp router-id Loopback0 force


mpls label protocol ldp

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

router ospf 1 vrf vrf1


router-id 10.5.5.2
network 10.1.1.0 0.0.0.255 area 0
redistribute bgp 65000 subnets
domain-id 0.0.0.1
domain-tag 2222

router bgp 65000


neighbor 10.5.5.3 remote-as 65000
neighbor 10.5.5.3 update-source Loopback0
address-family vpnv4
Manual:OSPF as PE-CE routing protocol 208

neighbor 10.5.5.3 activate


neighbor 10.5.5.3 send-community both
exit-address-family
address-family ipv4 vrf vrf1
redistribute connected
redistribute ospf 1 vrf vrf1 match internal external
exit-address-family

ip route 10.5.5.3 255.255.255.255 10.2.2.3

PE2
/interface bridge add name=lobridge

/ip address

add address=10.2.2.3/24 interface=ether1

add address=10.3.3.3/24 interface=ether2

add address=10.5.5.3/32 interface=lobridge

/ip route vrf add disabled=no export-route-targets=1.1.1.1:111 import-route-targets=1.1.1.1:111 \

interfaces=ether2,vrf-lobridge route-distinguisher=1.1.1.1:111 routing-mark=vrf1

/ip route add dst-address=10.5.5.2/32 gateway=10.2.2.2

/routing bgp instance set default as=65000

/routing bgp instance vrf add instance=default routing-mark=vrf1 redistribute-connected=yes redistribute-ospf=yes

/routing bgp peer add instance=default remote-as=65000 remote-address=10.5.5.2 \

address-families=vpnv4 update-source=lobridge

/routing ospf instance redistribute-bgp=as-type-1 router-id=10.5.5.3 routing-table=vrf1 \

domain-id=0.0.0.1 domain-tag=3333

/routing ospf network add area=backbone network=10.3.3.0/24

/mpls ldp set enabled=yes transport-address=10.5.5.3

/mpls ldp interface add interface=ether1


Manual:OSPF as PE-CE routing protocol 209

Configuration with intra-area routing (including a sham link)

CE1 additional backlink


/ip address add address=10.7.7.1/24 interface=backlink
/routing ospf network add area=backbone network=10.7.7.0/24
/routing ospf interface add interface=backlink cost=1000 network-type=point-to-point

CE2 additional backlink


/ip address add address=10.7.7.4/24 interface=backlink
/routing ospf network add area=backbone network=10.7.7.0/24
/routing ospf interface add interface=backlink cost=1000 network-type=point-to-point

PE1 (Cisco) with a sham link


interface Loopback1
ip vrf forwarding vrf1
ip address 10.6.6.2 255.255.255.255

router ospf 1 vrf vrf1


area 0 sham-link 10.6.6.2 10.6.6.3 cost 10

ip route 10.6.6.3 255.255.255.255 10.2.2.3

! all the rest of settings remain unchanged

PE2 with a sham-link


/interface bridge add name=vrf-lobridge

/ip address add address=10.6.6.3/32 interface=vrf-lobridge


# change the VRF to include vrf-lobridge interface
/ip route vrf add disabled=no export-route-targets=1.1.1.1:111 import-route-targets=1.1.1.1:111 \
interfaces=ether2,vrf-lobridge route-distinguisher=1.1.1.1:111 routing-mark=vrf1
Manual:OSPF as PE-CE routing protocol 210

# configure the sham link


/routing ospf sham-link add area=backbone src-address=10.6.6.3 dst-address=10.6.6.2
# add route to sham link's remote address
/ip route add dst-address=10.6.6.2 gateway=10.2.2.2

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

RouterOS MPLS features


As of version 3.8 MPLS feature development for RouterOS continues in mpls-test package that requires
routing-test package. Currently RouterOS (by means of mpls-test and routing-test packages) supports the following
MPLS related features:
• MPLS switching with penultimate hop popping support
• static local label bindings for IPv4
• static remote label bindings for IPv4
• Label Distribution Protocol (RFC 3036, RFC 5036) for IPv4
• downstream unsolicited label advertisement
• independent label distribution control
• liberal label retention
• targeted session establishment
• optional loop detection
• Virtual Private Lan Service
• VPLS LDP signaling (RFC 4762)
• VPLS pseudowire fragmentation and reassembly (RFC 4623)
• VPLS MP-BGP based autodiscovery and signaling (RFC 4761), see BGP based VPLS
• RSVP TE Tunnels
• tunnel head-end
• explicit paths
• OSPF extensions for TE tunnels
• CSPF path selection
• forwarding of VPLS and MPLS IP VPN traffic on TE tunnels
• MP-BGP based MPLS IP VPN
• OSPF extensions for MPLS TE
Features since version 3.17:
• support for OSPF as CE-PE protocol
• ping and traceroute for specified VRF
• control over network layer TTL propagation in MPLS
Features since version 3.20 (note that this version changes configuration syntax and adds new parameters!):
• Cisco style static VPLS pseudowires (RFC 4447 FEC type 0x80)
• Cisco VPLS BGP-based auto-discovery (draft-ietf-l2vpn-signaling-08)
• support for multiple import/export route target extended communities for BGP based VPLS (both, RFC 4761 and
draft-ietf-l2vpn-signaling-08)
Features since version 3.23
• Ingress TE tunnel rate limit and automatic reserved bandwidth adjustment, see TE Tunnel Bandwidth Control
• all tunnel bandwidth settings are specified and displayed in bits per second
• complete support for OSPF as PE-CE routing protocol (including sham links)
Features since version 3.24
• RIP as CE-PE protocol
• per-VRF BGP instance redistribution settings
MPLS features that RouterOS DOES NOT HAVE yet:
• IPv6 support
• LDP features:
Manual:MPLS/Overview 212

• downstream on demand label advertisement


• ordered label distribution control
• conservative label retention
• TE features
• fast reroute
• link/node protection
• Support for BGP as label distribution protocol
To ensure compatibility with other manufacturer equipment ensure that required features match, if uncertain, consult
with Mikrotik support. RouterOS LDP and TE implementation has been tested with Cisco IOS.

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.

Virtual Ethernet creation


Menu: /interface virtual-ethernet add
Manual:Interface/Virtual-ethernet 213

Property Desciption

arp (disabled | enabled | proxy-arp | reply-only, ARP protocol resolution mode:


default: enabled) • disabled - interface is not replying to ARP requests
• enabled - interface is replaying to all ARP requests on its MAC address
• proxy-arp - interface is replying to all ARP requests even if it is not interface MAC address
• reply-only - interface replies only to known (static entries in ARP table) sources

comment (text) Short description of the item

copy-from (number) Item number to copy settings from to create new item

disabled (yes | no default: yes) identifies if entry is part of active coniguration

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

mtu (0 65536 default: 1500) maximal transmission unit of the interface

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

Manual:Simple BGP Multihoming


Applies to RouterOS: all

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.

#set our AS number


/routing bgp instance
set default as=30

#add BGP peers


/routing bgp peer
add name=toISP1 remote-address=192.168.1.1 remote-as=10
add name=toISP2 remote-address=192.168.2.1 remote-as=20

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

[admin@RB1100test] /routing bgp peer> print


Flags: X - disabled, E - established
# INSTANCE REMOTE-ADDRESS REMOTE-AS
0 E default 192.168.1.1 10
1 E default 192.168.1.2 20

Network Advertisements and Routing Filters


Now we can start to advertise our networks and filter out all other unnecessary advertisements.
First step is to advertise our networks

/routing bgp network


add network=10.1.1.0/24 synchronize=no
add network=10.1.2.0/24 synchronize=no

Next step is to specify which routing filter chains will be used

/routing bgp peer


set isp1 in-filter=isp1-in out-filter=isp1-out
set isp2 in-filter=isp2-in out-filter=isp2-out

in-filter is for incoming (received) prefixes, out-filter is for advertised prefixes.

Main/Backup link setup


After chains are specified we can accept our networks and drop everything else as we are not transit provider. As
you know one of the BGP attributes that influence best path selection is AS Path length (shorter AS Path is more
preferred). So as we want ISP2 to be backup only, we will use BGP AS prepend (increase length of AS path) to force
incoming traffic through ISP1.
Outgoing filters to ISP1:

/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

Outgoing filters to ISP2:

/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

Load sharing setup


Using previous setup we are kind of wasting one link. So it is possible to redesign our setup as illustrated below to
utilize both links.

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

Outgoing filters to ISP2:

/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:

[admin@MikroTik] > /interface eoip add remote-address=10.0.1.1/24 tunnel-id=1


[admin@MikroTik] > /interface eoip add remote-address=10.0.2.1/24 tunnel-id=2

• and on router R2

[admin@MikroTik] > /interface eoip add remote-address=10.1.1.1/24 tunnel-id=1


[admin@MikroTik] > /interface eoip add remote-address=10.2.2.1/24 tunnel-id=2

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

Refer to the following page regarding bonding mode selection.


• and on router R2
[admin@MikroTik] > / interface bonding add slaves=eoip-tunnel1,eoip-tunnel2 mode=balance-rr

The last step is to add IP addresses to the bonding interfaces:


• on router R1:

[admin@MikroTik] > / ip address add address 192.168.0.1/24 interface=bonding1

Tip: Refer to the following page regarding bonding mode selection.


• and on router R2

[admin@MikroTik] > / ip address add address 192.168.0.2/24 interface=bonding1

Test the configuration


Now two routers are able to reach each other using addresses from the 192.168.0.0/24 network. To verify bonding
interface functionality, do the following:
• on router R1:

[admin@MikroTik] > /interface monitor-traffic eoip-tunnel1,eoip-tunnel2

• and on router R2

[admin@MikroTik] > /tool bandwidth-test 192.168.0.1 direction=transmit

You should see that traffic is distributed equally across both EoIP interfaces:

[admin@MikroTik] > /int monitor-traffic eoip-tunnel1,eoip-tunnel2


received-packets-per-second: 685 685
received-bits-per-second: 8.0Mbps 8.0Mbps
sent-packets-per-second: 21 20
sent-bits-per-second: 11.9kbps 11.0kbps
received-packets-per-second: 898 899
received-bits-per-second: 10.6Mbps 10.6Mbps
sent-packets-per-second: 20 21
Manual:Bonding Examples 219

sent-bits-per-second: 11.0kbps 11.9kbps


received-packets-per-second: 975 975
received-bits-per-second: 11.5Mbps 11.5Mbps
sent-packets-per-second: 22 22
sent-bits-per-second: 12.4kbps 12.3kbps
received-packets-per-second: 980 980
received-bits-per-second: 11.6Mbps 11.6Mbps
sent-packets-per-second: 21 21
sent-bits-per-second: 11.9kbps 11.8kbps
received-packets-per-second: 977 977
received-bits-per-second: 11.6Mbps 11.5Mbps
sent-packets-per-second: 21 21
sent-bits-per-second: 11.9kbps 11.8kbps
-- [Q quit|D dump|C-z pause]
[admin@MikroTik] >

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

Refer to the following page regarding bonding mode selection.


• and on router R2
[admin@MikroTik] > / interface bonding set bonding1 link-monitoring=arp arp-ip-targets=192.168.0.1

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.

ConnectionRate ::= [!]From-To


From,To ::= 0..4294967295 (integer number)

Example
These rules will capture TCP/UDP traffic that was going trough the router when connection speed was below
100kbps

/ip firewall filter


add action=accept chain=forward connection-rate=0-100k protocol=tcp
add action=accept chain=forward connection-rate=0-100k protocol=udp

Notes
Connection Rate is available in RouterOS since v3.30. This option was introduced to allow capture traffic intensive
connections.

Application Example - Traffic Prioritization


Connection-rate can be used in various different ways, that still need to be realized, but most common setup will be
to detect and set lower priorities to the "heavy connections" (connections that maintain fast rate for long periods of
time (such as P2P,HTTP,FTP downloads). By doing this you can prioritize all other traffic that usually includes
VOIP and HTTP browsing and online gaming.
Method described in this example can be used together with other ways to detect and prioritize traffic
As connection-rate option does not have any averages we need to determine what will be the margin that identifies
"heavy connections". If we assume that normal HTTP browsing connection is less than 500kB (4Mb) long and VOIP
requires no more than 200kbps speed, then every connection that after first 500kB still have more than 200kbps
Manual:Connection Rate 221

speed can be assumed as "heavy".


(You might have different "connection-bytes" for HTTP browsing and differenet "connection-rate" for VOIP in your
network - so, please, do your own research before applying this example)
For this example lets assume that we have 6Mbps upload and download connection to ISP.

Quick Start for Impatient


/ip firewall mangle
add chain=forward action=mark-connection connection-mark=!heavy_traffic_conn \
new-connection-mark=all_conn
add chain=forward action=mark-connection connection-bytes=500000-0 \
connection-mark=all_conn connection-rate=200k-100M \
new-connection-mark=heavy_traffic_conn protocol=tcp
add chain=forward action=mark-connection connection-bytes=500000-0 \
connection-mark=all_conn connection-rate=200k-100M \
new-connection-mark=heavy_traffic_conn protocol=udp
add chain=forward action=mark-packet connection-mark=heavy_traffic_conn \
new-packet-mark=heavy_traffic passthrough=no
add chain=forward action=mark-packet connection-mark=all_conn \
new-packet-mark=other_traffic passthrough=no

/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.

add chain=forward action=mark-connection connection-bytes=500000-0 \


connection-mark=all_conn connection-rate=200k-100M \
new-connection-mark=heavy_traffic_conn protocol=tcp
add chain=forward action=mark-connection connection-bytes=500000-0 \
connection-mark=all_conn connection-rate=200k-100M \
new-connection-mark=heavy_traffic_conn protocol=udp

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"

add chain=forward action=mark-packet connection-mark=heavy_traffic_conn \


new-packet-mark=heavy_traffic passthrough=no
add chain=forward action=mark-packet connection-mark=all_conn \
new-packet-mark=other_traffic passthrough=no

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

Manual:Load balancing multiple same subnet


links
Applies to RouterOS: v4,v5

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

/ip firewall nat


add action=masquerade chain=srcnat out-interface=ether1
add action=masquerade chain=srcnat out-interface=ether2
Manual:Load balancing multiple same subnet links 224

/ip firewall mangle


add action=mark-routing chain=prerouting src-address=192.168.1.0/24 new-routing-mark=first
add action=mark-routing chain=prerouting src-address=192.168.2.0/24 new-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

[admin@MikroTik] /ip route> print detail


0 ADC dst-address=10.1.101.0/24 pref-src=10.1.101.18 gateway=ether1,ether2
gateway-status=ether1 reachable,ether2 reachable distance=0 scope=10

Note: Routing filters can be used to adjust preferred source if needed

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.

/ip firewall mangle


add action=mark-routing chain=prerouting src-address=192.168.1.0/24 new-routing-mark=first
add action=mark-routing chain=prerouting src-address=192.168.2.0/24 new-routing-mark=other

And masquerade our local networks

/ip firewall nat


add action=masquerade chain=srcnat out-interface=ether1
add action=masquerade chain=srcnat out-interface=ether2

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

[admin@MikroTik] /ip route> print detail


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
0 A S dst-address=0.0.0.0/0 gateway=10.1.101.1%ether2
gateway-status=10.1.101.1 reachable ether2 distance=1 scope=30
target-scope=10 routing-mark=other

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

Manual:OSPFv3 with Quagga


In this example we demonstrate interoperability of MikroTik 3.x with Quagga in multi-area OSPF setup with load
balancing.
RouterOS version 3.16 and Quagga 0.99.11 are used respectively.

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

add area-id=0.0.0.1 name=area1


/routing ospf-v3 interface
add interface=ether1 area=area1
add interface=ether2 area=area1
 
[admin@C] /routing ospf-v3> route print
# DESTINATION STATE COST
0 ::/0 ext-1 21
1 2003::1:0:0:0:0/64 inter-area 20
2 2003::2:0:0:0:0/64 intra-area 10
3 2003::3:0:0:0:0/64 intra-area 10
4 2003::4:0:0:0:0/64 inter-area 20
 
[admin@C] /routing ospf-v3> route print detail
0 destination=::/0 state=ext-1 gateway=fe80::1200:ff:fe00:201,fe80::1200:ff:fe00:ff00
interface=ether1,ether2 cost=21 area=external
 
1 destination=2003::1:0:0:0:0/64 state=inter-area gateway=fe80::1200:ff:fe00:201
interface=ether1 cost=20 area=area1
 
2 destination=2003::2:0:0:0:0/64 state=intra-area gateway=:: interface=ether1 cost=10
area=area1
 
3 destination=2003::3:0:0:0:0/64 state=intra-area gateway=:: interface=ether2 cost=10
area=area1
 
4 destination=2003::4:0:0:0:0/64 state=inter-area gateway=fe80::1200:ff:fe00:ff00
interface=ether2 cost=20 area=area1

Ping an "Internet" address from Router C (traffic will go through ECMP route):

[admin@C] > /ping 2003::1


2003::1 64 byte ping: ttl=63 time=20 ms
2003::1 64 byte ping: ttl=63 time=12 ms
2003::1 64 byte ping: ttl=63 time=9 ms
2003::1 64 byte ping: ttl=63 time=12 ms
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max = 9/13.2/20 ms
 
[admin@C] > /tool traceroute 2003::1
ADDRESS STATUS
1 2003::2:0:0:0:2 19ms 7ms 15ms
2 2003::1 13ms 13ms 12ms
Article Sources and Contributors 229

Article Sources and Contributors


Manual:CD Install  Source: http://wiki.mikrotik.com/index.php?oldid=16953  Contributors: Janisk, Marisb, SergejsB

Manual:Interface/PPPoE  Source: http://wiki.mikrotik.com/index.php?oldid=17222  Contributors: Janisk, Marisb, Normis

Manual:Interface/VLAN  Source: http://wiki.mikrotik.com/index.php?oldid=19562  Contributors: Janisk, Kirshteins, Marisb

Manual:IP/DHCP Server  Source: http://wiki.mikrotik.com/index.php?oldid=20189  Contributors: Janisk, Marisb

Manual:IP/DHCP Relay  Source: http://wiki.mikrotik.com/index.php?oldid=17273  Contributors: Janisk, Marisb

Manual:IP/DHCP Client  Source: http://wiki.mikrotik.com/index.php?oldid=20168  Contributors: Janisk, Marisb

Manual:Interface/Traffic Engineering  Source: http://wiki.mikrotik.com/index.php?oldid=17225  Contributors: Janisk, Marisb

Manual:HTB  Source: http://wiki.mikrotik.com/index.php?oldid=16957  Contributors: Eep, Janisk, Marisb, Megis, Normis

Manual:Queue Size  Source: http://wiki.mikrotik.com/index.php?oldid=16951  Contributors: Janisk, Marisb, Megis

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:Queues - Burst  Source: http://wiki.mikrotik.com/index.php?oldid=16948  Contributors: Eep, Janisk, Marisb, Megis

Manual:Packet Flow  Source: http://wiki.mikrotik.com/index.php?oldid=20478  Contributors: Janisk, Marisb, Megis, Normis

Manual:Queue  Source: http://wiki.mikrotik.com/index.php?oldid=16916  Contributors: Eep, Janisk, Marisb, Megis, Normis, SergejsB

Manual:Interface/Bonding  Source: http://wiki.mikrotik.com/index.php?oldid=20456  Contributors: Janisk, Marisb, Normis

Manual:TE Tunnels Example  Source: http://wiki.mikrotik.com/index.php?oldid=19203  Contributors: Marisb

Manual:MPLS/Traffic-eng  Source: http://wiki.mikrotik.com/index.php?oldid=17239  Contributors: Marisb

Manual:TE Tunnels  Source: http://wiki.mikrotik.com/index.php?oldid=16522  Contributors: Marisb, Mplsguy, Normis

Manual:TE tunnel auto bandwidth  Source: http://wiki.mikrotik.com/index.php?oldid=16517  Contributors: Marisb, Mplsguy

Manual:Connection tracking  Source: http://wiki.mikrotik.com/index.php?oldid=16984  Contributors: Janisk, Marisb, Normis

Manual:Routing Table Matcher  Source: http://wiki.mikrotik.com/index.php?oldid=16980  Contributors: Janisk, Marisb

Manual:IP/Firewall/L7  Source: http://wiki.mikrotik.com/index.php?oldid=17630  Contributors: Eep, Hrnous, Janisk, Marisb, Normis

Manual:IP/Firewall/NAT  Source: http://wiki.mikrotik.com/index.php?oldid=18214  Contributors: Janisk, Marisb, Normis, SergejsB

Manual:IP/Firewall/Mangle  Source: http://wiki.mikrotik.com/index.php?oldid=18215  Contributors: Janisk, Marisb, Normis

Manual:IP/Firewall/Filter  Source: http://wiki.mikrotik.com/index.php?oldid=19677  Contributors: Janisk, Kirshteins, Marisb, Normis

Manual:IP/Firewall/Address list  Source: http://wiki.mikrotik.com/index.php?oldid=17287  Contributors: Janisk, Marisb

Manual:IP/Services  Source: http://wiki.mikrotik.com/index.php?oldid=20677  Contributors: Janisk, Marisb, SergejsB

Manual:IP/Address  Source: http://wiki.mikrotik.com/index.php?oldid=20446  Contributors: Janisk, Marisb

Manual:IP/ARP  Source: http://wiki.mikrotik.com/index.php?oldid=19458  Contributors: Janisk, Marisb

Manual:IP/Route  Source: http://wiki.mikrotik.com/index.php?oldid=20436  Contributors: Eep, Janisk, Marisb

Manual:Virtual Routing and Forwarding  Source: http://wiki.mikrotik.com/index.php?oldid=16975  Contributors: Eep, Janisk, Marisb, Normis, Route

Manual:Routing/OSPF  Source: http://wiki.mikrotik.com/index.php?oldid=20491  Contributors: Janisk, Marisb, Normis, Route

Manual:OSPF Case Studies  Source: http://wiki.mikrotik.com/index.php?oldid=20495  Contributors: Janisk, Marisb

Manual:OSPF-examples  Source: http://wiki.mikrotik.com/index.php?oldid=19791  Contributors: Janisk, Marisb, Normis, Route

Manual:Routing/BGP  Source: http://wiki.mikrotik.com/index.php?oldid=19807  Contributors: Janisk, Marisb, 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:Routing/MME  Source: http://wiki.mikrotik.com/index.php?oldid=17440  Contributors: Atis, Eep, Marisb

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:MPLS/Overview  Source: http://wiki.mikrotik.com/index.php?oldid=16040  Contributors: Marisb, Mplsguy, Normis, Route

Manual:Interface/Virtual-ethernet  Source: http://wiki.mikrotik.com/index.php?oldid=20299  Contributors: Janisk, Marisb, Normis

Manual:Simple BGP Multihoming  Source: http://wiki.mikrotik.com/index.php?oldid=19642  Contributors: Marisb

Manual:Bonding Examples  Source: http://wiki.mikrotik.com/index.php?oldid=19357  Contributors: Eep, Eugene, Marisb, Normis, Peson

Manual:Connection Rate  Source: http://wiki.mikrotik.com/index.php?oldid=16964  Contributors: Janisk, Marisb, Megis, Normis

Manual:Load balancing multiple same subnet links  Source: http://wiki.mikrotik.com/index.php?oldid=16963  Contributors: Janisk, Marisb
Article Sources and Contributors 230

Manual:OSPFv3 with Quagga  Source: http://wiki.mikrotik.com/index.php?oldid=17612  Contributors: Janisk, Marisb, Route


Image Sources, Licenses and Contributors 231

Image Sources, Licenses and Contributors


Image:Version.png  Source: http://wiki.mikrotik.com/index.php?title=File:Version.png  License: unknown  Contributors: Normis
Image:CD1.png  Source: http://wiki.mikrotik.com/index.php?title=File:CD1.png  License: unknown  Contributors: SergejsB
Image:CD3.png  Source: http://wiki.mikrotik.com/index.php?title=File:CD3.png  License: unknown  Contributors: SergejsB
Image:CD4.png  Source: http://wiki.mikrotik.com/index.php?title=File:CD4.png  License: unknown  Contributors: SergejsB
Image:CD6.png  Source: http://wiki.mikrotik.com/index.php?title=File:CD6.png  License: unknown  Contributors: SergejsB
Image:CD7.png  Source: http://wiki.mikrotik.com/index.php?title=File:CD7.png  License: unknown  Contributors: SergejsB
Image:CD8.png  Source: http://wiki.mikrotik.com/index.php?title=File:CD8.png  License: unknown  Contributors: SergejsB
Image:CD9.png  Source: http://wiki.mikrotik.com/index.php?title=File:CD9.png  License: unknown  Contributors: SergejsB
Image:CD10.png  Source: http://wiki.mikrotik.com/index.php?title=File:CD10.png  License: unknown  Contributors: SergejsB
Image:CD11.png  Source: http://wiki.mikrotik.com/index.php?title=File:CD11.png  License: unknown  Contributors: SergejsB
Image:pppoe-discovery.png  Source: http://wiki.mikrotik.com/index.php?title=File:Pppoe-discovery.png  License: unknown  Contributors: Marisb
File:pppoe-apex.png  Source: http://wiki.mikrotik.com/index.php?title=File:Pppoe-apex.png  License: unknown  Contributors: Marisb
Image:image12001.gif  Source: http://wiki.mikrotik.com/index.php?title=File:Image12001.gif  License: unknown  Contributors: Andriss
Image:image12003.gif  Source: http://wiki.mikrotik.com/index.php?title=File:Image12003.gif  License: unknown  Contributors: Andriss
Image:Icon-note.png  Source: http://wiki.mikrotik.com/index.php?title=File:Icon-note.png  License: unknown  Contributors: Marisb, Route
Image:image12004.gif  Source: http://wiki.mikrotik.com/index.php?title=File:Image12004.gif  License: unknown  Contributors: Andriss
Image:image12005.gif  Source: http://wiki.mikrotik.com/index.php?title=File:Image12005.gif  License: unknown  Contributors: Andriss
File:Slash32.png  Source: http://wiki.mikrotik.com/index.php?title=File:Slash32.png  License: unknown  Contributors: Janisk
Image:dhcp-relay.png  Source: http://wiki.mikrotik.com/index.php?title=File:Dhcp-relay.png  License: unknown  Contributors: Marisb
Image:HTB_Example1.png  Source: http://wiki.mikrotik.com/index.php?title=File:HTB_Example1.png  License: unknown  Contributors: Megis
Image:HTB_Example2.png  Source: http://wiki.mikrotik.com/index.php?title=File:HTB_Example2.png  License: unknown  Contributors: Megis
Image:HTB_Example3.png  Source: http://wiki.mikrotik.com/index.php?title=File:HTB_Example3.png  License: unknown  Contributors: Megis
Image:HTB_Example4.png  Source: http://wiki.mikrotik.com/index.php?title=File:HTB_Example4.png  License: unknown  Contributors: Megis
Image:Queue_size_No_Limit.PNG  Source: http://wiki.mikrotik.com/index.php?title=File:Queue_size_No_Limit.PNG  License: unknown  Contributors: Megis
Image:Queue_size_0_packets.PNG  Source: http://wiki.mikrotik.com/index.php?title=File:Queue_size_0_packets.PNG  License: unknown  Contributors: Megis
Image:Queue_size_Unlimited_Packets.PNG  Source: http://wiki.mikrotik.com/index.php?title=File:Queue_size_Unlimited_Packets.PNG  License: unknown  Contributors: Megis
Image:Queue_size_10_packets.PNG  Source: http://wiki.mikrotik.com/index.php?title=File:Queue_size_10_packets.PNG  License: unknown  Contributors: Megis
Image:Queue_size_50_packets.PNG  Source: http://wiki.mikrotik.com/index.php?title=File:Queue_size_50_packets.PNG  License: unknown  Contributors: Megis
Image:PCQ.png  Source: http://wiki.mikrotik.com/index.php?title=File:PCQ.png  License: unknown  Contributors: SergejsB
Image:PCQ_Alg.png  Source: http://wiki.mikrotik.com/index.php?title=File:PCQ_Alg.png  License: unknown  Contributors: Megis
Image:PCQ_Example1.png  Source: http://wiki.mikrotik.com/index.php?title=File:PCQ_Example1.png  License: unknown  Contributors: Megis
Image:PCQ_Example2.png  Source: http://wiki.mikrotik.com/index.php?title=File:PCQ_Example2.png  License: unknown  Contributors: Megis
Image:PCQ3.png  Source: http://wiki.mikrotik.com/index.php?title=File:PCQ3.png  License: unknown  Contributors: Megis
Image:PCQ4.png  Source: http://wiki.mikrotik.com/index.php?title=File:PCQ4.png  License: unknown  Contributors: Megis
Image:Burst time.16.part1.JPG  Source: http://wiki.mikrotik.com/index.php?title=File:Burst_time.16.part1.JPG  License: unknown  Contributors: Megis
Image:Burst time.16.part2.JPG  Source: http://wiki.mikrotik.com/index.php?title=File:Burst_time.16.part2.JPG  License: unknown  Contributors: Megis
Image:Burst time.8.part1.JPG  Source: http://wiki.mikrotik.com/index.php?title=File:Burst_time.8.part1.JPG  License: unknown  Contributors: Megis
Image:Burst time.8.part2.JPG  Source: http://wiki.mikrotik.com/index.php?title=File:Burst_time.8.part2.JPG  License: unknown  Contributors: Megis
Image:Bridge_final.png  Source: http://wiki.mikrotik.com/index.php?title=File:Bridge_final.png  License: unknown  Contributors: Megis
Image:IP_final.png  Source: http://wiki.mikrotik.com/index.php?title=File:IP_final.png  License: unknown  Contributors: Megis
Image:Input_interface.jpg  Source: http://wiki.mikrotik.com/index.php?title=File:Input_interface.jpg  License: unknown  Contributors: Megis
Image:output_interface.jpg  Source: http://wiki.mikrotik.com/index.php?title=File:Output_interface.jpg  License: unknown  Contributors: Megis
Image:local_process-_in.jpg  Source: http://wiki.mikrotik.com/index.php?title=File:Local_process-_in.jpg  License: unknown  Contributors: Megis
Image:local_process-_out.jpg  Source: http://wiki.mikrotik.com/index.php?title=File:Local_process-_out.jpg  License: unknown  Contributors: Megis
Image:connection_tracking.jpg  Source: http://wiki.mikrotik.com/index.php?title=File:Connection_tracking.jpg  License: unknown  Contributors: Megis
Image:Filter_input.jpg  Source: http://wiki.mikrotik.com/index.php?title=File:Filter_input.jpg  License: unknown  Contributors: Megis
Image:Filter_forward.jpg  Source: http://wiki.mikrotik.com/index.php?title=File:Filter_forward.jpg  License: unknown  Contributors: Megis
Image:Filter_output.jpg  Source: http://wiki.mikrotik.com/index.php?title=File:Filter_output.jpg  License: unknown  Contributors: Megis
Image:src_nat.jpg  Source: http://wiki.mikrotik.com/index.php?title=File:Src_nat.jpg  License: unknown  Contributors: Megis
Image:dst_nat.jpg  Source: http://wiki.mikrotik.com/index.php?title=File:Dst_nat.jpg  License: unknown  Contributors: Megis
Image:mangle_prerouting.jpg  Source: http://wiki.mikrotik.com/index.php?title=File:Mangle_prerouting.jpg  License: unknown  Contributors: Megis
Image:mangle_input.jpg  Source: http://wiki.mikrotik.com/index.php?title=File:Mangle_input.jpg  License: unknown  Contributors: Megis
Image:mangle_forward.jpg  Source: http://wiki.mikrotik.com/index.php?title=File:Mangle_forward.jpg  License: unknown  Contributors: Megis
Image:mangle_output.jpg  Source: http://wiki.mikrotik.com/index.php?title=File:Mangle_output.jpg  License: unknown  Contributors: Megis
Image:mangle_postrouting.jpg  Source: http://wiki.mikrotik.com/index.php?title=File:Mangle_postrouting.jpg  License: unknown  Contributors: Megis
Image:global_in.jpg  Source: http://wiki.mikrotik.com/index.php?title=File:Global_in.jpg  License: unknown  Contributors: Megis
Image:global_out.jpg  Source: http://wiki.mikrotik.com/index.php?title=File:Global_out.jpg  License: unknown  Contributors: Megis
Image:Interface HTB.jpg  Source: http://wiki.mikrotik.com/index.php?title=File:Interface_HTB.jpg  License: unknown  Contributors: Megis
Image:IPsec_policy.jpg  Source: http://wiki.mikrotik.com/index.php?title=File:IPsec_policy.jpg  License: unknown  Contributors: Megis
Image:accounting.jpg  Source: http://wiki.mikrotik.com/index.php?title=File:Accounting.jpg  License: unknown  Contributors: Megis
Image:use_ip_firewall.jpg  Source: http://wiki.mikrotik.com/index.php?title=File:Use_ip_firewall.jpg  License: unknown  Contributors: Megis
Image:bridge_input.jpg  Source: http://wiki.mikrotik.com/index.php?title=File:Bridge_input.jpg  License: unknown  Contributors: Megis
Image:Bridge_forward.jpg  Source: http://wiki.mikrotik.com/index.php?title=File:Bridge_forward.jpg  License: unknown  Contributors: Megis
Image:Bridge_output.jpg  Source: http://wiki.mikrotik.com/index.php?title=File:Bridge_output.jpg  License: unknown  Contributors: Megis
Image:Bridge_dst_nat.jpg  Source: http://wiki.mikrotik.com/index.php?title=File:Bridge_dst_nat.jpg  License: unknown  Contributors: Megis
Image:Bridge_src_nat.jpg  Source: http://wiki.mikrotik.com/index.php?title=File:Bridge_src_nat.jpg  License: unknown  Contributors: Megis
Image:In-interface-bridge.jpg  Source: http://wiki.mikrotik.com/index.php?title=File:In-interface-bridge.jpg  License: unknown  Contributors: Megis
Image:hotspot_in.jpg  Source: http://wiki.mikrotik.com/index.php?title=File:Hotspot_in.jpg  License: unknown  Contributors: Megis
Image Sources, Licenses and Contributors 232

Image:Bridge Desicion.jpg  Source: http://wiki.mikrotik.com/index.php?title=File:Bridge_Desicion.jpg  License: unknown  Contributors: Megis


Image:bridge_decision.jpg  Source: http://wiki.mikrotik.com/index.php?title=File:Bridge_decision.jpg  License: unknown  Contributors: Megis
Image:routing_decision.JPG  Source: http://wiki.mikrotik.com/index.php?title=File:Routing_decision.JPG  License: unknown  Contributors: Megis
Image:routing_adjustment.jpg  Source: http://wiki.mikrotik.com/index.php?title=File:Routing_adjustment.jpg  License: unknown  Contributors: Megis
Image:TTL=TTL-1.jpg  Source: http://wiki.mikrotik.com/index.php?title=File:TTL=TTL-1.jpg  License: unknown  Contributors: Megis
Image:IPSec_Decryption.jpg  Source: http://wiki.mikrotik.com/index.php?title=File:IPSec_Decryption.jpg  License: unknown  Contributors: Megis
Image:IPSec_Encryption.jpg  Source: http://wiki.mikrotik.com/index.php?title=File:IPSec_Encryption.jpg  License: unknown  Contributors: Megis
Image:out_interface_bridge.jpg  Source: http://wiki.mikrotik.com/index.php?title=File:Out_interface_bridge.jpg  License: unknown  Contributors: Megis
Image:Hotspot_out.jpg  Source: http://wiki.mikrotik.com/index.php?title=File:Hotspot_out.jpg  License: unknown  Contributors: Megis
Image:Packet_Flow_Example_1.png  Source: http://wiki.mikrotik.com/index.php?title=File:Packet_Flow_Example_1.png  License: unknown  Contributors: Megis
Image:Packet_Flow_Example_2c.png  Source: http://wiki.mikrotik.com/index.php?title=File:Packet_Flow_Example_2c.png  License: unknown  Contributors: Megis
Image:Packet_Flow_Example_3_1.png  Source: http://wiki.mikrotik.com/index.php?title=File:Packet_Flow_Example_3_1.png  License: unknown  Contributors: Megis
Image:Packet_Flow_Example_3_2c.png  Source: http://wiki.mikrotik.com/index.php?title=File:Packet_Flow_Example_3_2c.png  License: unknown  Contributors: Megis
Image:Packet_Flow_Example_4c.png  Source: http://wiki.mikrotik.com/index.php?title=File:Packet_Flow_Example_4c.png  License: unknown  Contributors: Megis
Image:Packet_Flow_Example_5c.png  Source: http://wiki.mikrotik.com/index.php?title=File:Packet_Flow_Example_5c.png  License: unknown  Contributors: Megis
File:bonding-lacp-example.png  Source: http://wiki.mikrotik.com/index.php?title=File:Bonding-lacp-example.png  License: unknown  Contributors: Marisb
Image:bon-tlb.png  Source: http://wiki.mikrotik.com/index.php?title=File:Bon-tlb.png  License: unknown  Contributors: Marisb
Image:bon-alb.png  Source: http://wiki.mikrotik.com/index.php?title=File:Bon-alb.png  License: unknown  Contributors: Marisb
File:mpls-te-example.png  Source: http://wiki.mikrotik.com/index.php?title=File:Mpls-te-example.png  License: unknown  Contributors: Marisb
Image:VPLS.png  Source: http://wiki.mikrotik.com/index.php?title=File:VPLS.png  License: unknown  Contributors: Karliskarlis
Image:2009-01-26 1346.jpg  Source: http://wiki.mikrotik.com/index.php?title=File:2009-01-26_1346.jpg  License: unknown  Contributors: Normis
File:RTM.png  Source: http://wiki.mikrotik.com/index.php?title=File:RTM.png  License: unknown  Contributors: Marisb
Image:rib.png  Source: http://wiki.mikrotik.com/index.php?title=File:Rib.png  License: unknown  Contributors: Eep
Image:conn_route_and_address.png  Source: http://wiki.mikrotik.com/index.php?title=File:Conn_route_and_address.png  License: unknown  Contributors: Eep
Image:scope_and_target_scope.png  Source: http://wiki.mikrotik.com/index.php?title=File:Scope_and_target_scope.png  License: unknown  Contributors: Eep
Image:nh-lookup.png  Source: http://wiki.mikrotik.com/index.php?title=File:Nh-lookup.png  License: unknown  Contributors: Eep
Image:fib.png  Source: http://wiki.mikrotik.com/index.php?title=File:Fib.png  License: unknown  Contributors: Eep
Image:l3vpn-simple.png  Source: http://wiki.mikrotik.com/index.php?title=File:L3vpn-simple.png  License: unknown  Contributors: Route
Image:l3vpn-two-customers.png  Source: http://wiki.mikrotik.com/index.php?title=File:L3vpn-two-customers.png  License: unknown  Contributors: Route
Image:ospf-header.png  Source: http://wiki.mikrotik.com/index.php?title=File:Ospf-header.png  License: unknown  Contributors: Marisb
Image:ospf-hello.png  Source: http://wiki.mikrotik.com/index.php?title=File:Ospf-hello.png  License: unknown  Contributors: Marisb
Image:ospf-adjacency.png  Source: http://wiki.mikrotik.com/index.php?title=File:Ospf-adjacency.png  License: unknown  Contributors: Marisb
Image:sp-net.png  Source: http://wiki.mikrotik.com/index.php?title=File:Sp-net.png  License: unknown  Contributors: Marisb
Image:sp-tree.png  Source: http://wiki.mikrotik.com/index.php?title=File:Sp-tree.png  License: unknown  Contributors: Marisb
Image:ospf-basic.png  Source: http://wiki.mikrotik.com/index.php?title=File:Ospf-basic.png  License: unknown  Contributors: Marisb
Image:backbone-s.png  Source: http://wiki.mikrotik.com/index.php?title=File:Backbone-s.png  License: unknown  Contributors: Marisb
Image:area-br.png  Source: http://wiki.mikrotik.com/index.php?title=File:Area-br.png  License: unknown  Contributors: Marisb
Image:basic-multi-area.png  Source: http://wiki.mikrotik.com/index.php?title=File:Basic-multi-area.png  License: unknown  Contributors: Marisb
Image:vlink-area.png  Source: http://wiki.mikrotik.com/index.php?title=File:Vlink-area.png  License: unknown  Contributors: Marisb
Image:vlink-backbone.png  Source: http://wiki.mikrotik.com/index.php?title=File:Vlink-backbone.png  License: unknown  Contributors: Marisb
Image:stub-example.png  Source: http://wiki.mikrotik.com/index.php?title=File:Stub-example.png  License: unknown  Contributors: Marisb
Image:nssa-example.png  Source: http://wiki.mikrotik.com/index.php?title=File:Nssa-example.png  License: unknown  Contributors: Marisb
Image:image6005.gif  Source: http://wiki.mikrotik.com/index.php?title=File:Image6005.gif  License: unknown  Contributors: Andriss
Image:image6006.gif  Source: http://wiki.mikrotik.com/index.php?title=File:Image6006.gif  License: unknown  Contributors: Andriss
Image:ospf-nbma.png  Source: http://wiki.mikrotik.com/index.php?title=File:Ospf-nbma.png  License: unknown  Contributors: Route
Image:ibgp_load_bal.png  Source: http://wiki.mikrotik.com/index.php?title=File:Ibgp_load_bal.png  License: unknown  Contributors: Route
Image:ebgp_load_bal.png  Source: http://wiki.mikrotik.com/index.php?title=File:Ebgp_load_bal.png  License: unknown  Contributors: Route
Image:l3vpn.png  Source: http://wiki.mikrotik.com/index.php?title=File:L3vpn.png  License: unknown  Contributors: Route
Image:ospf-pe-ce.png  Source: http://wiki.mikrotik.com/index.php?title=File:Ospf-pe-ce.png  License: unknown  Contributors: Route
Image:ospf-pe-ce-sham-links.png  Source: http://wiki.mikrotik.com/index.php?title=File:Ospf-pe-ce-sham-links.png  License: unknown  Contributors: Route
File:bgp-multihoming.png  Source: http://wiki.mikrotik.com/index.php?title=File:Bgp-multihoming.png  License: unknown  Contributors: Marisb
File:bgp-multihoming-download-sharing.png  Source: http://wiki.mikrotik.com/index.php?title=File:Bgp-multihoming-download-sharing.png  License: unknown  Contributors: Marisb
Image:Bonding ARP Monitoring Exam.jpg  Source: http://wiki.mikrotik.com/index.php?title=File:Bonding_ARP_Monitoring_Exam.jpg  License: unknown  Contributors: Eugene
File:two-link-example.png  Source: http://wiki.mikrotik.com/index.php?title=File:Two-link-example.png  License: unknown  Contributors: Marisb
Image:Icon-warn.png  Source: http://wiki.mikrotik.com/index.php?title=File:Icon-warn.png  License: unknown  Contributors: Marisb, Route
Image:ospfv3_setup.png  Source: http://wiki.mikrotik.com/index.php?title=File:Ospfv3_setup.png  License: unknown  Contributors: Route

You might also like