Which routes should OSPF learn for us?
In this three-router chain, OSPF can learn the remote LANs instead of relying on an inter-site static route for each destination. R1 keeps its static default towards the ISP. The examples use OSPFv2 for IPv4 on Cisco IOS / IOS XE. The internal router links and LANs join area 0; R1's ISP-facing Gi0/2 does not run OSPF.
This overview uses a three-router chain: R1 reaches R3 through R2, with no direct R1–R3 backup link. Assume that static routes to the remote internal LANs have been removed, or are not preferred over OSPF, before expecting the route codes below. Keep R1's static default to the ISP. A preferred static route can hide an otherwise eligible OSPF route in the routing table.
Learn more: What Is OSPF?
First understand neighbours, adjacencies and shared-LAN roles
An OSPF neighbour is another router discovered through Hello packets. A Full adjacency is a closer relationship: the routers have completed the required database synchronisation for their shared area. The link-state database (LSDB) is OSPF's map of the topology; a neighbour list and that database are different things.
On a shared broadcast LAN, OSPF elects two roles to organise these relationships and the distribution of updates:
- DR: designated router
- The elected router that coordinates OSPF adjacencies and flooding (sharing updated link-state information) on this segment. It also originates the segment's type 2 network LSA when it has the required Full adjacency. Being DR does not make it everyone's default gateway.
- BDR: backup designated router
- The elected backup. It already has Full adjacencies and maintains its database, so it can take the DR role after the existing DR is declared down. Failure detection and recovery still take time.
- DROther
- A router that is neither DR nor BDR on this segment. It forms Full adjacencies with the DR and BDR, while normally remaining 2-Way with other DROthers. It still learns routes and forwards user traffic.
These roles belong to the shared segment, not the entire OSPF area. Point-to-point OSPF links do not elect them. On a broadcast link, the role after the slash in FULL/DR or FULL/BDR describes the neighbour, not the local router.
Learn more: DR, BDR and DROther explained, with a worked election
Meet, share, calculate
Neighbour discovery, database synchronisation and path calculation are separate jobs. A neighbour is not necessarily a Full adjacency. On a broadcast LAN, two routers that are both DROthers normally stay 2-Way and synchronise through the DR/BDR.
How two routers become neighbours
A link-state advertisement (LSA) is a record describing part of the topology or reachability. A Database Description (DBD) packet summarises records so adjacent routers can discover what they lack. A Link State Request (LSR) asks for a needed record; a Link State Update (LSU) carries one or more LSAs. A Link State Acknowledgment (LSAck) confirms receipt of advertised records. These are protocol messages, not the learner's web traffic.
Read the following exchange from top to bottom. Bidirectional Hellos establish that each router can hear the other. When the routers need an adjacency, they compare database summaries and obtain missing records. Reaching Full means that the required database synchronisation has completed; one acknowledgment alone does not make a neighbour Full.
On a default Cisco broadcast Ethernet interface, OSPFv2 Hellos go to 224.0.0.5 every 10 seconds, with a 40-second dead interval. Network type and configuration can change those values. Check area, timers, subnet and authentication settings when neighbours do not form; use show ip ospf interface to inspect the actual values.
Cost: how OSPF picks a path
OSPF's metric is called cost. Each interface normally derives cost from reference bandwidth ÷ configured interface bandwidth, with a minimum of 1. A manual ip ospf cost overrides this calculation. For alternative intra-area routes to the same prefix, compare the sum of outgoing interface costs, including the destination LAN interface.
| Interface | Default cost | With reference 10000 Mbps |
|---|---|---|
| 10 Mbps Ethernet | 10 | 1000 |
| 100 Mbps FastEthernet | 1 | 100 |
| 1 Gbps GigabitEthernet | 1 | 10 |
| 10 Gbps | 1 | 1 |
With the default, OSPF can't tell 100 Mbps from 10 Gbps. That's why this lab uses auto-cost reference-bandwidth 10000consistently on R1, R2 and R3. The reference is in Mbps; it changes the cost calculation, not the link speed.
Show the outgoing-cost diagram
Why big networks split into areas
An area bounds the detailed link-state topology a router maintains. An area border router (ABR) connects areas and keeps a database for each area it joins. Remote reachability can cross the backbone without copying every remote area's internal topology. The configuration in this lesson remains single-area; the sketch below shows how that design can grow.
Show the optional multi-area example
Turning OSPF on for R1
Before typing, configure and enable the addressed interfaces: R1 Gi0/0 is 192.168.1.1/24, Gi0/1 is 10.0.12.1/30 towards R2 at 10.0.12.2, and Gi0/2 is 203.0.113.2/30 towards the ISP at 203.0.113.1. R2 joins R3 over 10.0.23.0/30. PCs use their local router's LAN IP as their default gateway; return routes must exist too.
Start this block at R1's global configuration prompt, R1(config)#. From R1#, enter configure terminal first. For the full internal address plan and router configurations, follow the linked configuration lesson. That separate lesson uses point-to-point router links; this overview keeps broadcast Ethernet to illustrate the DR/BDR neighbour labels shown below.
Learn more: Complete three-router configuration lesson
Based on Cisco IOS / IOS XE documentation, not run on a lab device. R2 and R3 are set up the same way with their own router IDs and networks.
ip route 0.0.0.0 0.0.0.0 203.0.113.1
router ospf 1
router-id 1.1.1.1
auto-cost reference-bandwidth 10000
network 192.168.1.0 0.0.0.255 area 0
network 10.0.12.0 0.0.0.3 area 0
passive-interface GigabitEthernet0/0
default-information originateOn R1. The network command uses a wildcard mask (the inverse of the subnet mask) to choose which interfaces run OSPF.
router ospf 1: the 1 is a local process number. It doesn't need to match between routers.router-id: the router's OSPF name. It must be unique.passive-interface: advertise the LAN, but don't send hellos to the PCs on it.default-information originate: originate a default when R1 has an installed default route. The static route above requires a usable ISP next hop; this example does not use the unconditional originate option.
Keep user-facing LANs passive when they do not need OSPF neighbours. An active LAN interface could admit an unwanted neighbour if its OSPF settings and authentication requirements are satisfied.
Show which R1 interfaces participate
Neighbours FULL, routes marked O
These outputs are based on Cisco documentation, not run on a lab device.
R2#show ip ospf neighbor Neighbor ID Pri State Dead Time Address Interface 1.1.1.1 1 FULL/BDR 00:00:33 10.0.12.1 GigabitEthernet0/0 3.3.3.3 1 FULL/DR 00:00:38 10.0.23.2 GigabitEthernet0/1
R1#show ip route ospf Gateway of last resort is 203.0.113.1 to network 0.0.0.0 O 10.0.23.0/30 [110/20] via 10.0.12.2, 00:03:10, GigabitEthernet0/1 O 192.168.2.0/24 [110/20] via 10.0.12.2, 00:03:10, GigabitEthernet0/1 O 192.168.3.0/24 [110/30] via 10.0.12.2, 00:03:10, GigabitEthernet0/1
Type commands in the practice lab
The practice lab starts with the chain already configured. First inspect show ip ospf neighbor and show ip route ospf; R1 should learn 192.168.3.0/24 via 10.0.12.2 at cost 30. In its guided failure exercise, making the transit interface passive removes its OSPF neighbours without shutting the cable. Restore it with no passive-interface Gi0/1 in router configuration mode and verify that the neighbour and route return, or use Reset lab to restore the prepared baseline.
An installed route and a successful application test are different checks. This browser lab supports only the documented command subset. Its expected output is an educational model, not a measurement from your own router or a guarantee of Internet access.
Simulated R1 terminal. Type supported IOS commands and inspect the result. R2 and R3 are preconfigured. Outputs are simplified teaching examples, not responses from real equipment. Changes last until reset or page reload.
R1 is ready. Try show ip ospf neighbor, or ? for help.
Ready. Type a command and press Enter.
Try a guided troubleshooting exercise
- Inspect routes with
show ip route ospf. - Enter
enable,configure terminal, thenrouter ospf 1. - Type
passive-interface Gi0/1, thendo show ip ospf neighbor. - Compare
do ping 10.0.12.2withdo ping 192.168.3.10. The link is up, but the OSPF neighbour and remote routes are gone. - Check
do show ip route 192.168.3.10: the default still matches, but this lab ISP cannot reach LAN 3. - Restore
no passive-interface Gi0/1. Tryauto-cost reference-bandwidth 100and inspect routes again. Only R1 changes, so the remote route becomes cost 21. Reset to restore the consistent 10000 Mbps reference on all routers.
Test yourself on the OSPF overview
R1 and R2 are cabled, but R1 is in area 0 and R2's interface is in area 1. What happens?
Two paths: three 1 Gbps links, or one 100 Mbps link, all at default reference bandwidth. Which does OSPF choose?
Two OSPF neighbours are both DROthers on the same broadcast LAN. They remain 2-Way with each other. Is that necessarily a fault?
References: RFC 2328 routing-protocol packets, Cisco neighbour states, OSPF costs and behaviour, and IOS XE configuration guide.