OSPF Configuration on MikroTik RouterOS v7 (Step by Step)
Set up single-area OSPF between MikroTik routers on RouterOS v7: instance, area, interface templates, loopback, verification and the most common neighbor problems.
Problem
You need dynamic routing between two or more MikroTik routers, and the RouterOS v6 OSPF commands no longer work on v7.
Symptoms
- Commands such as
/routing ospf network addfail on RouterOS v7. - Routers do not become neighbors, or the neighbor stays in
ExStartor2-Way.
Likely causes
RouterOS v7 rebuilt OSPF. Networks are now added with interface templates, and instances and areas are separate objects. Most neighbor problems come from a mismatched MTU, area or network type, or from a firewall dropping OSPF packets.
Prerequisites
- Two routers connected by a link, for example R1
ether210.0.12.1/30 and R2ether210.0.12.2/30. - RouterOS v7 on both routers.
- A unique loopback address on each router for the router ID.
Solution (WinBox / CLI)
On R1 (repeat on R2 with its own addresses: loopback 10.255.255.2/32 and link 10.0.12.2/30):
/interface bridge add name=loopback
/ip address add address=10.255.255.1/32 interface=loopback
/ip address add address=10.0.12.1/30 interface=ether2
/routing ospf instance add name=ospf-v2 version=2 router-id=10.255.255.1
/routing ospf area add name=backbone area-id=0.0.0.0 instance=ospf-v2
/routing ospf interface-template add area=backbone interfaces=ether2 type=ptp
/routing ospf interface-template add area=backbone interfaces=loopback passiveTo advertise a LAN, add it as a passive template, for example 192.168.10.0/24:
/routing ospf interface-template add area=backbone networks=192.168.10.0/24 passiveNote: type=ptp is ideal for a link between exactly two routers. Both ends must use the same network type.
If your input firewall drops traffic that does not come from the LAN, allow OSPF:
/ip firewall filter add chain=input protocol=ospf action=accept comment="Allow OSPF" place-before=0Verification
/routing ospf neighbor print
/ip route print where ospfThe neighbor state must be Full, and the other router's networks appear in the routing table as OSPF routes.
Common errors
- Stuck in ExStart or Exchange: the MTU is different on the two ends. Use the same MTU on both interfaces.
- Stuck in Init or 2-Way: network type mismatch (
ptpon one side,broadcaston the other), or the firewall drops OSPF (IP protocol 89). - No neighbor at all: different area IDs, different subnets on the link, or hello and dead timers that do not match.
- Duplicate router ID: every router needs a unique
router-id.
Rollback
/routing ospf instance disable ospf-v2Disabling the instance removes the OSPF routes. Re-enable it with enable. Static routes are not affected.
Watch the video (RouterOS v6; the concepts are the same): How to configure OSPF in MikroTik router
This topic is covered hands-on in MTCRE — MikroTik Certified Routing Engineer.
View MTCRE