Open Shortest Path First (OSPF) is a robust and efficient routing protocol widely used in enterprise networks. It enables routers to communicate routing information dynamically, allowing for optimal path selection based on network conditions. In this blog post, we'll guide you through configuring OSPF on Cisco routers, ensuring you understand how to set up interfaces before enabling OSPF.
In our example, we have two routers, each with multiple networks:
First, we will configure the interfaces on Router 1.
Router1# configure terminal Router1(config)# interface GigabitEthernet0/0 Router1(config-if)# ip address 192.168.1.1 255.255.255.0 Router1(config-if)# no shutdown Router1(config-if)# exit Router1(config)# interface GigabitEthernet0/1 Router1(config-if)# ip address 10.0.0.1 255.255.255.0 Router1(config-if)# no shutdown Router1(config-if)# exit Router1(config)# exit
Next, we will configure the interfaces on Router 2.
Router2# configure terminal Router2(config)# interface GigabitEthernet0/0 Router2(config-if)# ip address 10.0.0.2 255.255.255.0 Router2(config-if)# no shutdown Router2(config-if)# exit Router2(config)# interface GigabitEthernet0/1 Router2(config-if)# ip address 192.168.2.1 255.255.255.0 Router2(config-if)# no shutdown Router2(config-if)# exit Router2(config)# interface GigabitEthernet0/2 Router2(config-if)# ip address 192.168.3.1 255.255.255.0 Router2(config-if)# no shutdown Router2(config-if)# exit Router2(config)# exit
After configuring the interfaces, we can now set up OSPF on Router 1.
Router1# configure terminal Router1(config)# router ospf 1 Router1(config-router)# router-id 1.1.1.1 Router1(config-router)# network 10.0.0.0 0.0.0.255 area 0 Router1(config-router)# network 192.168.1.0 0.0.0.255 area 0 Router1(config-router)# exit Router1(config)# exit
Now let's configure OSPF on Router 2.
Router2# configure terminal Router2(config)# router ospf 1 Router2(config-router)# router-id 2.2.2.2 Router2(config-router)# network 10.0.0.0 0.0.0.255 area 0 Router2(config-router)# network 192.168.2.0 0.0.0.255 area 0 Router2(config-router)# network 192.168.3.0 0.0.0.255 area 0 Router2(config-router)# exit Router2(config)# exit
After configuring OSPF on both routers, it's essential to verify that the OSPF neighbors are established and routes are learned.
Use the following commands on both routers:
Router1# show ip ospf neighbor Router1# show ip route ospf
Router2# show ip ospf neighbor Router2# show ip route ospf
Finally, we’ll test the connectivity between Router 1 and Router 2 using the ping command. Below is a simulated PuTTY output for pinging from Router 1 to Router 2.
Router1> enable Router1# ping 192.168.3.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 10.20.32.251, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 3/4/7 ms Router1#
In this post, we walked through the complete process of configuring OSPF on Cisco routers. By first configuring the interfaces, we ensured that our network topology was properly established before enabling OSPF. This methodical approach helps prevent configuration errors and makes troubleshooting more manageable.
If you have any questions or need further assistance with OSPF or Cisco configurations, feel free to leave a comment below. Happy networking!