Configuring OSPF

After identifying the OSPF process, you need to identify the interfaces that you want to activate OSPF communications on as well as the area in which each resides. This will also configure the networks you’re going to advertise to others. OSPF uses wildcards in the configuration. Also, when you configuring an OSPF routing, you need to define ID number of the process which is irrelevant. It can be the same on every router on the network, or it can be different-doesn’t matter. It’s locally significant and just enables the OSPF routing on the router. The value of the Process ID must be in the range of 1 – 65 535. The areas can be any number from 0 to 4 294 967 295.

OSPF configuration use wildcards instead of network masks. The calculation of the wildcards is easy. The only thing that you need to remember is that they’re always one less than the block size. A /25 is a block size of 128, so we’d add our network statement using the subnet number and then add a wildcard of 127; /28 is a block size of 16, so the wildcard in the end will be 15. For the /30, which is a block size of 4, we’d use a wildcard of 3, etc.

Let’s use our known figure as an example and configure that network with OSPF using wildcards to make sure you have a solid grip on this. Thw following figure shows a four-router network with the IP addresses of each interface. I use this example in the EIGRP configuration and because of the AD (Administrative Distance) I need to stop the EIGRP process.

OSPF with backup route

The configuration for each router must be something like the following code:

R1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#no router eigrp 10
R1(config)#
R1(config)#router ospf ?
<1-65535>  Process ID

R1(config)#router ospf 123
R1(config-router)#
R1(config-router)#net 10.10.1.0 0.0.0.255 ?
area  Set the OSPF area ID

R1(config-router)#net 10.10.1.0 0.0.0.255 area ?
<0-4294967295> OSPF area ID as a decimal value
A.B.C.D       OSPF area ID in IP address format

R1(config-router)#net 10.10.1.0 0.0.0.255 area 0
R1(config-router)#net 10.10.4.0 0.0.0.255 area 0
R1(config-router)#
R1(config-router)#end
R1#

The routing table in router R3 is the following:

R3#sh 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, 5 subnets
O       10.10.1.0 [110/2] via 10.10.4.1, 00:01:26, FastEthernet0/1
O       10.10.2.0 [110/1564] via 10.10.4.1, 00:01:26, FastEthernet0/1
C       10.10.3.0 is directly connected, Serial1/0
C       10.10.4.0 is directly connected, FastEthernet0/1
O       10.10.10.0 [110/65] via 10.10.3.1, 00:01:26, Serial1/0
R3#

Again, as in the EIGRP here we have the routing to the 10.10.1.0/24 network directly through R1 router. Look at the metric of the route to 10.10.1.0/24. Because it is connected through two Fast Ethernet links, each of them has metric of 1. If I shut down the interface FE0/1 on router R3, which is the direct connection to rouer R1, then we will have the following routing table:

R3(config-if)#do sh 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, 5 subnets
O       10.10.1.0 [110/1627] via 10.10.3.1, 00:00:08, Serial1/0
O       10.10.2.0 [110/1626] via 10.10.3.1, 00:00:08, Serial1/0
C       10.10.3.0 is directly connected, Serial1/0
C       10.10.4.0 is directly connected, FastEthernet0/1
O       10.10.10.0 [110/65] via 10.10.3.1, 00:00:08, Serial1/0
R3(config-if)#

As you see, we have our rebuilded routing table with 10.10.3.1 as a next hop for all networks. The metric now is worse but it is a backup, so it is better then nothing, right?

Hint: When you are in global configuration mode you can execute commands which can be executed only in privileged mode, with adding do command in front of them as it is shown in the example above.

Our Recommended Premium CCNA Training Resources

These are the best CCNA training resources online:

Click Here to get the Cisco CCNA Gold Bootcamp, the most comprehensive and highest rated CCNA course online with a 4.8 star rating from over 30,000 public reviews. I recommend this as your primary study source to learn all the topics on the exam. Cisco CCNA Gold Bootcamp
And click here for a free trial of AlphaPrep premium practice tests when youre ready to test your knowledge. They have the largest question bank, with adaptive tests and advanced reporting which tells you exactly when you are ready to pass the real exam. Cisco CCNA Gold Bootcamp