OSPF

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.

Commands in this article follow RouterOS v7 documentation but have not yet been marked as lab-tested on this site. Always test changes in a lab or maintenance window and keep a backup.

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 add fail on RouterOS v7.
  • Routers do not become neighbors, or the neighbor stays in ExStart or 2-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 ether2 10.0.12.1/30 and R2 ether2 10.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):

RouterOS CLI
/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 passive

To advertise a LAN, add it as a passive template, for example 192.168.10.0/24:

RouterOS CLI
/routing ospf interface-template add area=backbone networks=192.168.10.0/24 passive

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

RouterOS CLI
/ip firewall filter add chain=input protocol=ospf action=accept comment="Allow OSPF" place-before=0

Verification

RouterOS CLI
/routing ospf neighbor print
/ip route print where ospf

The 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 (ptp on one side, broadcast on 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

RouterOS CLI
/routing ospf instance disable ospf-v2

Disabling 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

Go deeper in class

This topic is covered hands-on in MTCRE — MikroTik Certified Routing Engineer.

View MTCRE
WhatsApp