Configuring Single Area OSPF
OSPF’s basic configuration is very simple. Like with other routing protocols (RIP, EIGRP), you must first enable OSPF on a router using the router ospf PROCESS-ID global configuration command. Next, you need to define which interfaces OSPF will run and what networks will be advertised using the network IP_ADDRESS WILDCARD_MASK AREA_ID command from the OSPF configuration mode.
Let’s get started with some basic OSPF routing protocol configuration. We will use the following network topology:
Assume that the IP addresses and the basic configurations are already configured on the devices. To configure OSPF, we need to enable OSPF on both routers first. Then we need to define what network will be advertised in OSPF using the following sequence of commands on both routers:
R1(config-router)#router ospf 1 R1(config-router)#network 10.0.1.0 0.0.0.255 area 0 R1(config-router)#network 172.16.0.0 0.0.255.255 area 0 R2(config-router)#router ospf 1 R2(config-router)#network 192.168.0.0 0.0.0.255 area 0 R2(config-router)#network 172.16.0.0 0.0.255.255 area 0
The network commands entered on both routers include subnets directly connected to both routers. We can verify that the routers have become neighbors by typing the show ip ospf neighbors command on either router:
R1#show ip ospf neighbor Neighbor ID Pri State Date Time Address Interface 192.168.0.2 1 FULL/BDR 00:00:32 172.16.0.2 FastEthernet0/1
To verify if the routing updates were exchanged, we can use the show ip route command. All routes marked with the character O are OSPF routes. For example, here is the output of the command on R1:
R1#show ip route Codes: L - local, 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, E - EGP i - IS-IS, 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.0.1.0 is directly connected, FastEthernet0/0 C 172.16.0.0/16 is directly connected, FastEthernet0/1 O 192.168.0.0/24 [110/2] via 172.16.0.2, 00:03:44, FastEthernet0/1
You can see in the routing table that R1 has learned about the network 192.168.0.0/24 through OSPF.
Configuring Multiarea OSPF
Although basic OSPF configuration can be straightforward, OSPF provides many extra features that can get really complex. In this example, we will configure a multiarea OSPF network and some other OSPF features.
Consider the following multiarea OSPF network. Assume that the IP address and the basic configurations are already configured on each device.
In this example, we have two OSPF areas – area 0 and area 1. As you can see from the network topology depicted above, routers R1 and R3 are in area 0 and area 1, respectively. Router 2 connects to both areas, which makes him an ABR (Area Border Router). Our goal is to advertise the subnets directly connected to R1 and R3 by entering the following configurations on R1:
R1(config-router)#router ospf 1 R1(config-router)#network 10.0.1.0 0.0.0.255 area 0 R1(config-router)#network 172.16.0.0 0.0.255.255 area 0 R1(config-router)#router-id 22.214.171.124
Because R1 connects only to R2, we only need to establish a neighbor relationship with R2 and advertise directly connected subnet into OSPF.
Configuration of R3 looks similar, but with one difference, namely area number. R3 is in area 1.
R3(config-router)#router ospf 1 R3(config-router)#network 192.168.0.0 0.0.0.255 area 1 R3(config-router)#network 126.96.36.199 0.0.0.255 area 1 R3(config-router)#router-id 188.8.131.52
What about R2? Because R2 is an ABR, we need to establish neighbor relationships with R1 and R3. To do that, we need to specify different area IDs for each neighbor relationship, 0 for R1 and 1 for R2. We can do that using the following sequence of commands:
R2(config-router)#router ospf 1 R2(config-router)#network 172.16.0.0 0.0.0.255 area 0 R2(config-router)#network 192.168.0.0 0.0.0.255 area 1 R2(config-router)#router-id 184.108.40.206
Now R2 should have a neighbor relationship with both R1 and R3. We can verify that by using the show ip ospf neighbor command:
R2#show ip ospf neighbor Neighbor ID Pri State Date Time Address Interface 220.127.116.11 1 FULL/BDR 00:00:39 172.16.0.1 FastEthernet0/0 18.104.22.168 1 FULL/DR 00:00:36 192.168.0.2 FastEthernet0/1
To verify if directly connected subnets are really advertised into the different areas, we can use the show ip route ospf command on both R1 and R3:
R1#show ip route ospf 22.214.171.124/24 is subnetted, 1 subnets O IA 126.96.36.199 [110/3] via 172.16.0.2, 00:12:48, FastEthernet0/1 O IA 192.168.0.0 [110/2] via 172.16.0.2, 00:12:48, FastEthernet0/1
R3#show ip route ospf 10.0.0.0/24 is subnetted, 1 subnets O IA 10.0.1.0 [110/3] via 192.168.0.1, 00:13:47, FastEthernet0/0 O IA 188.8.131.52 [110/2] via 192.168.0.1, 00:13:47, FastEthernet0/0
Characters IA in front of the routes indicates that these routes reside in different areas.
Download our Free CCNA Study Guide PDF for complete notes on all the CCNA 200-301 exam topics in one book.
We recommend the Cisco CCNA Gold Bootcamp as your main CCNA training course. It’s the highest rated Cisco course online with an average rating of 4.8 from over 30,000 public reviews and is the gold standard in CCNA training: