Friday, September 25, 2009

IP Routing - OSPF

In this post I'm going to describe a few benefits of OSPF and how to configure it.

OSPF stands for Open Shortest Path First and and is a link state, non-proprietary, classless routing protocol. OSPF uses the dijkstra algorithm to calculate routes and has an administrative distance of 110.

The main advantages of OSPF are the fast convergence time and the low bandwidth use. Unlike RIP which is a flat network OSPF networks can be structured. Areas are used to structure the network and each router needs to have an interface in area 0 which is the backbone network. For the CCNA exam only area 0 is used. OSPF can also be configured to use authentication on it's routing updates.

Configuring OSPF

Below is a diagram of the routers I'll be referring to in this post.

Router 1 (R1)
FastEthernet 0/0 -
loopback 0 -
loopback 1 -

Router 2 (R2)
FastEthernet 0/0 -
FastEthernet 1/0 -

Router 3 (R3)
FastEthernet 0/0 -

Okay, lets get started.

I'll remove RIP so router 3 doesn't know about the subnet on router 1.

R3#conf t
R3(config)#no router rip

R3#sh ip route
Gateway of last resort is not set
C is directly connected, FastEthernet0/0

Below I'll remove RIP from Routers 1, 2 and 3, configure them with OSPF and verify routes propagated.

R1#conf t
R1(config)#no router rip
R1(config)#router ospf 10
R1(config-router)#network area 0
R1(config-router)#network area 0

I also have an network that I dont want published so I leave this out.

R2#conf t
R2(config)#no router rip
R2(config)#router ospf 10
R2(config-router)#network area 0
R2(config-router)#network area 0

R3#conf t
R3(config)#router ospf 10
R3(config-router)#network area 0

Notice, I just create the routes that I want advertised and place them into Area 0. All routers must have at least one interface in Area 0. I have used 10 as the OSPF process ID. this could be different on each router but its easier to remember if it is all the same.

Great. Now I verify that the routes have been propagated.

R3#sh ip route
Gateway of last resort is not set is subnetted, 1 subnets
O [110/3] via, 00:06:53, FastEthernet0/0
O [110/2] via, 00:06:53, FastEthernet0/0
C is directly connected, FastEthernet0/0

And can I ping the interface?

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to, timeout is 2 seconds:
Success rate is 100 percent (5/5), round-trip min/avg/max = 52/72/96 ms

Ok this is all good but I can see on the routing table of R3 (shown above) that I have no gateway of last resort set. I want to set this to go to loopback 0 on R1.

To fix this I'll go back to R1, tell OSPF to advertise the gateway route and then create a static route to set the gateway of last resort. Here's how:

R1(config)#router ospf 10
R1(config-router)#default-information originate

R1(config)#ip route loopback 0

R1#sh ip route
Gateway of last resort is to network is subnetted, 1 subnets
C is directly connected, Loopback0 is subnetted, 1 subnets
C is directly connected, Loopback1
C is directly connected, FastEthernet0/0
O [110/2] via, 00:20:59, FastEthernet0/0
S* is directly connected, Loopback0

And I have another look on R3 to make sure it has got to that network.

R3#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 to network is subnetted, 1 subnets
O [110/3] via, 00:23:59, FastEthernet0/0
O [110/2] via, 00:23:59, FastEthernet0/0
C is directly connected, FastEthernet0/0
O*E2 [110/1] via, 00:04:23, FastEthernet0/0

Bingo! All done.

Here is a link to a great article on OSPF
Here is a link to some great OSPF videos

No comments: