Diagram of single-area OSPFv2 topology with four Cisco routers connected via GigabitEthernet, including IP addresses, router IDs, and 'show ip protocol' command output for verification.

Configure Single-Area OSPFv2: A Comprehensive Guide

OSPFv2 is a link-state routing protocol for IPv4, initially drafted in 1991 (RFC 1247) and standardized in 1998 (RFC 2328), serving as a scalable alternative to the distance-vector Routing Information Protocol (RIP). It uses Dijkstra’s algorithm to compute shortest paths, making it ideal for large networks. Figure 1 provides a reference topology for configuring single-area OSPFv2, where routers start with interface addresses and passwords but no static or dynamic routing. This setup is perfect for CCNA students learning basics and CCNP candidates optimizing configurations.

Design 494307141 1
Configure Single-Area OSPFv2: A Comprehensive Guide 8

Router OSPF Configuration Mode and Process ID

To enable OSPFv2 on routers in the topology, use the router ospf process-id command in global configuration mode. The process-id is a locally significant number between 1 and 65,535—it doesn’t need to match on neighboring routers for adjacencies to form and has no impact on OSPF packets or LSAs. You can even use different process IDs on every router in your network. For example

R1(config)# router ospf 1

 This starts OSPF process 1.

CCNA tip: Multiple processes allow running separate OSPF instances on one router, useful in CCNP scenarios like VRFs.

OSPF Router ID

Every router in an OSPF network requires a unique router ID to participate in the domain. It can be manually configured or automatically assigned. The router ID is essential for:

  • Uniquely identifying routers within the OSPF domain and all packets originating from them.
  • Originating Link-State Advertisements (LSAs) to build the topology database.
  • Electing the Designated Router (DR) and Backup Designated Router (BDR) in multi-access networks (e.g., Ethernet LANs). If priorities are equal, the highest router ID wins.

Determining Router ID

There a three-way for Cisco routers to find the router ID as described:

  • The router ID is configured using the OSPF“router-id rid” command in router configuration mode. The value rid is any 32-bit value expressed as an IPv4 address. This is the recommended method for assigning a router ID.
  • If the router ID is not configured, the router chooses the highest IPv4 address of any configured loopback interfaces. This is the second-best method of assigning a router ID.
  • If loopback interfaces are not configured on the router, it chooses the highest active IPv4 address of any of its physical interfaces. This method is not recommended by many network administrators because it makes it very difficult for administrators to differentiate between specific routers when assigning an ID.

If the highest IPv4 address is used as the router ID, the interface is not required to be OSPF-enabled. It is not necessary to configure that interface for the OSPF protocol.

The only requirement is that the interface is active and in the upstate. The router ID is an IP address, but it is not routable, so it is not integrated into the routing table unless the OSPF routing process chooses an interface that is properly defined by a network command.

Configuring an OSPF Router ID

As I say prior that we can configure Router ID using the “router-id rid” command in routerconfiguration mode. An OSPF router identifies itself to other routers using the router ID. The rid is any 32-bit number in the form of IPv4 address.

As shown in Figure 1, Router1 has been configured with a router ID of 10.10.10.1, Router2 with 10.10.20.1, Router2 with 10.10.30.1, and R4 with 10.10.40.1. We can verify the router ID using the “show ip protocols” command.

The figure-2 illustrates the rid assignment to Router2 and figure-3 illustrates the verification of the router ID to Router2. You can see that when we enter the router ID, the router must reload to clear IP OSPF process. If the router ID is the same on two neighboring routers, the router displays an error message for duplicate router ID. To resolve this problem configure all routers with unique OSPF router IDs.

Screen Shot 2024 06 09 at 120355 AM
Configure Single-Area OSPFv2: A Comprehensive Guide 9
Screen Shot 2024 06 09 at 120414 AM
Configure Single-Area OSPFv2: A Comprehensive Guide 10

Modifying Router ID

Sometimes we need to modify the router ID. Due to a wrong configuration or network change. For example, if we want to assign a new ID to router2 in the above topology due to the new router ID scheme. So, an active OSPF router does not allow the router ID; to be changed; until the router reloaded or the OSPF process cleared.

The way to assign a new router ID to a router is the same; only it requires reloading the router to kill the OSPF active process due to active adjacencies. The adjacencies must be renegotiated and established with the new router ID.

The preferred method for changing router ID is clearing the OSPF process. The command for killing the OSPF process is “ clear ip ospf process” in privileged EXEC mode.

This command down the OSPF to Init states, displaying the adjacency change messages from full to down and then from loading to full. Now again you can verify the ID changing using “show ip protocols”. The figure-4 illustrates the clearing OSPF process.

Screen Shot 2024 06 09 at 120610 AM
Configure Single-Area OSPFv2: A Comprehensive Guide 11

Using a Loopback Interface as the Router ID

We can also use a loopback interface as a router ID. The IPv4 address of the loopback interface required configuration using the subnet mask 255.255.255.255. This is a 32-bit subnet mask that does not advertise as a route to other OSPF routers.

Configure Single-Area OSPFv2

The network command in router mode adds the interfaces in the OSPF area. Interfaces that match the network address in the network command are enabled to send and receive OSPF packets. As a result, the network (or subnet) address for the interface has been included in OSPF routing updates. The command syntax is <network network-address wildcard-mask area area-id>.

The area area-id is the OSPF area planned by the network administrator. When configuring single-area OSPF, the network command must be configured with the same area-id on all routers. Though we can use any area ID, it is good to use an area ID of 0 with a single-area OSPF. This principle changes the later network from a single area to a multi-area OSPF.

Wild Card Mask

The wildcard-mask with the network address of the interface enable OSPF. We know that OSPF is a classless protocol by design; So, the wildcard mask always required to find interfaces which participating in a routing process. So, it is the inverse of the subnet mask configured on that interface. It is a string of 32 binary digits.

The wildcard mask decides the bits of the address to check for a match. In a subnet mask, binary 1 is equal to a match and binary 0 is not a match but In a wildcard mask, the reverse is true. To calculate a wild card mask is to subtract the network subnet mask from 255.255.255.255.

For example, if we have a /24 and /25 network as shown in the figure-5 below the wildcard mask from the /24 subnet mask 0.0.0.255 and the wildcard mask from /25 network is 0.0.0.127. We simply subtract the subnet mask from 32-bit string.

Screen Shot 2024 06 09 at 120437 AM
Configure Single-Area OSPFv2: A Comprehensive Guide 12

The example in Figure 2 calculates the wildcard mask from the network address of 192.168.10.64/26. Again, the subnet mask 255.255.255.192 was subtracted from 255.255.255.255, resulting in 0.0.0.63. Therefore, 192.168.10.0/26 is 192.168.10.0 with a wildcard mask of 0.0.0.63.

The Network Command

Router1 participates in the OSPFv2 routing process for an area. The wildcard masks identify the respective interfaces based on their network addresses. Because this is a single-area OSPF network, all area IDs have been set to 0. We enable the interface into OSPFv2 using the <network intf-ip-address 0.0.0.0 area area-id> router configuration mode command.

The benefit of specifying the interface is that the wildcard mask calculation is not important. OSPFv2 uses the interface address and subnet mask to resolve the network to advertise.

Some IOS versions also allow the subnet mask instead of the wildcard mask. The IOS then converts the subnet mask automatically to the wildcard mask format. Figure 6 illustrates the configuration of networks on Router2.

Screen Shot 2024 06 09 at 120500 AM
Configure Single-Area OSPFv2: A Comprehensive Guide 13

FAQs

What is the purpose of the OSPF router ID?

The router ID uniquely identifies routers in the OSPF domain, originates LSAs for the topology database, and is used in DR/BDR elections on multi-access networks. It can be manually set or auto-assigned from loopback or physical interfaces.

How do you calculate a wildcard mask for OSPF?

Subtract the subnet mask from 255.255.255.255. For example, a /24 mask (255.255.255.0) gives 0.0.0.255; a /26 (255.255.255.192) gives 0.0.0.63. This enables classless interface participation in OSPF routing.

Why use a loopback interface for OSPF router ID?

Loopbacks provide stability as they are always up, preventing ID changes if physical interfaces fail. Configure with a /32 mask (255.255.255.255), and it won’t advertise unless included in a network command. Ideal for reliable networks.

How do you modify an existing OSPF router ID?

Use clear ip ospf process in privileged EXEC mode to apply changes without a full reload. This resets adjacencies briefly. Verify with show ip protocols. Needed for config errors or network changes.

What is the network command in OSPFv2?

It enables interfaces in an OSPF area: network network-address wildcard-mask area area-id. For single-area, use area 0 on all routers. Matches interfaces to send/receive OSPF packets and include subnets in updates.

Avatar of Asad Ijaz

Asad Ijaz

NetworkUstad's lead networking architect with CCIE certification. Specializes in CCNA exam preparation and enterprise network design. Authored 2,800+ technical guides on Cisco systems, BGP routing, and network security protocols since 2018. Picture this: I'm not just someone who writes about tech; I'm a certified expert in the field. I proudly hold the titles of Cisco Certified Network Professional (CCNP) and Cisco Certified Network Associate (CCNA). So, when I talk about networking, I'm not just whistling in the dark; I know my stuff! My website is like a treasure trove of knowledge. You'll find a plethora of articles and tutorials covering a wide range of topics related to networking and cybersecurity. It's not just a website; it's a learning hub for anyone who's eager to dive into the world of bits, bytes, and secure connections. And here's a fun fact: I'm not a lone wolf in this journey. I'm a proud member and Editor of Team NetworkUstad. Together, we're on a mission to empower people with the knowledge they need to navigate the digital landscape safely and effectively. So, if you're ready to embark on a tech-savvy adventure, stick around with me, Asad Ijaz Khattak. We're going to unravel the mysteries of technology, one article at a time!"