VMware ESXi and vSphere Cluster Management

Configure Basic OSPF for CCNA

Learn to configure and verify single-area OSPF on Cisco routers using router ospf, network statements, wildcard masks, area 0, and IOS verification commands.

Open Shortest Path First (OSPF) is a link-state interior gateway protocol (IGP). It allows routers within the same organization or autonomous system to exchange IPv4 routing information dynamically.

This lesson shows how to configure basic, single-area OSPF on two Cisco routers. You will create an OSPF process, match interfaces with network statements, place those interfaces in area 0, verify the neighbor adjacency, and confirm that remote LAN routes were learned.

What OSPF does

OSPF routers form neighbor relationships with compatible OSPF routers on a shared network segment. After discovering neighbors, they form adjacencies and exchange topology information. Each router builds a link-state database and uses that information to calculate the best routes before installing selected routes in its routing table.

A link-state advertisement (LSA) is information distributed by OSPF to describe router links, networks, and reachability. Routers use received and originated LSAs to build the link-state database. The database represents the OSPF topology; the resulting best paths become routes in the IPv4 routing table.

OSPF is different from a protocol that simply sends a list of routes to its neighbors. OSPF first develops a shared view of the topology through neighbor communication and LSA exchange, then calculates paths locally.

Two fundamental OSPF configuration tasks

  1. Create an OSPF routing process. This starts an OSPF process on the router.
  2. Identify participating interfaces and networks. OSPF network statements match interface IP addresses, activate OSPF on matching interfaces, and associate those interfaces with an area.

From privileged EXEC mode, the basic IOS command flow is:

Router> enable
Router# configure terminal
Router(config)# router ospf 1
Router(config-router)#

The prompt changes to (config-router) after the router ospf command. Network statements are entered in this OSPF router configuration mode.

OSPF process ID

The command router ospf process-id creates or enters an OSPF routing process. For example:

Router(config)# router ospf 1

The OSPF process ID is a locally significant IOS identifier. It identifies the OSPF process on that router; it is not an identifier exchanged as a neighbor requirement.

Neighboring routers do not need matching process IDs. R1 can use process 1 while R2 uses process 10, and they can still become OSPF neighbors if the shared interfaces have compatible OSPF settings, including the same area ID.

OSPF areas and area 0

An OSPF area is a logical grouping of routers and links within an OSPF domain. Areas help organize topology information and limit the scope of some OSPF updates.

Area 0 is the OSPF backbone area. A basic single-area lab commonly places every participating interface in area 0. Routers connected on the same OSPF link must use the same area ID on that link to form a neighbor relationship.

SettingNeighboring routers must match?Explanation
OSPF process IDNoIt is a locally significant identifier on each router.
Area ID on the shared interfaceYesThe two ends of the OSPF link must belong to the same area for neighbor formation.

Two-router single-area lab topology

The example uses two routers, one transit connection, and one LAN behind each router. All OSPF interfaces belong to area 0.

DeviceInterface or LANIPv4 address/subnetOSPF areaPurpose
R1LAN interface10.0.0.1/240Default gateway for the R1 LAN
R1Transit interface172.16.0.1/300Connection to R2
R2Transit interface172.16.0.2/300Connection to R1
R2LAN interface192.168.0.1/240Default gateway for the R2 LAN

The hosts on the LANs use their router's LAN interface as a default gateway. The exact interface names depend on the router platform, so the configuration below focuses on OSPF. The interfaces must already have the listed IPv4 addresses and must be operational.

Wildcard masks

A wildcard mask is the inverse of a subnet mask. Cisco IOS uses it in commands such as OSPF network statements to determine which address bits must match and which bits may vary.

To calculate a wildcard mask, subtract each subnet-mask octet from 255:

Wildcard octet = 255 - subnet-mask octet
Prefix lengthSubnet maskWildcard maskTypical use
/24255.255.255.00.0.0.255LAN
/30255.255.255.2520.0.0.3Point-to-point transit link

For a /24, the wildcard 0.0.0.255 allows the final octet to vary. For a /30, the wildcard 0.0.0.3 allows the final two bits of the final octet to vary.

The address in a network statement is a matching pattern; it does not have to be the exact IP address assigned to an interface. For example, this statement matches interface addresses in the 10.0.0.0/24 range:

network 10.0.0.0 0.0.0.255 area 0

It matches an interface at 10.0.0.1 because that address is within the matched range. The statement does not configure 10.0.0.0 on the interface. It matches an existing interface address and then activates OSPF on that interface.

The OSPF network statement

The command format is:

network ip-address wildcard-mask area area-id

When an interface IP address matches the address and wildcard mask, IOS enables OSPF on that interface. OSPF then advertises the connected network associated with the interface into the specified area.

Include each directly connected subnet that should participate in the OSPF domain. In this lab, each router advertises both its local LAN and the transit subnet.

Configure R1

R1 has process ID 1. Its LAN is 10.0.0.0/24, and its transit network is 172.16.0.0/30. Enter these commands from privileged EXEC mode:

R1> enable
R1# configure terminal
R1(config)# router ospf 1
R1(config-router)# network 10.0.0.0 0.0.0.255 area 0
R1(config-router)# network 172.16.0.0 0.0.0.3 area 0
R1(config-router)# end

The first statement activates OSPF on R1's LAN interface and advertises 10.0.0.0/24. The second activates OSPF on the R1-R2 transit interface and advertises 172.16.0.0/30.

Configure R2

R2 uses process ID 10 to demonstrate that process IDs do not need to match. Its transit network is 172.16.0.0/30, and its LAN is 192.168.0.0/24.

R2> enable
R2# configure terminal
R2(config)# router ospf 10
R2(config-router)# network 172.16.0.0 0.0.0.3 area 0
R2(config-router)# network 192.168.0.0 0.0.0.255 area 0
R2(config-router)# end

R2 now activates OSPF on both its transit and LAN interfaces. Because the transit interfaces are in the same IP subnet and both use area 0, the routers can form an adjacency.

What happens after configuration

  1. Each router identifies interfaces matched by its OSPF network statements.
  2. OSPF begins sending and receiving OSPF messages on those interfaces.
  3. R1 and R2 discover one another as OSPF neighbors on the transit link.
  4. The neighbors form an adjacency and synchronize topology information.
  5. They exchange LSAs describing their links and reachable networks.
  6. Each router builds or updates its link-state database and calculates routes.
  7. R1 installs a route to 192.168.0.0/24, and R2 installs a route to 10.0.0.0/24.

Verify the OSPF neighbor adjacency

Use the following command in privileged EXEC mode:

R1# show ip ospf neighbor

In a basic point-to-point or Ethernet lab, the expected neighbor state is usually FULL. FULL means the OSPF routers have established their adjacency and synchronized their relevant topology information.

R1# show ip ospf neighbor

Neighbor ID     Pri   State           Dead Time   Address         Interface
2.2.2.2           1   FULL/ -         00:00:35    172.16.0.2      GigabitEthernet0/1

The exact neighbor ID, interface name, priority, and timers vary by platform and configuration. The important evidence is that the expected neighbor is listed and the state reaches FULL.

Verify OSPF-learned routes

Use:

R1# show ip route ospf

Cisco IOS identifies an internal route learned through OSPF with the route code O. On R1, the remote R2 LAN should appear as an OSPF route:

R1# show ip route ospf

     192.168.0.0/24 is variably subnetted, 1 subnets
O       192.168.0.0 [110/2] via 172.16.0.2, 00:00:20, GigabitEthernet0/1

The exact administrative distance, metric, timer, and outgoing interface can vary. The important evidence is the O route for 192.168.0.0/24 through R2. This confirms that R1 received topology and reachability information and installed a route to the remote LAN.

CommandWhat it verifiesExpected evidence
show ip ospf neighborOSPF neighbor discovery and adjacencyThe expected router appears, normally in FULL state.
show ip route ospfRoutes learned through OSPFRemote networks appear with the Cisco route code O.

Process ID versus area ID experiment

Different process IDs

Keep R1 configured with router ospf 1 and R2 configured with router ospf 10. If the transit interfaces are both matched by network statements and both assigned to area 0, the routers can form a FULL adjacency. This demonstrates that the process ID is local.

Different area IDs

If the R1 transit interface is assigned to area 0 but the R2 transit interface is assigned to area 1, the shared-link OSPF settings are incompatible. The expected adjacency will not become operational. Correct the R2 transit statement so it also uses area 0:

R2(config)# router ospf 10
R2(config-router)# network 172.16.0.0 0.0.0.3 area 0

After the correction, check show ip ospf neighbor again and wait for the neighbor state to reach FULL.

Troubleshooting missing neighbors

If show ip ospf neighbor does not list the expected router, check the following:

  • Confirm that both transit interfaces have addresses in the same IP subnet, such as 172.16.0.1/30 and 172.16.0.2/30.
  • Confirm that the interfaces are not administratively down and that the physical and data-link connection is operational.
  • Review each OSPF network statement. The wildcard mask must match the transit interface address.
  • Confirm that both ends of the shared link use the same area ID.
  • Do not treat different process IDs as a problem by themselves.

Recalculate the wildcard mask if the OSPF command appears correct but no interface participates. A /30 transit subnet requires 0.0.0.3; a /24 LAN requires 0.0.0.255.

Troubleshooting a missing remote LAN route

An adjacency can exist while a remote LAN route is absent. In that case, inspect the remote router's LAN configuration:

  • Confirm that the remote LAN interface has the expected IP address and is operational.
  • Confirm that a network statement matches the remote LAN interface address.
  • Compare the statement's wildcard mask with the LAN prefix. For 192.168.0.0/24, use 0.0.0.255.
  • Run show ip route ospf on the receiving router and look for the remote subnet marked with O.

For example, R2 must include:

network 192.168.0.0 0.0.0.255 area 0

Without a matching statement, OSPF may still form an adjacency over the transit link, but R2 will not advertise its LAN through OSPF.

Summary

  • OSPF is a link-state interior gateway protocol that exchanges topology and reachability information between routers.
  • The basic workflow is to create an OSPF process and identify participating interfaces with network statements.
  • The process ID is locally significant and does not need to match on neighboring routers.
  • A network statement uses an IP address and wildcard mask to match interface addresses, activate OSPF, and place matching interfaces in an area.
  • A /24 subnet uses wildcard mask 0.0.0.255; a /30 subnet uses 0.0.0.3.
  • Area 0 is the standard backbone and the area used in this single-area lab.
  • Interfaces on the same OSPF link must use the same area ID to become neighbors.
  • show ip ospf neighbor verifies adjacency, with FULL normally expected in a basic lab.
  • show ip route ospf verifies learned routes, which IOS marks with route code O.
  • LSA exchange builds the link-state database, which OSPF uses to calculate routes.

For the related configuration reference, see Configure OSPF.