RIP
CLI reference:/routing/rip/instance/routing/rip/interface-template/routing/rip/interface/routing/rip/neighbor/routing/rip/static-neighbor/routing/rip/keys
RIP (Routing Information Protocol) is a distance-vector routing protocol. Each router sends its routes to its neighbors about every 30 seconds, and the neighbors add the cost of the interface the update arrived on, by default 1, to the metric. A route with a metric of 16 is unreachable, so RIP works in networks where no path is longer than 15 hops.
RouterOS runs RIP version 2 (RFC 2453) for IPv4 and RIPng (RFC 2080) for IPv6. Version 1 (RFC 1058) is not supported.
A RIP configuration has these parts:
- An instance in
/routing/rip/instancesets the address family, the VRF, which routes RIP advertises (redistribute,originate-default) and the route filters. - Interface templates in
/routing/rip/interface-templateselect the interfaces RIP runs on and set their mode, cost and authentication. - Optional static neighbors in
/routing/rip/static-neighborand authentication keys in/routing/rip/keys.
/routing/rip/interface and
/routing/rip/neighbor show the state.
On a router with the default firewall, accept RIP (UDP port 520) on the RIP interfaces, see Allow routing protocols.
For RIPng, accept UDP port 521 in /ipv6/firewall/filter.
Configure RIP on three routers
Three routers are connected in a row: R1 ether2 (10.0.12.1/30) to R2 ether2 (10.0.12.2/30), and R2
ether3 (10.0.23.1/30) to R3 ether2 (10.0.23.2/30). R1 has the LAN 192.168.1.0/24 on bridge, R3 has
192.168.3.0/24 on bridge. R1 is also connected to the internet on ether1. RIP makes the two LANs
reachable from each other.
RIP passes on the routes it learns from its neighbors. Other routes, including the networks of the RIP
interfaces, are advertised only when their type is listed in redistribute, so R1 and R3 redistribute
their connected networks. redistribute=connected
covers every connected network, including the WAN network on ether1, so a route filter limits the
advertised routes to 192.168.0.0/16. On R1:
/routing/filter/rule
add chain=rip-out rule="if (dst in 192.168.0.0/16) { accept }"
/routing/rip/instance
add name=rip1 redistribute=connected out-filter-chain=rip-out
/routing/rip/interface-template
add instance=rip1 interfaces=ether2
add instance=rip1 interfaces= mode=passive
The LAN interface is a RIP interface in mode=passive: the router sends no RIP updates to the LAN
devices, but still accepts updates from a router on the LAN.
R2 only passes routes on, so it needs no redistribute:
/routing/rip/instance
add name=rip1
/routing/rip/interface-template
add instance=rip1 interfaces=ether2
add instance=rip1 interfaces=ether3
R3 uses the same configuration as R1:
/routing/filter/rule
add chain=rip-out rule="if (dst in 192.168.0.0/16) { accept }"
/routing/rip/instance
add name=rip1 redistribute=connected out-filter-chain=rip-out
/routing/rip/interface-template
add instance=rip1 interfaces=ether2
add instance=rip1 interfaces= mode=passive
Check neighbors and routes
A router lists a neighbor when it receives RIP updates from it. On R1:
[admin@MikroTik] > /routing/rip/neighbor/print detail
Flags: D - DYNAMIC
0 D instance=rip1 address=10.0.12.2%ether2 routes=1 packets-total=5
last-update=12s
routes is the number of routes received from the neighbor. A neighbor can have routes=0, for example
when it has no routes to advertise. When a neighbor sends no update for route-timeout (180 seconds by
default), its routes are removed from the routing table.
The RIP routes have distance 120. rip.metric is the hop count to the destination: R3 advertises its LAN
with metric 1, R2 adds 1 and R1 adds 1:
[admin@MikroTik] > /routing/route/print detail where rip
Flags: A - ACTIVE; r - RIP
Ar afi= contribution=active dst-address=192.168.3.0/24 routing-table=main
gateway=10.0.12.2%ether2 immediate-gw=10.0.12.2%ether2 distance=120 scope=20
target-scope=10 belongs-to="rip1" rip.tag=0 .metric=3
debug.fwp-ptr=0x203C2420
When a neighbor or a route is missing, check the log: RIP logs with the route and rip topics.
Advertise a default route
originate-default advertises a default route:
never- Do not advertise a default route.always- Always advertise a default route.if-installed- Advertise a default route only when the router has an active one.
The out filter applies to the default route too. To let R1 advertise its default route from ether1 to the other routers:
/routing/filter/rule
add chain=rip-out rule="if (dst == 0.0.0.0/0) { accept }"
/routing/rip/instance
set [find name=rip1] originate-default=if-installed
R2 then has a RIP default route through R1. Check it with
/ip/route/print where dst-address=0.0.0.0/0.
Use passive and strict interfaces
mode of an interface template changes how RIP uses the interface:
passive- The router does not send updates on the interface, but receives them.strict- The router sends updates on the interface only as unicast to the static neighbors and ignores multicast updates.
A passive interface sends nothing, also not to static neighbors.
Without mode, the router sends updates to the multicast address 224.0.0.9 and receives updates from
any router on the interface.
Add static neighbors
On a link where multicast does not reach the neighbor, add the neighbor in
/routing/rip/static-neighbor. The router sends its
updates to a static neighbor as unicast. Without mode, it sends the multicast updates too. With
mode=strict, the router talks only to its static neighbors. On R2:
/routing/rip/interface-template
set [find interfaces=ether3] mode=strict
/routing/rip/static-neighbor
add instance=rip1 address=10.0.23.2
A strict interface ignores R3's multicast updates, so R3 sends unicast updates to R2 too:
/routing/rip/static-neighbor
add instance=rip1 address=10.0.23.1
Change the interface cost
The router adds the cost of the interface template to the metric of every route it receives on the
interface. A higher cost makes a path less preferred. To add 5 instead of 1 on R1's ether2:
/routing/rip/interface-template
set [find interfaces=ether2] cost=5
R1's metric to 192.168.3.0/24 becomes 2 + 5:
[admin@MikroTik] > /routing/route/print detail where rip
Flags: A - ACTIVE; r - RIP
Ar afi= contribution=active dst-address=192.168.3.0/24 routing-table=main
gateway=10.0.12.2%ether2 immediate-gw=10.0.12.2%ether2 distance=120 scope=20
target-scope=10 belongs-to="rip1" rip.tag=0 .metric=7
debug.fwp-ptr=0x203C2420
Authenticate RIP messages
RIP authenticates messages with MD5 keys from a key chain. Create the same key chain on both routers of a link and set it on the interface template. On R1 and R2, create the key chain:
/routing/rip/keys
add chain=rip-keys key-id=1 key=Ex4mple-key
Then use it on the link:
/routing/rip/interface-template
set [find interfaces=ether2] key-chain=rip-keys
The key is at most 16 characters long, and key-id is from 0 to 254. Both ends must use the same key ID
and key, and the chain names can differ. Until both ends use the key, the router does not accept the
neighbor's routes and logs a route,rip,warning message for each update: message without authentication when the neighbor has no key, message crypto auth failed when the keys differ. On R1, before R2 has the key (%*1c is the internal ID of the
interface):
2026-12-01 11:32:45 route,rip,warning instance { 0 IP } message without authentication from 10.0.12.2%*1c
password sets plain-text
authentication instead: the password is sent unencrypted in every update, so prefer a key chain. When both
are set, the router uses the key chain.
Filter RIP routes
RIP uses routing filters: in-filter-chain of the instance filters
the routes received from neighbors, out-filter-chain filters the routes RIP advertises. A route that
reaches the end of a chain without accept is rejected. RouterOS has no prefix lists: write the prefixes
in the filter rules. To accept only the 192.168.0.0/16 networks from R1's neighbors:
/routing/filter/rule
add chain=rip-in rule="if (dst in 192.168.0.0/16) { accept }"
/routing/rip/instance
set [find name=rip1] in-filter-chain=rip-in
A route that the in filter rejects stays in /routing/route with the F (filtered) flag and is not
installed in /ip/route.
Filters can also change routes. In an in filter, set distance 100 installs the routes with distance 100
instead of 120. In an out filter, set rip-ext-metric 5 advertises the route with metric 5 instead of 1,
for example on R3:
/routing/filter/rule
add chain=rip-out rule="if (dst == 192.168.3.0/24) { set rip-ext-metric 5; accept }" \
place-before=([find chain=rip-out]->0)
Run RIPng for IPv6
An instance with afi=ipv6 runs RIPng. The neighbors use their link-local addresses. On R1, with
2001:db8:1::/64 on the LAN and an out filter as for IPv4:
/ipv6/address
add address=2001:db8:1::1/64 interface=
/routing/filter/rule
add chain=rip6-out rule="if (dst in 2001:db8::/32) { accept }"
/routing/rip/instance
add name=rip6 afi= redistribute=connected out-filter-chain=rip6-out
/routing/rip/interface-template
add instance=rip6 interfaces=ether2
add instance=rip6 interfaces= mode=passive
On R2:
/routing/rip/instance
add name=rip6 afi=
/routing/rip/interface-template
add instance=rip6 interfaces=ether2
R2 learns the LAN with R1's link-local address as the gateway:
[admin@MikroTik] > /ipv6/route/print where rip
Flags: D - DYNAMIC; A - ACTIVE; r - RIP
Columns: DST-ADDRESS, GATEWAY, ROUTING-TABLE, DISTANCE
DST-ADDRESS GATEWAY ROUTING-TABLE DISTANCE
DAr 2001:db8:1::/64 fe80::90e8:17ff:fe7b:46cc%ether2 main 120
Technical details
Packets
- RIPv2 updates go to UDP port 520 of the multicast address 224.0.0.9, with IP TTL 1, or as unicast to static neighbors.
- RIPng updates go to UDP port 521 of ff02::9 from the link-local address, with hop limit 255.
- A change, such as a new or removed connected network, is sent immediately in a triggered update, without waiting for the update interval.
- With a key chain, each update carries an authentication header with the key ID and an MD5 trailer.
Metric and split horizon
- A redistributed route is advertised with metric 1. The receiving router adds the cost of the interface and installs the route with distance 120.
- By default the router advertises a route back on the interface it was learned on with metric 16
(poison reverse). With
poison-reverse=no, it does not advertise the route on that interface at all (split horizon).
Timers
update-interval: the interval between updates, 1 to 1800 seconds. Updates are sent about every 30 seconds by default.route-timeout: when no update for a route arrives for this time, the route is removed from the routing table and advertised with metric 16. 5 to 1800 seconds. Default: 180.route-gc-timeout: how long the router keeps advertising a timed-out route with metric 16 before it stops advertising it. 5 to 1800 seconds.
All properties are described in the CLI reference, starting from
/routing/rip/instance.