With this article, we will look at the basic commands used within Cisco IOS to configure OSPF.
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 10.0.0.3 will have OSPF enabled, and the IP advertised into OSPF and the LSDB.
R1# show run | sec ospf router ospf 1 router-id 18.104.22.168 network 10.0.0.3 0.0.0.0 area 0
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
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 10.0.128.6/30, Area 0, Attached via Network Statement Process ID 1, Router ID 22.214.171.124, 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) 126.96.36.199, Interface address 10.0.128.6 No backup designated router on this network Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
The priority determines which routers are selected as the designated router (DR) and backup designated router (BDR) of the area.  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. 
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 188.8.131.52, Network Type BROADCAST, Cost: 1 Topology-MTID Cost Disabled Shutdown Topology Name Process ID 1, Router ID 184.108.40.206, Network Type BROADCAST, Cost: 1 Topology-MTID Cost Disabled Shutdown Topology Name
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.  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 ... summary-address 10.0.0.0 255.255.0.0
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 10.1.1.0 255.255.255.0
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 220.127.116.11 255.255.255.255
router ospf 1
network 18.104.22.168 0.0.0.0 area 0
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.
 “interfaces <interface> <interface-name> ip ospf priority … – Brocade.” http://www.brocade.com/content/html/en/vrouter5600/35r6/vrouter-35r6-ospf/GUID-0D44C556-C65B-436D-BE28-0ABC4F588E66.html . Accessed 17 Feb. 2018.
 “How to configure OSPF cost – Cisco Support Community.” 22 Jun. 2009, https://supportforums.cisco.com/t5/network-infrastructure-documents/how-to-configure-ospf-cost/ta-p/3133153 . Accessed 18 Feb. 2018.
 “OSPF summarization – Study CCNA.” http://study-ccna.com/ospf-summarization/ . Accessed 18 Feb. 2018.
- How to Configure a BIND Server on Ubuntu - March 15, 2018
- What is a BGP Confederation? - March 6, 2018
- Cisco – What is BGP ORF (Outbound Route Filtering)? - March 5, 2018
Want to become a networking expert?
Here is our hand-picked selection of the best courses you can find online:
Cisco CCNA 200-301 Certification Gold Bootcamp
Complete Cyber Security Course – Network Security
Internet Security Deep Dive course
Python Pro Bootcamp
and our recommended certification practice exams:
AlphaPrep Practice Tests - Free Trial