Configuring OSPF 1
OSPF basic configuration is very simple. Just like with other routing protocols covered so far (RIP, EIGRP) first you need to enable OSPF on a router. This is done by using the router ospf PROCESS-ID global configuration command. Next, you need to define on which interfaces OSPF will run and what networks will be advertised. This is done by using the network IP_ADDRESS WILDCARD_MASK AREA_ID command from the ospf configuration mode.
Let’s get started with some basic OSPF configuration. We will use the following network topology:
First, we need to enable OSPF on both routers. Then we need to define what network will be advertised into OSPF. This can be done by using the following sequence of commands on both routers:
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:
To verify if the routing updated 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:
You can see that R1 has learned about the network 192.168.0.0/24 through OSPF.
Configuring OSPF 2
Although basic OSPF configuration can be very simple, OSPF provides many extra features that can get really complex. In this example, we will configure multiarea OSPF network and some other OSPF features.
Consider the following multiarea OSPF network:
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 the 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. To do that, the following configuration on R1 will be used:
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 the area 1.
What about R2? Well, because R2 is an ABR, we need to establish neighbor relationship with both R1 and R3. To do that, we need to specify different area ID for each neighbor relationship, 0 for R1 and 1 for R2. We can do that using the following sequence of commands:
Now R2 should have neighbor relationship with both R1 and R3. We can verify that by using the show ip ospf neighbor command:
To verify if directly connected subnets are really advertised into the different area, we can use the show ip route ospf command on both R1 and R3:
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: