Care to know what dynamic Cisco routing is for and how to set up OSPF in Cisco? Then this article was meant for you!

Let’s look at the following network topology:

Suppose that we are using static routing in this network. Then a necessity arises to add a new router (R4). Routers “know” only about networks that are directly connected to them. In this case we have to manually add all routes to subnets on R4 and add routes to subnets R4 is servicing to other routers:

When network grows, it becomes a very time consuming task. Dynamic routing protocols allow automatic route sharing which simplifies network service. Dynamic routing protocols define best route for sending packages by themselves (we can influence this choice when needed) and choose alternative route when a channel fails.

For example, R3 can connect to R1 using several routes: 10.5.0.4/30, 10.5.0.8/30 -> 10.5.0.0/30 or 10.5.0.16/30 -> 10.5.0.12/30 -> 10.5.0.0/30. Routers using OSPF are constantly exchanging data about known routes and state of connections. When direct channel between R1 and R3 fails, traffic flows over R2 router.

Configuring OSPF

This is how the topology of our network looks like after adding new router (R4):

Let’s start by configuring R1 router. Example of the configuration process is shown further in this article.

Start ospf process:

R1 ( config ) # router ospf 1

Last number is a process ID which can differ for different routers. For the sake of convenience it’s better to use the same number.

Now we turn off sending hello packages for all interfaces. With a safety in mind we are going to explicitly specify interfaces used for neighbor relations.

R1 ( config-router ) #passive-interface default

Next let’s specify interfaces that will be used for sending hello packages. For R1 they are fa0/0 and fa0/1:

R1 ( config-router ) #no passive-interface fa0/0 R1 ( config-router ) #no passive-interface fa0/1

We can do two things using network command: tell which networks we want to announce to other routers over OSPF and which interfaces will be used for sending hello packages. That’s why previously we added specific interfaces for hello packages. For example, we need 3 networks for R1 router: 10.5.0.0/30, 10.5.0.4/30 and 172.16.0.0/26. But the last network will only include user devices and we don’t want somebody to be able to influence routing tables on the routers.

Format of the network command:

network 0.0.0.0 255.255.255.255 area 0

First parameter is a network number, second one is a wildcart mask and the last one is a zone number.

To put it simply, this command tells the router which interfaces are used to announce subnets over OSPF. In the example above we allowed to announce any subnets from any interfaces. Of course this method simplifies configuration but it is not recommended by Cisco since any interface configured on a router will be immediately added to routing tables on other routers. Cisco recommends connecting each network separately. In our network configuration on R1 it’s going to look as follows:

R1 ( config-router ) #network 10.5.0.1 0.0.0.0 area 0 R1 ( config-router ) #network 10.5.0.5 0.0.0.0 area 0 R1 ( config-router ) #network 172.16.0.1 0.0.0.0 area 0

To get a better understanding of the syntax, take a look at this example announcing both service networks (10.5.0.0/30 and 10.5.0.4/30):

R1 ( config-router ) #network 10.5.0.0 0.0.0.255 area 0

Basically it means: “announce subnets from interfaces beginning with 10.5.0”.

Let’s configure R2:

router ospf 1 passive-interface default no passive-interface FastEthernet0 / 0 no passive-interface FastEthernet0 / 1 no passive-interface Vlan30 network 10.5.0.2 0.0.0.0 area 0 network 10.5.0.9 0.0.0.0 area 0 network 10.5.0.13 0.0.0.0 area 0 network 172.16.0.129 0.0.0.0 area 0

Then we get the following notification:

* Mar 1 00:05: 29.875 : % OSPF- 5 -ADJCHG: Process 1 , Nbr 172.16.0.1 on FastEthernet0 / 0 from LOADING to FULL, Loading Done

It means that R1 and R2 have established neighbor relations and exchanged data on the known routes. Now R2 should have one neighbor:

R2# show ip ospf neighbor Neighbor ID Pri State Dead Time Address Interface 172.16.0.1 1 FULL / DR 00:00: 35 10.5.0.1 FastEthernet0 / 0

Take a look at the routing table on R2:

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 172.16.0.0 / 26 is subnetted, 2 subnets C 172.16.0.128 is directly connected, Vlan20 O 172.16.0.0 [ 110 / 11 ] via 10.5.0.1, 00:06: 39 , FastEthernet0 / 0 10.0.0.0 / 30 is subnetted, 3 subnets C 10.5.0.8 is directly connected, Vlan30 O 10.5.0.4 [ 110 / 20 ] via 10.5.0.1, 00:06: 39 , FastEthernet0 / 0 C 10.5.0.0 is directly connected, FastEthernet0 / 0

We got two routes over OSPF from R1 which is indicated by O letter in the beginning of the entry about the route.

R3 configuration:

router ospf 1 passive-interface default no passive-interface FastEthernet0 / 0 no passive-interface FastEthernet0 / 1 no passive-interface Vlan20 network 10.5.0.6 0.0.0.0 area 0 network 10.5.0.10 0.0.0.0 area 0 network 10.5.0.17 0.0.0.0 area 0 network 172.16.0.65 0.0.0.0 area 0

R4 configuration:

router ospf 1 passive-interface default no passive-interface FastEthernet0 / 0 no passive-interface FastEthernet0 / 1 network 10.5.0.14 0.0.0.0 area 0 network 10.5.0.18 0.0.0.0 area 0 network 172.16.1.1 0.0.0.0 area 0 network 172.16.1.65 0.0.0.0 area 0 network 172.16.1.129 0.0.0.0 area 0 network 172.16.1.193 0.0.0.0 area 0

After these manipulations the routing table looks as follows:

R1# show ip route ... 172.16.0.0 / 26 is subnetted, 6 subnets O 172.16.1.128 [ 110 / 21 ] via 10.5.0.6, 00: 11 :05, FastEthernet0 / 1 [ 110 / 21 ] via 10.5.0.2, 00: 11 :05, FastEthernet0 / 0 O 172.16.1.192 [ 110 / 21 ] via 10.5.0.6, 00: 11 :05, FastEthernet0 / 1 [ 110 / 21 ] via 10.5.0.2, 00: 11 :05, FastEthernet0 / 0 C 172.16.0.0 is directly connected, Vlan10 O 172.16.1.0 [ 110 / 21 ] via 10.5.0.6, 00: 11 :05, FastEthernet0 / 1 [ 110 / 21 ] via 10.5.0.2, 00: 11 :05, FastEthernet0 / 0 O 172.16.0.64 [ 110 / 11 ] via 10.5.0.6, 00: 11 :07, FastEthernet0 / 1 O 172.16.1.64 [ 110 / 21 ] via 10.5.0.6, 00: 11 :07, FastEthernet0 / 1 [ 110 / 21 ] via 10.5.0.2, 00: 11 :07, FastEthernet0 / 0 10.0.0.0 / 30 is subnetted, 5 subnets O 10.5.0.12 [ 110 / 20 ] via 10.5.0.2, 00: 11 :07, FastEthernet0 / 0 O 10.5.0.8 [ 110 / 11 ] via 10.5.0.6, 00: 11 :08, FastEthernet0 / 1 [ 110 / 11 ] via 10.5.0.2, 00: 11 :08, FastEthernet0 / 0 C 10.5.0.4 is directly connected, FastEthernet0 / 1 C 10.5.0.0 is directly connected, FastEthernet0 / 0 O 10.5.0.16 [ 110 / 20 ] via 10.5.0.6, 00: 11 : 11 , FastEthernet0 / 1

Now we can simulate uplink failure. Let’s trace the route from the R3 router to the client PC with IP 172.16.0.2:

R3# traceroute 172.16.0.2 Type escape sequence to abort. Tracing the route to 172.16.0.2 1 10.5.0.5 16 msec 16 msec 16 msec 2 172.16.0.2 24 msec 36 msec 44 msec

From a trace log we see that traffic goes directly to R1. Let’s turn off R1 interface that R3 is connected to:

R1# conf t Enter configuration commands, one per line. End with CNTL / Z. R1 ( config ) #interface fa0/1 R1 ( config-if ) #shutdown R1 ( config-if ) #end

R3 notice that channel from R1 has failed:

* Mar 1 03: 32 : 41.567 : % OSPF- 5 -ADJCHG: Process 1 , Nbr 172.16.0.1 on FastEthernet0 / 0 from FULL to DOWN, Neighbor Down: Dead timer expired

Now traffic uses an alternative channel (R3 -> R2 — R1):

R3# traceroute 172.16.0.2 Type escape sequence to abort. Tracing the route to 172.16.0.2 1 10.5.0.9 16 msec 16 msec 16 msec 2 10.5.0.1 40 msec 32 msec 40 msec 3 172.16.0.2 44 msec 48 msec 68 msec

We have finished configuring OSPF with one area (area 0). Now our network uses OSPF for dynamic routing.

Multi Area OSPF

When should we separate the network into several areas? First of all, when we need route aggregation. For example, in our topology R4 router announces 4 routes into the network, but all networks in 172.16.1.0-172.16.1.255 range belong to R4 exclusively. We want to announce only one route: 172.16.1.0/24. It’s especially relevant for large networks with a large routing table.

Secondly, taking into account nature of all link-state protocols of dynamic routing, each router in OSPF knows when any of the network channels fails. Of course this naturally improves the process of choosing an optimal route but significantly increases load. Suppose we have 15 offices in Khmelnytsky and 10 in Vinnytsia. Routers in Vinnytsia don’t need to know that some router in Khmelnytsky has failed. Separating network into several areas helps to solve this issue

First, let’s remove subnet announce from R4:

router ospf 1 no network 172.16.1.1 0.0.0.0 area 0 no network 172.16.1.65 0.0.0.0 area 0 no network 172.16.1.129 0.0.0.0 area 0 no network 172.16.1.193 0.0.0.0 area 0

Then add subnets from area 1:

router ospf 1 network 172.16.1.1 0.0.0.0 area 1 network 172.16.1.65 0.0.0.0 area 1 network 172.16.1.129 0.0.0.0 area 1 network 172.16.1.193 0.0.0.0 area 1

After that announce range for the area:

R4 ( config-router ) #area 1 range 172.16.1.0 255.255.255.0

Now only one route appears on routers with area 0:

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 ... O IA 172.16.1.0 / 24 [ 110 / 21 ] via 10.5.0.6, 00:00: 30 , FastEthernet0 / 1 [ 110 / 21 ] via 10.5.0.2, 00:00: 30 , FastEthernet0 / 0 ...