Start with the interfaces and the required result
PC-A on 192.168.1.0/24 needs to reach the server at 192.168.3.10. R1 knows PC-A's local network, and R3 knows the server's local network. R2 joins them. Each router needs routes to the remote LANs, and the server needs a return path to PC-A.
OSPFv2 is the IPv4 routing protocol we use here. An area groups interfaces that share detailed OSPF topology information. This small network uses one normal area, area 0. An OSPF neighbour is another router on a local link. PCs and ordinary Layer 2 access switches do not need to become OSPF neighbours.
R1–R3 should learn the three LANs. Only router-to-router interfaces form neighbours. R1 also supplies an external default route. Interface addresses and basic connectivity are already configured; the blocks below start in global configuration mode on their named router.
- R1 · RID 1.1.1.1
- Gi0/0 192.168.1.1/24 → SW1; Gi0/1 10.0.12.1/30 → R2 Gi0/0 10.0.12.2/30; Gi0/2 203.0.113.2/30 → ISP Gi0/0 203.0.113.1/30 (outside OSPF).
- R2 · RID 2.2.2.2
- Gi0/0 → R1; Gi0/1 10.0.23.1/30 → R3 Gi0/0 10.0.23.2/30; Gi0/2 192.168.2.1/24 → SW2.
- R3 · RID 3.3.3.3
- Gi0/0 → R2; Gi0/1 192.168.3.1/24 → SW3. LAN interfaces on all three routers are passive but included in area 0.
- Hosts and access switches
- PC-A 192.168.1.10/24, PC-B 192.168.2.10/24, server 192.168.3.10/24. Each gateway is its LAN's .1 router address. Each switch Gi0/1 → router, Gi0/2 → host Ethernet; one local access VLAN per LAN.
- OSPF assumptions
- Area 0, local process 1, unique explicit RIDs. Router links: point-to-point, Hello 10 / Dead 40 s, no authentication, matching MTU 1500. All interfaces up; gigabit bandwidth, reference 10000 Mbps, outgoing cost 10 unless stated.
- Address key
- /24 mask 255.255.255.0; /30 mask 255.255.255.252. Prefixes describe networks; host/interface addresses identify devices. No URL is shown. ISP range is documentation addressing; Internet service needs NAT, return routing and permitting policy beyond this OSPF example.
See the configuration and verification sequence
Read in arrow direction. Labels describe each stage or hop; connectors show the sequence, not a complete physical cabling plan or time to scale.
1 · Select the interface, keep its actual subnet mask
The process ID is the local number for OSPF, here 1. The router ID is a separate unique name, such as 1.1.1.1 for R1. It looks like an IP address, but it does not need to be configured on a port. Set it explicitly so the router's identity is predictable.
A wildcard mask tells IOS which address bits to compare: 0 means match, and 1 means ignore. The wildcard 0.0.0.3 matches the four addresses from 10.0.12.0 through 10.0.12.3. R1's 10.0.12.1 interface is inside that range.
See why matching one address does not create a /32 route
- Equivalent selection
- On this R1, network 10.0.12.0 0.0.0.3 area 0 also selects Gi0/1. Its range is 10.0.12.0–10.0.12.3. Wildcard bits: 0 = compare, 1 = ignore. The /30 subnet mask is 255.255.255.252.
- Alternative command
- Under R1 interface Gi0/1: ip ospf 1 area 0 selects the interface explicitly. Both alternatives use local process 1 and area 0. R1 RID 1.1.1.1; its peer is R2 Gi0/0 10.0.12.2/30, RID 2.2.2.2.
The network command selects local interfaces. A precise match does not create a host route. The interface's actual address and mask determine the connected prefix advertised by this example.
network 10.0.12.0 0.0.0.3 area 0R1 router configuration mode: selects Gi0/1. For a contiguous /30 mask, 255.255.255.255 − 255.255.255.252 gives wildcard 0.0.0.3.
interface GigabitEthernet0/1
ip ospf 1 area 0Alternative on R1, from global configuration mode: enable OSPF directly on Gi0/1. Use either method for this interface; both are not needed.
The process number is local: neighbours do not need matching process IDs. Area IDs must agree on the link. On IOS, an interface-level OSPF area command takes precedence over a matching network statement; check both when reading an existing configuration.
2 · Advertise user LANs without forming neighbours there
The LAN must be included in OSPF so other routers can learn it. However, there is no OSPF router to discover beside PC-B. A passive interface advertises its selected subnet without sending Hello discovery packets or forming an adjacency on that interface.
Follow R2's active router links and passive LAN
- Routers and links
- R1 RID 1.1.1.1, Gi0/1 10.0.12.1/30 ↔ R2 RID 2.2.2.2, Gi0/0 10.0.12.2/30. R2 Gi0/1 10.0.23.1/30 ↔ R3 RID 3.3.3.3, Gi0/0 10.0.23.2/30. Area 0, P2P, Hello 10 / Dead 40 s.
- Passive LAN
- R2 Gi0/2 192.168.2.1/24 → SW2 Gi0/1; SW2 Gi0/2 → PC-B Ethernet 192.168.2.10/24, gateway 192.168.2.1. OSPF is enabled on Gi0/2 and passive-interface GigabitEthernet0/2 is set. No OSPF neighbour forms on this LAN.
Passive does not mean hidden. The OSPF-enabled LAN stays advertised, but no adjacency forms on it. With passive-interface default, enable neighbour formation only on the intended router links.
3 · Apply the configuration to each router
R1 · network statements and the ISP default
Read R1's block in three parts. The static default points unknown destinations to the Internet service provider (ISP). The interface command makes the R1–R2 link point-to-point: OSPF treats it as a link with one other router, without electing a designated router. The process commands then set identity, cost calculation and the interfaces allowed to form neighbours.
ip route 0.0.0.0 0.0.0.0 203.0.113.1
interface GigabitEthernet0/1
ip ospf network point-to-point
exit
router ospf 1
router-id 1.1.1.1
auto-cost reference-bandwidth 10000
passive-interface default
no passive-interface GigabitEthernet0/1
network 192.168.1.0 0.0.0.255 area 0
network 10.0.12.0 0.0.0.3 area 0
default-information originate
exitR1 only, from global configuration mode. Gi0/0 advertises LAN 1 passively. Gi0/1 forms the R2 adjacency. Gi0/2 faces the ISP and is not selected for OSPF. Set the RID before enabling the process on its interfaces.
R2 · explicit interface commands
R2 has two router-facing links, so both need no passive-interface. Its third interface is the PC-B LAN and stays passive. This block uses interface commands instead of network statements to show the alternative. You do not need both methods on the same interface.
router ospf 1
router-id 2.2.2.2
auto-cost reference-bandwidth 10000
passive-interface default
no passive-interface GigabitEthernet0/0
no passive-interface GigabitEthernet0/1
exit
interface GigabitEthernet0/0
ip ospf 1 area 0
ip ospf network point-to-point
exit
interface GigabitEthernet0/1
ip ospf 1 area 0
ip ospf network point-to-point
exit
interface GigabitEthernet0/2
ip ospf 1 area 0
exitR2 only. Gi0/0 and Gi0/1 form neighbours; Gi0/2 advertises LAN 2 passively. An interface must be selected for OSPF before the passive setting can advertise its subnet.
R3 · exact interface-address matches
R3 uses wildcard 0.0.0.0, which compares every address bit. The two lines therefore select exactly the transit interface and the LAN interface. They still advertise the real /30 transit and /24 LAN networks. The wildcard selects an interface; the configured interface mask describes its subnet.
interface GigabitEthernet0/0
ip ospf network point-to-point
exit
router ospf 1
router-id 3.3.3.3
auto-cost reference-bandwidth 10000
passive-interface default
no passive-interface GigabitEthernet0/0
network 10.0.23.2 0.0.0.0 area 0
network 192.168.3.1 0.0.0.0 area 0
exitR3 only. Exact matches select the two interfaces. Gi0/0 forms the R2 adjacency; Gi0/1 advertises LAN 3 passively. Its LAN prefix remains /24, not /32.
A new interface remains passive under this policy, but its subnet is advertised only if OSPF is also enabled on it. For a new router link, configure the network type on both ends and remove passive on the intended interface.
4 · Check the route cost from the receiving router
Cost is OSPF's path metric. For this example, each gigabit routed interface costs 10. To reach LAN 1, R3 adds its outgoing cost towards R2, R2's outgoing cost towards R1 and R1's outgoing cost onto LAN 1: 10 + 10 + 10 gives an OSPF route metric of 30. Switch ports on the same LAN do not add a routed OSPF hop.
- Cost assumptions
- Each routed interface has bandwidth 1000 Mbps; every router uses reference 10000 Mbps. No manual cost override: 10000 ÷ 1000 = 10. RIDs R1 1.1.1.1, R2 2.2.2.2, R3 3.3.3.3; area 0, transit links P2P.
- Interfaces and next hop
- R3 Gi0/0 10.0.23.2/30 → R2 Gi0/1 10.0.23.1/30; R2 Gi0/0 10.0.12.2/30 → R1 Gi0/1 10.0.12.1/30; R1 Gi0/0 192.168.1.1/24 → SW1 Gi0/1. R3's immediate next hop is 10.0.23.1, not R1's RID.
Reference bandwidth is in Mbps. At 10000 Mbps, gigabit interfaces cost 10; 100 Mbps interfaces cost 100; 10 Gbps interfaces cost 1. Use the same reference across the domain. The default 100 Mbps reference gives all three speeds cost 1.
Manual cost and bandwidth overrides
An explicit ip ospf cost 50 overrides the automatic calculation on that outgoing interface. Otherwise OSPF uses the interface bandwidth value. The bandwidth command changes that configured value, not the physical line rate. The reverse direction has its own cost. These overrides are not applied in the cost-30 example.
interface GigabitEthernet0/1
ip ospf cost 50Separate example: interface configuration from global mode on the selected router. This changes its outgoing cost, so the illustrated metric may change.
Equal-cost paths can be installed up to the device's supported and configured maximum-paths limit. This chain has no alternate path.
5 · Originate a default only under the intended condition
A default route, 0.0.0.0/0, is used when no more specific route matches the destination. R1 having a static default does not automatically teach it to R2 and R3. default-information originate asks OSPF to advertise one while R1 has an eligible installed default, under the conditions used in this lab.
On R3 the default next hop is R2, 10.0.23.1. R3 cannot send directly to the ISP's 203.0.113.1 address because that router is not on R3's local link. Each router forwards to its own next hop.
Compare the advertised default and its withdrawal
- Link and identity map
- ISP Gi0/0 203.0.113.1/30 ↔ R1 Gi0/2 203.0.113.2/30. R1 Gi0/1 10.0.12.1/30 ↔ R2 Gi0/0 .2/30. R2 Gi0/1 10.0.23.1/30 ↔ R3 Gi0/0 .2/30. RIDs: R1 1.1.1.1; R2 2.2.2.2; R3 3.3.3.3.
- Example conditions
- Normal area 0; internal links P2P; R1 is ASBR. Plain default-information originate, no route-map or metric override; example external type E2, metric 1. R3's next hop is 10.0.23.1. R1 does not run OSPF towards the ISP.
- Link and identity map
- ISP Gi0/0 203.0.113.1/30 ↔ R1 Gi0/2 203.0.113.2/30. R1 Gi0/1 10.0.12.1/30 ↔ R2 Gi0/0 .2/30. R2 Gi0/1 10.0.23.1/30 ↔ R3 Gi0/0 .2/30. RIDs: R1 1.1.1.1; R2 2.2.2.2; R3 3.3.3.3.
- Example conditions
- R1 has no installed 0.0.0.0/0. No always keyword, route-map or alternate default originator. Snapshot is after withdrawal and convergence. OSPF neighbours on internal links remain Full.
An installed default is not an Internet health check. A failure beyond the ISP next hop can leave R1's static default installed. Plain default-information originate then continues advertising it. The always keyword removes the installed-default requirement; it does not repair upstream connectivity.
6 · Verify interfaces, neighbours and learned routes
First check what OSPF is actually running on. Next check whether the expected router has reached Full, meaning database synchronisation has completed. Finally inspect the route for the destination. These checks answer different questions; one successful neighbour entry is not proof that every LAN is advertised.
R2#show ip ospf interface brief Interface PID Area IP Address/Mask Cost State Nbrs F/C Gi0/1 1 0 10.0.23.1/30 10 P2P 1/1 Gi0/0 1 0 10.0.12.2/30 10 P2P 1/1
R2#show ip ospf interface GigabitEthernet0/2 Internet Address 192.168.2.1/24, Area 0 Process ID 1, Router ID 2.2.2.2, Network Type BROADCAST, Cost: 10 No Hellos (Passive interface) Neighbor Count is 0, Adjacent neighbor count is 0
R2#show ip ospf neighbor Neighbor ID Pri State Dead Time Address Interface 3.3.3.3 0 FULL/ - 00:00:34 10.0.23.2 GigabitEthernet0/1 1.1.1.1 0 FULL/ - 00:00:39 10.0.12.1 GigabitEthernet0/0
R3#show ip route ospf O*E2 0.0.0.0/0 [110/1] via 10.0.23.1, GigabitEthernet0/0 O 10.0.12.0/30 [110/20] via 10.0.23.1, GigabitEthernet0/0 O 192.168.1.0/24 [110/30] via 10.0.23.1, GigabitEthernet0/0 O 192.168.2.0/24 [110/20] via 10.0.23.1, GigabitEthernet0/0
show ip ospf | include ID|ReferencePrivileged EXEC on each router: confirm the active RID and 10000 Mbps reference. On an existing process, a configured RID change may require a process restart; plan for disrupted adjacencies.
Test PC-B to server 192.168.3.10 and back, checking host gateways and any filtering. Full neighbours alone do not prove end-to-end traffic works. After verification, save on each router with copy running-config startup-config.
Short lab: prove the LAN advertisement
On R3 run show ip route 192.168.1.0, then ping 192.168.1.10 from the server. In this isolated lab, remove only R1's LAN network statement with no network 192.168.1.0 0.0.0.255 area 0 under process 1. Leave the R1–R2 transit statement intact.
Check R2's neighbour table and R3's route again. R1 can remain Full with R2 while the LAN route disappears after convergence. Restore the original network statement and verify the route and host test recover. This separates a healthy neighbour relationship from a complete set of advertisements.
For a failed check, follow Verifying and troubleshooting OSPF. For a complete hands-on build, use the single-area OSPF lab.
Sources: Cisco network-area command reference, passive-interface behaviour, and default-route origination.
Test yourself on configuring OSPF
R1 has Gi0/1 10.0.12.1/30 and the command network 10.0.12.0 0.0.0.3 area 0. Which prefix does R1 advertise for that link?
The reference bandwidth is 10000 Mbps. What is the OSPF cost of a FastEthernet (100 Mbps) interface?
R2's OSPF-enabled LAN interface Gi0/2 is configured as passive. What happens to 192.168.2.0/24?
R3 has passive-interface default and network statements for both interfaces, but no other commands. What happens with R2?
R1 uses plain default-information originate, without always or a route-map. Its only installed default is removed, and no other router originates one. After convergence, what do R2 and R3 see?