Cisco IOS - How to Configure OSPF



With this article, we will look at the basic commands used within Cisco IOS to configure OSPF.

Basic Configuration

To initially configure OSPF, at a minimum, you must configure three things - process ID, router ID, and the network.

  • Process ID - Defines the OSPF process ID that OSPF will run under. This is typically set to 1 on all devices.
  • Router ID - The router ID is a unique number that identifies the router. It is used as a tie breaker to a route if all other metrics are the same between 2 routers to a destination.
  • Network - Allows you to define a network based on a wildcard mask. Any interface with an IP within the specified network will have OSPF enabled and the IP will be advertised into OSPF.

Below shows you an example. The key thing to note here is the network command specifies that any interface with an IP of will have OSPF enabled, and the IP advertised into OSPF and the LSDB.

R1# show run | sec ospf
router ospf 1
 network area 0

Passive interface

To explicitly disable an interface from OSPF, the following command can be used,

router ospf 1
passive-interface gi0/1

However, the recommended way (by Cisco) is to disable OSPF on all interfaces first and then to only enable OSPF on the required interfaces. Like so,

router ospf 1
passive-interface default
no passive-interface gi0/1

HELLO Intervals

The HELLO interval setting (default 10 seconds for broadcast network types) is changed on a per-interface basis.

interface gi0/1
ip ospf hello interval 1

To determine the current HELLO interval timer settings, the command show ip ospf interface can be used.

R1# show ip ospf interface 
GigabitEthernet0/1 is up, line protocol is up 
  Internet Address, Area 0, Attached via Network Statement
  Process ID 1, Router ID, Network Type BROADCAST, Cost: 1
  Topology-MTID    Cost    Disabled    Shutdown      Topology Name
        0           1         no          no            Base
  Transmit Delay is 1 sec, State DR, Priority 2
  Designated Router (ID), Interface address
  No backup designated router on this network
  Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5

DR Election

The priority determines which routers are selected as the designated router (DR) and backup designated router (BDR) of the area. [1] The router with the highest wins the election.

The configuration to change the priority is configured on a per-interface basis. Like so:


interface gi0/1
  ip ospf priority 0


interface gi0/1
  ip ospf priority 1


OSPF uses a reference bandwidth of 100 Mbps (10^8) for cost calculation. The formula to calculate the cost is reference bandwidth divided by interface bandwidth ; Interface Cost= 10^8/(interface bandwidth). Calculated values are rounded up to the nearest single decimal value. This means that OSPF will calculate interfaces with speeds higher than 10 Mbps as a cost of 1 (Table 1). T he result of this is that OSPF routers in the network cannot make an accurate path calculation when comparing fast Ethernet interface versus a gigabit Ethernet interface as both interfaces has a cost of 1. [2]

Interface TypeCost
100 Gbps 1
40 Gbps 1
10 Gbps 1
10 Gbps 1
1 Gbps 1
100 Mbps 1
10 Mbps 10
1.544 Mbps 64
768 Kbps 133
384 Kbps 266
128 Kbps 781

Table 1 - Default OSPF cost calculations.

There are two methods for changing the calculated costs - auto-cost and interface cost.

The auto-cost reference-bandwidth command allows you to change the reference bandwidth that OSPF uses to calculate its metrics:

router ospf 1
  auto-cost reference-bandwidth 1000000

REMEMBER You must ensure the reference bandwidth is consistent across all routers.

ip ospf cost can also be used to change the OSPF cost. However, this works on a per-interface basis and will override the calculated cost.

int gi0/1
ip ospf cost 1234

To verify the interface cost, the following command is used:

show ip ospf interface | inc Cost
  Process ID 1, Router ID, Network Type BROADCAST, Cost: 1
  Topology-MTID    Cost    Disabled    Shutdown      Topology Name
  Process ID 1, Router ID, Network Type BROADCAST, Cost: 1
  Topology-MTID    Cost    Disabled    Shutdown      Topology Name

Summary routes

OSPF, unlike EIGRP, doesn’t support automatic summarization. Also, unlike EIGRP, where you can summarize routes on every router in an EIGRP network, OSFP can summarize routes only on ABRs and ASBRs. [3] Route summarization both decreases the amount of OSPF traffic and also reduce the computation cycles required for SPF calculations.

OSPF provides two types of route summarization - Inter-Area Summarization and External Summarization.

Inter-Area Summarization is performed on the Area Border Router (ABR) only. Routes are summarized from one OSPF area to another.

router ospf 1

External Summarization can only be done on the ASBR (Autonomous System Boundary Router). Routes are summarized to an external destinations.

router ospf 1
area 0 range

Default route

OSPF, by default doe not generate a default route into the OSPF domain. In order for OSPF to generate a default route, the default-information originate command is used.

router ospf 1
default-information originate


A good practice to help with OSPF administration and troubleshooting is to also configure the loopback on the device, inline with its configured router id, so that it is pingable. Like so:

interface Loopback1
ip address

router ospf 1
network area 0

Verification Commands

Below are some of the key commands you can use to verify and troubleshoot your OSPF configuration. 

show ip protocols Show detailed information about the OSPF process.
show ip ospf neighbors Show details about OSPF neighbors.
show ip ospf interface Show detailed OSPF information about OSPF interfaces.
debug ip ospf adj Debug the OSPF adjacency process.

Table 2 - Verification commands.


[1] "interfaces <interface> <interface-name> ip ospf priority ... - Brocade." . Accessed 17 Feb. 2018.
[2] "How to configure OSPF cost - Cisco Support Community." 22 Jun. 2009, . Accessed 18 Feb. 2018.
[3] "OSPF summarization - Study CCNA." . Accessed 18 Feb. 2018.

About the Author


R Donato

Rick Donato is the Founder and Chief Editor of He currently works as an SDN/NFV Solutions Architect and has a keen interest in automation and the cloud.

You can find Rick on Twitter @f3lix001