Basic OSPF Configuration

ospf cost per interface

CCNA students need to understand how OSPF works but also how to configure it. If you have no idea what OSPF is or if you are a little fuzzy, I recommend you to read my Introduction to OSPF first before continuing. Having said that, let’s configure OSPF! This is the topology I will use:

ospf lab single area

This is the topology that we’ll use. All routers are in OSPF Area 0. Note that the link between R2 and R1 is an Ethernet (10Mbit) link. All other links are FastEthernet (100Mbit) interfaces.

We’ll start with the configuration between R2 and R3:

R2(config)#router ospf 1
R2(config-router)#network 192.168.23.0 0.0.0.255 area 0
R3(config)#router ospf 1
R3(config-router)#network 192.168.23.0 0.0.0.255 area 0

I need to use the router ospf command to get into the OSPF configuration. The number “1” is a process ID and you can choose any number you like. It doesn’t matter and if you want you can use a different number on each router.

The second step is to use the network command. It works similar to RIP but it is slightly different, let me break it down for you:

network 192.168.23.0 0.0.0.255

Just like RIP the network command does two things:

  • Advertise the networks that fall within this range in OSPF.
  • Activate OSPF on the interface(s) that fall within this range. This means that OSPF will send hello packets on the interface.

Behind 192.168.23.0 you can see it says 0.0.0.255. This is not a subnet mask but a wildcard mask. A wildcard mask is a reverse subnet mask. Let me give you an example:

Subnetmask

255

255

255

0

11111111

11111111

11111111

00000000

Wildcardmask

0

0

0

255

00000000

00000000

00000000

11111111

When I say reverse subnet mask I mean that the binary 1s and 0s of the wildcard mask are flipped compared to the subnet mask. A subnet mask of 255.255.255.0 is the same as wildcard mask 0.0.0.255. Don’t worry about this too much for now as I’ll explain wildcard masks to you when we talk about access-lists!

OSPF uses areas so you need to specify the area:

area 0

In our example we have configured single area OSPF. All routers belong to area 0.

After typing in my network command you’ll see this message in the console:

R3# %OSPF-5-ADJCHG: Process 1, Nbr 192.168.23.2 on FastEthernet0/0 from LOADING to FULL, Loading Done
R2# %OSPF-5-ADJCHG: Process 1, Nbr 192.168.23.3 on FastEthernet1/0 from LOADING to FULL, Loading Done

Great! It seems that R3 and R2 have become neighbors. There’s another command we can use to verify that we have become neighbors:

R3#show ip ospf neighbor

Neighbor ID Pri State Dead Time Address Interface
192.168.23.2 1 FULL/BDR 00:00:36 192.168.23.2 FastEthernet0/0
R2#show ip ospf neighbor

Neighbor ID Pri State Dead Time Address Interface
192.168.23.3 1 FULL/DR 00:00:32 192.168.23.3 FastEthernet1/0

Show ip ospf neighbor is a great command to see if your router has OSPF neighbors. When the state is full you know that the routers have successfully become neighbors.

Each OSPF router has a router ID and we check it with the show ip protocols command:

R2#show ip protocols
Routing Protocol is "ospf 1"
Outgoing update filter list for all interfaces is not set
Incoming update filter list for all interfaces is not set
Router ID 192.168.23.2
R3#show ip protocols
Routing Protocol is "ospf 1"
Outgoing update filter list for all interfaces is not set
Incoming update filter list for all interfaces is not set
Router ID 192.168.23.3

Above you see the router ID of R2 and R3. They used their highest active IP address as the router ID. Let’s create a loopback on R2 to see if the router ID changes…

R2(config)#interface loopback 0
R2(config-if)#ip address 2.2.2.2 255.255.255.0

This is how you create a loopback interface. You can pick any number that you like it really doesn’t matter.

R2#show ip protocols
Routing Protocol is "ospf 1"
Outgoing update filter list for all interfaces is not set
Incoming update filter list for all interfaces is not set
Router ID 192.168.23.2

The router ID still the same. We need to reset the OSPF process before the change will take effect, this is how you do it:

R2#clear ip ospf process
Reset ALL OSPF processes? [no]: yes

Use clear ip ospf process to reset OSPF. Let’s see if there is a difference:

R2#show ip protocols
Routing Protocol is "ospf 1"
Outgoing update filter list for all interfaces is not set
Incoming update filter list for all interfaces is not set
Router ID 2.2.2.2

We can also change the router ID manually. Let me demonstrate this on R3:

R3#show ip protocols
Routing Protocol is "ospf 1"
Outgoing update filter list for all interfaces is not set
Incoming update filter list for all interfaces is not set
Router ID 192.168.23.3

Right now it’s 192.168.23.3…

R3(config-router)#router-id 3.3.3.3
Reload or use "clear ip ospf process" command, for this to take effect
R3#clear ip ospf process
Reset ALL OSPF processes? [no]: yes

The router is friendly enough to warn me to reload or clear the OSPF process. Let’s verify our configuration:

R3#show ip protocols
Routing Protocol is "ospf 1"
Outgoing update filter list for all interfaces is not set
Incoming update filter list for all interfaces is not set
Router ID 3.3.3.3

As you can see above the router ID is now 3.3.3.3.

Changing the router ID isn’t something you would normally do. IP addresses on your router have to be unique so your OSPF router ID will also be unique. Understanding how OSPF selects a router ID is something you have to understand for the exam however.

Right now we have an OSPF neighbor adjacency between R2 and R3. Let’s configure our routers so that R2/R1 and R1/R3 also become OSPF neighbors:

R2(config)#router ospf 1
R2(config-router)#network 192.168.12.0 0.0.0.255 area 0
R1(config)#router ospf 1
R1(config-router)#network 192.168.12.0 0.0.0.255 area 0
R1(config-router)#network 192.168.13.0 0.0.0.255 area 0
R3(config)#router ospf 1
R3(config-router)#network 192.168.13.0 0.0.0.255 area 0

I’ll advertise all networks in OSPF. Before we check the routing table it’s a good idea to see if our routers have become OSPF neighbors:

R2#show ip ospf neighbor 

Neighbor ID   Pri   State     Dead Time   Address       Interface
192.168.13.1    1   FULL/BDR  00:00:31    192.168.12.1  Ethernet0/0
3.3.3.3         1   FULL/DR   00:00:38    192.168.23.3  FastEthernet1/0
R1#show ip ospf neighbor 

Neighbor ID   Pri   State     Dead Time   Address       Interface
3.3.3.3         1   FULL/BDR  00:00:33    192.168.13.3  FastEthernet1/0
2.2.2.2         1   FULL/DR   00:00:30    192.168.12.2  Ethernet0/0
R3#show ip ospf neighbor 

Neighbor ID   Pri   State     Dead Time   Address         Interface
192.168.13.1    1   FULL/DR   00:00:37    192.168.13.1    FastEthernet1/0
2.2.2.2         1   FULL/BDR  00:00:30    192.168.23.2    FastEthernet0/0

Excellent our routers have become OSPF neighbors and the state is full which means they are done exchanging information. Let’s check the routing tables:

R2#show ip route ospf 
O    192.168.13.0/24 [110/2] via 192.168.23.3, 00:09:45, FastEthernet1/0

R2 has one entry, it’s for network 192.168.13.0 /24. What exactly do we see here?

We're Sorry, Full Content Access is for Members Only...

If you like to keep on reading, Become a Member Now! Here is why:

  • Learn any CCNA, CCNP and CCIE R&S Topic. Explained As Simple As Possible.
  • Try for Just $1. The Best Dollar You’ve Ever Spent on Your Cisco Career!
  • Full Access to our 799 Lessons. More Lessons Added Every Week!
  • Content created by Rene Molenaar (CCIE #41726)

572 Sign Ups in the last 30 days

satisfaction-guaranteed
100% Satisfaction Guaranteed!
You may cancel your monthly membership at any time.
No Questions Asked!

Forum Replies

  1. Thank you very much Rene for your work. I appreciate much :wink:

  2. Very good lesson! Thanks for all your work!

  3. Very good lesson! Thanks for all your work!

  4. Hi Rene,
    When connecting 3 routers(a router triangle) to configure OSPF, will it make a difference if I created point-to-point serial connections as opposed to using the ethernet ports?
    Thanks
    Mo

  5. Hi Mo,

    There will be two differences:

    - The cost will be higher (that’s no problem) because the link is slower.
    - OSPF treats point-to-point links differently than multi-access links (Ethernet). One of the things is that it doesn’t elect a DR/BDR on point-to-point links.

    Rene

101 more replies! Ask a question or join the discussion by visiting our Community Forum