Why would somebody want to run Open Shortest Path First (OSPF) on their network?
By utilizing the OSPF dynamic routing protocol, the number of static routes would be reduced. OSPF would also allow automatic route updates when a new network has been added. As a path to a new network has been changed, OSFP would also allow automatic route updates as the devices or links behave upward or downward.
Taking a step backwards to look at the basics of OSPF may clarify some of the initial questions on why this is actually useful. OSPF is best served by running inside of a single Autonomous System, which are a group of devices under a single administrative control. The OSPF enables network routers to share information with one another. These connected routers within the OSPF network are referred to as Neighbors. The Neighbors are identified by an IP address that the router will use to identify itself to other routers running OSPF, known as the router ID. An initial connection can be made by utilizing a Hello packet, which is a special packet sent out periodically by a network router to establish and confirm network adjacency. Once the network adjacency relationship is formed, the routers can now share LSA packets.
OSPF is best set up with a router ID set to a loopback address. To set this up, first set up a bridge and name it “Loopback.” The next step is to assign the bridge a private address that no existing device already uses (i.e. 184.108.40.206). This will allow the router to be keep the same router ID in the event that an interface goes down. Step three involves adding an instance in order to set the router ID to loopback address that had been set up before. To do so go into Routing > OSPF. The last step will be to turn on OSFP and start to broadcast Hello packets on the network to the Neighbor routers.
Running the Process
Once all of the aforementioned steps have been completed the routing table will be populated with dynamic routes created by the OSPF process running on the router. If any of the OSPF routes are set to the default cost of 110, they will take precedence unless changed over the 110 value. In other words, OSPF will always use the highest IP address on the router’s loopback interface, regardless of OSPF enabled loopback.
To truly see OSFP in action, add the following lines of code into three demo routers:
Add Bridges on R1, R2, R3
/interface bridgeadd name=LAN add name=Lo0
Add IP addresses to routersR1
/ip address add address=172.16.1.1/24 interface=LAN network=172.16.1.0 add address=10.0.2.2/30 interface=ether1 network=10.0.2.0 add address=10.0.0.1/30 interface=ether5 network=10.0.0.0 add address=220.127.116.11/32 interface=Lo0 network=18.104.22.168
/ip address add address=172.16.2.1/24 interface=LAN network=172.16.2.0 add address=10.0.1.1/30 interface=ether5 network=10.0.1.0 add address=10.0.0.2/30 interface=ether1 network=10.0.0.0 add address=22.214.171.124/32 interface=Lo0 network=126.96.36.199
/ip address add address=10.0.1.2/30 interface=ether1 network=10.0.1.0 add address=10.0.2.1/30 interface=ether5 network=10.0.2.0 add address=172.16.3.1/24 interface=LAN network=172.16.3.0 add address=188.8.131.52/32 interface=Lo0 network=184.108.40.206
Setup instance and set router-ID
/routing ospf instance set [ find default=yes ] router-id=220.127.116.11
/routing ospf instance set [ find default=yes ] router-id=18.104.22.168
/routing ospf instance set [ find default=yes ] router-id=22.214.171.124
Add network statements for each network you wish to advertise
/routing ospf network add area=backbone network=172.16.1.0/24 add area=backbone network=10.0.0.0/30 add area=backbone network=10.0.2.0/30 add area=backbone network=126.96.36.199/32
/routing ospf network add area=backbone network=172.16.2.0/24 add area=backbone network=10.0.1.0/30 add area=backbone network=10.0.0.0/30 add area=backbone network=188.8.131.52/32
/routing ospf network add area=backbone network=172.16.3.0/24 add area=backbone network=10.0.2.0/30 add area=backbone network=10.0.1.0/30 add area=backbone network=184.108.40.206/32
Below is an example of R1’s routing table after all the routers have been setup.