This guide builds a small single-area OSPFv2 network on two Cisco IOS XE routers. It configures the interfaces, advertises both LANs through area 0, verifies the neighbor relationship, and explains the most common reasons an adjacency fails.
Official references:
- Cisco IOS XE OSPF configuration guide
- Enabling OSPFv2 on an interface
- Default passive interfaces
- Troubleshoot OSPF neighbor problems
- Managing IOS XE configuration files
The commands in this article target Cisco IOS and IOS XE. Cisco IOS XR, NX-OS, and ASA use different configuration models or syntax.
Example Topology
The example uses one point-to-point transit link and one LAN on each router:
| Router | Interface | IPv4 address | Purpose |
|---|---|---|---|
| R1 | GigabitEthernet0/0/0 |
10.1.0.1/24 |
R1 LAN |
| R1 | Serial0/0/0 |
10.0.12.1/30 |
Link to R2 |
| R2 | Serial0/0/0 |
10.0.12.2/30 |
Link to R1 |
| R2 | GigabitEthernet0/0/0 |
172.16.2.1/24 |
R2 LAN |
Both routers place these interfaces in OSPF area 0. R1 uses router ID 1.1.1.1; R2 uses 2.2.2.2.
Replace the interface names with those shown by the actual router:
show ip interface brief
On a production router, review the running configuration and confirm an out-of-band recovery path before changing routing:
show running-config
show ip route
show ip protocols
Configure R1
Enter privileged EXEC mode and configure the LAN interface:
enable
configure terminal
hostname R1
interface GigabitEthernet0/0/0
description R1 LAN
ip address 10.1.0.1 255.255.255.0
no shutdown
exit
Configure the point-to-point link to R2:
interface Serial0/0/0
description OSPF link to R2
ip address 10.0.12.1 255.255.255.252
bandwidth 128
no shutdown
exit
The bandwidth 128 command records an intended bandwidth of 128 Kbit/s. Routing protocols can use it to calculate a metric, but it does not set the physical serial clock or limit traffic.
Configure OSPF process 10:
router ospf 10
router-id 1.1.1.1
passive-interface default
no passive-interface Serial0/0/0
network 10.1.0.1 0.0.0.0 area 0
network 10.0.12.1 0.0.0.0 area 0
exit
end
The host wildcard 0.0.0.0 enables OSPF only on the interface with that exact address. The LAN remains passive, so its prefix is advertised without sending OSPF Hello packets to client devices. The transit interface is active and can form a neighbor relationship.
Configure R2
Configure the point-to-point link:
enable
configure terminal
hostname R2
interface Serial0/0/0
description OSPF link to R1
ip address 10.0.12.2 255.255.255.252
bandwidth 128
no shutdown
exit
Configure the R2 LAN:
interface GigabitEthernet0/0/0
description R2 LAN
ip address 172.16.2.1 255.255.255.0
no shutdown
exit
Configure OSPF with a different router ID:
router ospf 10
router-id 2.2.2.2
passive-interface default
no passive-interface Serial0/0/0
network 10.0.12.2 0.0.0.0 area 0
network 172.16.2.1 0.0.0.0 area 0
exit
end
The OSPF process ID is locally significant and does not have to match between routers. Matching it in a small example makes the configuration easier to compare. The area number, subnet, Hello and Dead timers, authentication settings, and compatible network type must agree across the transit link.
Configure a Lab Serial Clock When Required
Physical serial links and some network simulators require a clock on the DCE end. Identify the cable role:
show controllers Serial0/0/0
If the local interface is the DCE end and the platform requires a clock, configure it there only:
configure terminal
interface Serial0/0/0
clock rate 128000
end
The clock rate 128000 command sets the lab serial clock to 128,000 bit/s. It is different from bandwidth 128, which supplies a metric reference in Kbit/s.
Verify Interface Status
Run these commands on both routers:
show ip interface brief
show interfaces Serial0/0/0
show interfaces Serial0/0/0 | include line protocol|Internet address|BW
The transit interfaces should be up/up, use addresses from 10.0.12.0/30, and report the intended bandwidth. If the interface is administratively down, apply no shutdown. If its line protocol is down, inspect the cable, clock, encapsulation, and remote interface.
Test direct connectivity before troubleshooting OSPF:
On R1:
ping 10.0.12.2 source 10.0.12.1
On R2:
ping 10.0.12.1 source 10.0.12.2
Verify OSPF
Display the active routing protocols and confirm the process, router ID, networks, and passive interfaces:
show ip protocols
show ip ospf
show running-config | section router ospf
Display the OSPF-enabled interfaces and inspect the transit link in detail:
show ip ospf interface brief
show ip ospf interface Serial0/0/0
Check the neighbor table:
show ip ospf neighbor
On a point-to-point link, the neighbor should reach the FULL state. R1 should see router ID 2.2.2.2; R2 should see 1.1.1.1.
Display only OSPF-learned routes:
show ip route ospf
R1 should learn the R2 LAN:
show ip route 172.16.2.0
R2 should learn the R1 LAN:
show ip route 10.1.0.0
Test routed connectivity with a source address from the local LAN:
On R1:
ping 172.16.2.1 source 10.1.0.1
On R2:
ping 10.1.0.1 source 172.16.2.1
Understand the Network Statements
In IOS XE OSPFv2, a network statement selects local interfaces whose addresses match the address and wildcard mask. It does not directly advertise an arbitrary remote network.
This exact match selects only the interface using 10.0.12.1:
network 10.0.12.1 0.0.0.0 area 0
A subnet-wide match for 10.1.0.0/24 would use:
network 10.1.0.0 0.0.0.255 area 0
Broad wildcard masks can unintentionally enable OSPF on additional interfaces. Use an exact interface address when that behavior is not required.
IOS XE can alternatively enable OSPF directly under an interface:
configure terminal
interface Serial0/0/0
ip ospf 10 area 0
end
The interface command is an alternative to matching that interface with a router-level network statement. Use one clear method consistently in a small configuration.
Understand OSPF Cost and Bandwidth
Display the bandwidth and calculated OSPF cost:
show interfaces Serial0/0/0 | include BW
show ip ospf interface Serial0/0/0 | include Cost
OSPF calculates interface cost from the OSPF reference bandwidth and the interface bandwidth. For high-speed networks, configure a consistent reference bandwidth on every OSPF router so that faster links receive distinct costs:
configure terminal
router ospf 10
auto-cost reference-bandwidth 100000
end
The value is in Mbit/s; 100000 represents 100 Gbit/s. Choose a value appropriate for the fastest link in the network and apply it consistently to every OSPF router. Changing it can change route selection.
When a design requires a fixed metric for one interface, configure an explicit cost instead of changing its documented bandwidth:
configure terminal
interface Serial0/0/0
ip ospf cost 100
end
Save the Configuration
Review the active changes before saving:
show running-config | section interface GigabitEthernet0/0/0
show running-config | section interface Serial0/0/0
show running-config | section router ospf
Save the running configuration to startup configuration on each router:
copy running-config startup-config
Confirm the destination filename when prompted.
Troubleshoot an OSPF Adjacency
No Neighbor Appears
Check Layer 1, Layer 2, addressing, reachability, OSPF activation, and passive-interface status:
show ip interface brief
show interfaces Serial0/0/0
show ip ospf interface Serial0/0/0
show ip protocols
show running-config | section router ospf
ping 10.0.12.2 source 10.0.12.1
Confirm that:
- Both interfaces are
up/upand use the same IP subnet and mask. - OSPF is enabled on both transit interfaces in the same area.
Serial0/0/0is excluded frompassive-interface defaulton both routers.- An access control list or firewall is not blocking IP protocol
89or the OSPF multicast addresses. - Each router has a unique router ID.
The Neighbor Stays in INIT
An INIT state means the router receives a neighbor’s Hello packets but does not see its own router ID returned in them. Check one-way connectivity, access control lists, link wiring, and the remote OSPF configuration.
show ip ospf neighbor
show access-lists
show cdp neighbors detail
The Neighbor Stays in EXSTART or EXCHANGE
An MTU mismatch is a common cause. Compare both ends:
show interfaces Serial0/0/0 | include MTU
show ip ospf interface Serial0/0/0
Correct the underlying MTU inconsistency when possible. Do not hide it with ip ospf mtu-ignore until the effect on the network has been evaluated.
Hello or Dead Timers Do Not Match
Compare the detailed OSPF interface output on both routers:
show ip ospf interface Serial0/0/0
Restore matching timers unless the network design intentionally uses non-default values. Also check that both ends use a compatible OSPF network type and authentication configuration.
The Router ID Is Wrong or Duplicated
Display the router ID:
show ip ospf
Configure a unique stable ID under the OSPF process. If the process is already running, the new ID normally takes effect after the OSPF process restarts:
configure terminal
router ospf 10
router-id 1.1.1.1
end
The following command resets OSPF adjacencies and temporarily removes learned OSPF routes, so use it only during an approved change window:
clear ip ospf process
A Prefix Is Missing
Check whether the local interface is up, whether its address matches an OSPF network statement, and whether the route is present in the OSPF database and remote routing table:
show ip interface brief
show ip protocols
show ip ospf database
show ip route ospf
show ip route 172.16.2.0
A passive interface still advertises its connected prefix when OSPF is enabled on that interface; it simply stops sending and receiving OSPF Hello packets there.
Use Debugging Only When Necessary
Debug output can be noisy and affect a busy router. Use it briefly from a controlled console session, then disable all debugging:
terminal monitor
debug ip ospf adj
undebug all
Collect the show-command output first. In most cases, interface state, IP reachability, area, timers, authentication, network type, MTU, passive-interface state, and router IDs identify the problem without debugging.