Thursday, 14 August 2014

Basic OSPF Configuration and Route Advertisement

So I figured I'd start off this new blog with a very basic tutorial on how to establish an OSPF adjacency between two neighboring routers. I will also demonstrate how to advertise networks from one OSPF router to the other and vice versa. I will be using the following topology:
The end goal of this tutorial is to get connectivity from R1 to R2 via it's loopback0 address, and from R2 to R1 via it's loopback0 address.  I have already pre-configured the IP addresses on each FastEthernet interface along with the loopback0 interface of each router. All interfaces are up/up and each router can see the 192.168.1.0/24 network in its routing table because it's a directly connected network.

Step 1 - Basic OSPF Configuration


R1(config)#router ospf 10
R1(config-router)#router-id 10.10.10.1
R1(config-router)#network 192.168.1.0 0.0.0.255 area 0

R2(config)#router ospf 20
R2(config-router)#router-id 20.20.20.1
R2(config-router)#network 192.168.1.0 0.0.0.255 area 0

Note that the process ID I used on R2 is different than that of R1.  This is simply to demonstrate that the process ID is locally significant meaning it doesn't matter to R2 what R1's proceed ID is and vice versa.  However there are a few rules that must be followed in order for neighbors to form an OSPF adjacency:

Both OSPF routers must be configured in the same area
Both OSPF router interfaces must be on the same subnet
Both OSPF routers must have unique router ID's
Both OSPF routers must have the same hello and dead timer values

If you have done everything correctly so far you should see the OSPF adjacency come up between the two routers as evidenced by the following message on each router:

R1(config-router)#
*Aug 14 09:42:37.655: %OSPF-5-ADJCHG: Process 10, Nbr 20.20.20.1 on FastEthernet0/0 from LOADING to FULL, Loading Done
R1(config-router)#

R2(config-router)#
*Aug 14 09:42:38.195: %OSPF-5-ADJCHG: Process 20, Nbr 10.10.10.1 on FastEthernet0/0 from LOADING to FULL, Loading Done
R2(config-router)#

Step 2 - Verify OSPF Adjacency


You can verify that you have established an OSPF adjacency with your neighboring router by using the 'show ip ospf neighbor' command.  Below is the output of this command on each router:

R1#show ip ospf neighbor
Neighbor ID     Pri   State           Dead Time   Address         Interface
20.20.20.1        1   FULL/BDR        00:00:35    192.168.1.2     FastEthernet0/0
R1#

R2#show ip ospf neighbor
Neighbor ID     Pri   State           Dead Time   Address         Interface
10.10.10.1        1   FULL/DR         00:00:36    192.168.1.1     FastEthernet0/0
R2#

Step 3 - Route Advertisement


At this point you will notice that if you issue the 'show ip route' command on each router, nothing has changed.  We still only see the directly connected networks - furthermore, if we ping from R1 to R2's loopback0 address, we cannot get there.  You should know that this is because we don't have a route to that network in our routing table.  

R1#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route

Gateway of last resort is not set

     10.0.0.0/24 is subnetted, 1 subnets
C       10.10.10.0 is directly connected, Loopback0
C    192.168.1.0/24 is directly connected, FastEthernet0/0
R1#ping 20.20.20.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 20.20.20.1, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)

What we need to do to establish this connectivity is to advertise the loopback0 routes into OSPF so that R1 tells R2 how to get to the 10.10.10.0/24 network and R2 tells R1 how to get to the 20.20.20.0/24 network.  
R1(config)#router ospf 10
R1(config-router)#network 10.10.10.0 0.0.0.255 area 0
R1(config-router)#

R2(config)#router ospf 20
R2(config-router)#network 20.20.20.0 0.0.0.255 area 0
R2(config-router)#

Now if we check the routing table of reach router, we will see that R1 now as an OSPF route to the 20.20.20.0/24 network and R2 has an OSPF route to the 20.20.20.0/24 network.  

R1#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route

Gateway of last resort is not set

     20.0.0.0/32 is subnetted, 1 subnets
O       20.20.20.1 [110/2] via 192.168.1.2, 00:00:10, FastEthernet0/0
     10.0.0.0/24 is subnetted, 1 subnets
C       10.10.10.0 is directly connected, Loopback0
C    192.168.1.0/24 is directly connected, FastEthernet0/0
R1#

R2#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route

Gateway of last resort is not set

     20.0.0.0/24 is subnetted, 1 subnets
C       20.20.20.0 is directly connected, Loopback0
     10.0.0.0/32 is subnetted, 1 subnets
O       10.10.10.1 [110/2] via 192.168.1.1, 00:02:21, FastEthernet0/0
C    192.168.1.0/24 is directly connected, FastEthernet0/0
R2#

Step 4 - Final Verification

Now that we are advertising the required routes into OSPF, we should be able to ping from R1 to R2 at 20.20.20.1 and R2 to R1 at 10.10.10.1

R1#ping 20.20.20.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 20.20.20.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/76/184 ms
R1#

R2#ping 10.10.10.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.10.10.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 12/74/224 ms
R2#

...and that's it!  We're done.  I will be getting into much more complicated tutorials and labs but for now we'll start off with the easy stuff and gradually work our way into the more difficult stuff as we go along.

Thanks for reading and I hope you found this post helpful and informative.  If you have any questions or feedback etc. please leave a comment down below.








No comments:

Post a Comment