Categories


Authors

MikroTik OSPF Routing

You can now get MikroTik training direct from Manito Networks. MikroTik Security Guide and Networking with MikroTik: MTCNA Study Guide by Tyler Hart are both available in paperback and Kindle!

MikroTik OSPF Routing

Open Shortest Path First (OSPF) is a Link-State routing protocol used by routers to dynamically exchange route information. It's an open, industry-standard protocol supported by all major vendors. While OSPF doesn't move traffic across the network on its own, it does allow routers to discover network paths. Configuring it on MikroTik router's isn't difficult, and the long-term benefits of using dynamic routing can be big.

OSPF Configuration

The following sections walk us through configuring interfaces, adding address, setting up OSPF, and advertising networks:

  1. Physical Connections
  2. Loopback Interfaces
  3. Assigning IP Addresses
  4. OSPF Instance Configuration
  5. Advertising Networks

Physical Connections

We'll establish the point-to-point links between the router first. This provides the foundation for OSPF to communicate. The link from top—middle routers will use the 172.16.0.0/30 subnet. The link from middle—bottom routers will use the 172.16.0.4/30 subnet.

On the top router:

/ip address
add interface=ether2 address=172.16.0.1/30

On the middle router:

/ip address
add interface=ether1 address=172.16.0.2/30
add interface=ether2 address=172.16.0.5/30

On the bottom router:

/ip address
add interface=ether1 address=172.16.0.6/30

Loopback Interfaces

We'll use virtual loopback (bridge) interfaces for this exercise. This makes the following steps work across any router model, regardless of how many ethernet ports it has. Running OSPF on a virtual interface also makes the protocol more stable, because that interface will always be online. The following commands create new bridge interfaces on all three of our routers:

On the top router:

/interface bridge
add name=ospf comment="OSPF loopback"
add name=lan comment="LAN"

On the middle router:

/interface bridge
add name=ospf comment="OSPF loopback"
add name=lan comment="LAN"

On the bottom router:

/interface bridge
add name=ospf comment="OSPF loopback"
add name=lan comment="LAN"

Assigning IP Addresses

Each ospf bridge interface needs an IP address that can be used later to identify the router. LAN interfaces need addresses for connecting user-facing LANs. Use the following commands to assign IP addresses to the new bridge interfaces:

On the top router:

/ip address
add interface=ospf address=10.255.255.1
add interface=lan address=192.168.1.1/24

On the middle router:

/ip address
add interface=ospf address=10.255.255.2
add interface=lan address=192.168.2.1/24

On the bottom router:

/ip address
add interface=ospf address=10.255.255.3
add interface=lan address=192.168.3.1/24

OSPF Instance Configuration

We'll configure the IP addresses created in the previous steps as the OSPF router's ID. Since the top router is attached to an upstream provider we'll also advertise the default route from that device. Use the following commands to configure the OSPF instances:

On the top router:

/routing ospf instance
set default router-id=10.255.255.1
set default distribute-default=always-as-type-1

On the middle router:

/routing ospf instance 
set default router-id=10.255.255.2

On the bottom router:

/routing ospf instance 
set default router-id=10.255.255.3

Advertising Networks

With our OSPF instances configured properly we can now begin advertising our connected networks. OSPF will advertise the following networks and addresses:

  • OSPF loopback
  • Point-to-point router links
  • LAN subnets

Use the following commands to advertise the routes directly connected on each router:

On the top router:

/routing ospf network
add network=10.255.255.1 area=backbone comment=Loopback
add network=172.16.0.0/30 area=backbone comment="Middle router"
add network=192.168.1.0/24 area=backbone comment=LAN

On the middle router:

/routing ospf network
add network=10.255.255.2 area=backbone comment=Loopback
add network=172.16.0.0/30 area=backbone comment="Top router"
add network=172.16.0.4/30 area=backbone comment="Bottom router"
add network=192.168.2.0/24 area=backbone comment=LAN

On the bottom router:

/routing ospf network
add network=10.255.255.3 area=backbone comment=Loopback
add network=172.16.0.4/30 area=backbone comment="Middle router"
add network=192.168.3.0/24 area=backbone comment=LAN

Verifying OSPF

With networks connected and OSPF configured we need to verify functionality. The following sections walk us through checking the status of OSPF routing:

  1. Neighbor Routers
  2. OSPF Routes

Neighbor Routers

By now OSPF should have established neighbor states between devices. The best device to check for neighbors is the middle router — if it has two neighbors then the top and bottom routers must be configured correctly. List the OSPF neighbors on the device with the following command:

/routing ospf neighbor print

OSPF Routes

List the routes in OSPF's route table:

/routing ospf route print

The best routes for a given destination will be copied from the protocol's route table to the main route table.

Six Step Troubleshooting Method

MikroTik Rogue DHCP Server Alerting