What is OSPF and why to use it?
Open Shortest Path First (OSPF) is interior gateway protocol (IGP) that makes use of a link state routing (LSR) algorithm. OSPF supports complex networks with multiple routers and may be structured, or subdivided, into routing areas to simplify administration and optimize traffic and resource utilization. Areas are defined as the backbone area, stub area, not-so-stubby area, or a totally stubby area. Router types are defined as internal router (IR), area border router (ABR), backbone router (BR), or autonomous system boundary router (ASBR). In addition to the four router types, OSPF uses the terms designated router (DR) and backup designated router (BDR).
In the network below there are a total of three routers and three end-user computers. In real world deployments a network could have dozens or hundreds of routers or devices depending on the scale of the network. Regardless of the network complexity dynamic routing serves the same role in that its purpose is to share routes with other routers so devices know how to transverse networks and remote devices can return traffic back to the requester. Hence, the creation of dynamic routing.
Steps to configure OSPF
Step 1: Configure all applicable router interfaces.
R1(config)#interface FastEthernet0/0 R1(config-if)#ip address 10.1.0.1 255.255.255.0 ! R1(config)#interface FastEthernet1/0 R1(config-if)#ip address 10.250.3.2 255.255.255.252 ! R1(config)#interface FastEthernet1/1 R1(config-if)#ip address 10.250.1.1 255.255.255.252
Step 2: Enable a OSPF routing process with each router having a unique router-id, enable OSPF routing on all applicable IP networks within one or more OSPF areas.
R1(config)#router ospf 101 R1(config-router)#router-id 10.250.1.1 R1(config-router)#network 10.1.0.0 0.0.0.255 area 1 R1(config-router)#network 10.250.0.0 0.0.255.255 area 0
In addition to the above, I recommend performing a few additional configurations for troubleshooting and security purposes. This prevents the possibility of rogue routers from forming an adjacency and protect the routing table from willful or accidental corruption.
Step 3: Log neighbor up/down and reset reasons.
R1(config)#router ospf 101 R1(config-router)#log-adjacency-changes
Step 4: Configure OSPF peer authentication used to form an adjacency.
R1(config)#interface FastEthernet1/0 R1(config-if)#ip ospf authentication-key ospf-pw1 ! R1(config)#interface FastEthernet1/1 R1(config-if)#ip ospf authentication-key ospf-pw1 ! R1(config)#router ospf 101 R1(config-router)#area 0 authentication
Caution: When peer authentication is added to the interface of a router, that router stops receiving routing messages from its peers until they are also configured for authentication. This does interrupt routing communications on your network.
Step 5: Configure password encryption on your routers so the passwords are not shown in the configuration in clear text.
Step 6: Suppress routing updates out of interfaces not used to form an adjacency.
R1(config)#router ospf 101 R1(config-router)#passive-interface fa0/0
Step 7: Repeat the same steps on all remaining routers with the applicable interface and routing configurations.
Verify the configuration
Now that the configuration is finished lets verify our neighbors and routes. Using the show ip ospf neighbor and show ip route commands you can verify the remote routers to which your router has formed an adjacency and verify the expected routes are being advertised. Use the ping command to verify connectivity.