Wednesday, December 16, 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 - 192.168.1.1/24
loopback 0 - 172.16.10.0/24
loopback 1 - 10.1.1.0/24

Router 2 (R2)
FastEthernet 0/0 - 192.168.1.2/24
FastEthernet 1/0 - 192.168.2.1/24

Router 3 (R3)
FastEthernet 0/0 - 192.168.2.2/24


Okay, lets get started.

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

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

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


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 192.168.1.0 0.0.0.255 area 0
R1(config-router)#network 172.16.10.0 0.0.0.255 area 0
R1(config-router)#end

I also have an network 10.1.1.0 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 192.168.1.0 0.0.0.255 area 0
R2(config-router)#network 192.168.2.0 0.0.0.255 area 0
R2(config-router)#end


R3#conf t
R3(config)#router ospf 10
R3(config-router)#network 192.168.2.0 0.0.0.255 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
172.16.0.0/32 is subnetted, 1 subnets
O 172.16.10.1 [110/3] via 192.168.2.1, 00:06:53, FastEthernet0/0
O 192.168.1.0/24 [110/2] via 192.168.2.1, 00:06:53, FastEthernet0/0
C 192.168.2.0/24 is directly connected, FastEthernet0/0

And can I ping the 172.16.10.1 interface?

R3#ping 172.16.10.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.10.1, 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-router)#exit

R1(config)#ip route 0.0.0.0 0.0.0.0 loopback 0
R1(config)#exit

R1#sh ip route
Gateway of last resort is 0.0.0.0 to network 0.0.0.0
172.16.0.0/24 is subnetted, 1 subnets
C 172.16.10.0 is directly connected, Loopback0
10.0.0.0/24 is subnetted, 1 subnets
C 10.1.1.0 is directly connected, Loopback1
C 192.168.1.0/24 is directly connected, FastEthernet0/0
O 192.168.2.0/24 [110/2] via 192.168.1.2, 00:20:59, FastEthernet0/0
S* 0.0.0.0/0 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 192.168.2.1 to network 0.0.0.0

172.16.0.0/32 is subnetted, 1 subnets
O 172.16.10.1 [110/3] via 192.168.2.1, 00:23:59, FastEthernet0/0
O 192.168.1.0/24 [110/2] via 192.168.2.1, 00:23:59, FastEthernet0/0
C 192.168.2.0/24 is directly connected, FastEthernet0/0
O*E2 0.0.0.0/0 [110/1] via 192.168.2.1, 00:04:23, FastEthernet0/0
R3#

Bingo! All done.

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

+++

Share |

"make something then You never be lost"

wibiya widget