How to configure OSPF for CCNA students

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 651 Lessons. More Lessons Added Every Week!
  • Content created by Rene Molenaar (CCIE #41726)

567 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. Jason, you are exactly right. Suppose your ASBR is 10.0.0.1, and it has a default route in its RIB (it doesn’t matter whether that route came from EIGRP, or is a static route). From the ASBR, under your OSPF process, you would issue
    (config-router)#default-information originate

    Now, if you went to another OSPF router in the same area as the ASBR, you would see the following in its routing table:

    Gateway of last resort is 10.0.0.1 to network 0.0.0.0
    
    O*E2  0.0.0.0/0 [110/1] via 10.0.0.1, 00:00:01, FastEthernet0/0
    

    So the ASBR is advertising an External Type-2

    ... Continue reading in our forum

  2. Hi rene
    I did " clear ip ospf process " after adding loopback ip .But my router ID did not change

    R1#clear ip ospf process
    Reset ALL OSPF processes? [no]: yes
    R1#
    R1#show ip protocols
    *** IP Routing is NSF aware ***
    
    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
      Number of areas in this router is 1. 1 normal 0 stub 0 nssa
      Maximum path: 4
      Routing for Networks:
        192.168.23.0 0.0.0.255 area 0
      Routing Information Sources:
        Ga
    ... Continue reading in our forum

  3. Sims,
    When you add a loopback, OSPF won’t automatically change the router-id even if you clear the process. Since you have already created the OSPF instance, you will have to issue the command
    (config-router)#router-id <A.B.C.D>
    Where A.B.C.D is what you want the ID to become, and after that, clear the OSPF process.

    The other much more difficult option would be (once you already have your loopback created) to remove OSPF and add it back, via:

    (config)#no router ospf 1
    (config)#router ospf 1
    

    But you would have to re-enter your configuration parameters doing it

    ... Continue reading in our forum

  4. Hi Rene,
    i am trying to doing your LAB one by one…
    Based on below mention topic when i am trying to change router id automatically based on highest ip address on interface why its not changing after clear ip ospf process

    R2#sh version
    Cisco IOS Software, 7200 Software (C7200P-SPSERVICESK9-M), Version 12.4(15)T9, RELEASE SOFTWARE (fc5)
    Technical Support: http://www.cisco.com/techsupport
    Copyright (c) 1986-2009 by Cisco Systems, Inc.
    Compiled Tue 28-Apr-09 20:04 by prod_rel_team
    
    ROM: System Bootstrap, Version 12.4(12.2r)T, RELEASE SOFTWARE (fc1)
    BOOTLDR: Cisco 
    ... Continue reading in our forum

  5. Hello Arindom

    Indeed with the config as you have it set up, the router ID should become 2.2.2.2 since it is the highest loopback ID. However, 192.168.23.2 does remain the router ID even after the clear ip ospf process command.

    The only thing i can think of is that you have the router ID explicitly configured in the OSPF process as 192.168.23.2 and this is why it is not changing. Please confirm that you have no configured router ID in the OSPF configuration.

    If all else fails, try rebooting the device. Let us know your results.

    I hope this has been helpful!

    Laz

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