How OSPF Neighbor Adjacency Works
To have two routers discover each other and exchange routes:
- Advertise the networks connecting the two routers โ this establishes adjacency only.
- Advertise the networks you want the neighbor to know about โ only then will the neighbor see networks “behind” the first router.
Basic Configuration
| Command | Description |
|---|---|
| router ospf 1 | Enter OSPF process 1 |
| router-id 0.0.0.32 | Manually set router ID |
| network 192.168.0.0 0.0.255.255 area 0 | Advertise network in area 0 |
| passive-interface fa0/0.2 | Suppress hello packets on interface (toward end users) |
| auto-cost reference-bandwidth 10000 | Set reference bandwidth in Mbps โ apply to ALL routers |
| clear ip ospf 1 process | Reset OSPF routing information |
| Command | Description |
|---|---|
| ip ospf cost 12 | Set interface cost manually |
| ip ospf hellow-interval 8 | Send hello every 8 seconds |
| ip ospf dead-interval 30 | Declare neighbor dead after 30 s without hello |
| ip ospf priority 100 | DR/BDR election priority |
| ip mtu 1400 | Set MTU (must match on all routers in the same segment) |
| bandwidth 10000 | Set interface bandwidth in Kbps (affects cost calculation) |
Cost formula: reference bandwidth / interface bandwidth (Kbps). Default reference bandwidth = 100 000. For links faster than 100 Mbps set:
auto-cost reference-bandwidth 100000000.
Diagnostics
| Command | Description |
|---|---|
| show ip ospf neighbor | Neighbor table with adjacency state |
| show ip ospf database | LSDB โ LSAs from neighbors |
| show ip ospf database router 1.1.1.1 | Detailed LSA content from router ID 1.1.1.1 |
| show ip ospf interface [brief] | OSPF-enabled interfaces and their cost |
| show ip ospf route | Routes computed by OSPF (before RIB insertion) |
| show ip route ospf | OSPF routes installed in the routing table |
| show ip route 192.168.3.2 | Detailed info for a specific route |
| show ip protocols | Dynamic routing protocol config (AD, networks, router ID) |
Route Filtering
Method 1 โ prefix-list + area filter-list (on ABR)
Goal: block networks 10.0.1.0, 10.0.2.0, 10.0.3.0 from being leaked from Area 0 into Area 1.
The logic is reversed โ permit only what you want; everything else is denied by default.
| Command | Description |
|---|---|
| ip prefix-list OSPF permit 192.168.0.0/16 | Permit only 192.168.0.0/16 to pass |
| area <id> filter-list prefix OSPF <in|out> | Apply on ABR. in = into area, out = from area |
| distance ospf external 255 | Raise AD for external OSPF routes (prevents default route override) |
Note: This filter does not block the default route
0.0.0.0โ it will still reach the neighbor router.
Method 2 โ distribute-list (on receiving router)
Goal: allow a router to install only specific routes in its RIB.
| Command | Description |
|---|---|
| access-list 3 permit 172.10.0.0 0.0.255.255 | Define permitted routes in ACL |
| router ospf 1 | Enter OSPF context |
| distribute-list 3 in | Apply ACL โ only listed routes are installed in RIB |
The router filters what goes into the RIB, but the LSDB remains unchanged.
Difference: Method 1 โ prevents a router from advertising routes. Method 2 โ prevents a router from accepting routes into RIB.
Filtering During Redistribution
| Command | Description |
|---|---|
| ip prefix-list FILT deny 172.10.2.0/16 | Create prefix-list to block a network |
| redistribute eigrp 1 subnets | Enable redistribution from EIGRP into OSPF |
| distribute-list prefix FILT out eigrp 1 | Apply filter to redistributed routes from EIGRP |
Route Summarization
| Command | Description |
|---|---|
| area 1 range 192.168.0.0 255.255.0.0 | ABR: advertise summary route for area 1 to other areas |
| summary-address 192.168.0.0 255.255.0.0 | ASBR: advertise summarized external route |
Redistribution
| Command | Description |
|---|---|
| default-information originate [always] | Method 1: inject default route to all OSPF neighbors. Requires static 0.0.0.0 on ASBR, or add `always` |
| redistribute connected subnets | Method 2: inject connected networks of ASBR into OSPF |
| redistribute eigrp 1 subnets | Inject EIGRP routes into OSPF |
| redistribute eigrp 1 metric-type 1 subnets | Same, but account for OSPF transit cost (E1 type) |
| distance ospf external|inter-area|intra-area 1-255 | Change AD for all OSPF route types |
| distance 1-255 172.20.0.0 0.0.255.255 | Change AD for a specific route only |
OSPF Area Types
Stub Area
ABR replaces Type-5 (external) LSAs with a default route for the stub area. All routers in the area must be configured as stub.
| Command | Description |
|---|---|
| area 1 stub | Mark area 1 as stub โ configure on ALL routers in the area |
| area 2 default-cost 50 | Set cost of the default route injected by ABR for stub area |
Totally Stubby Area
Replaces both Type-3 (inter-area summary) and Type-5 LSAs with a single default route.
| Command | Description |
|---|---|
| area 2 stub | On internal area routers |
| area 2 stub no-summary | On ABR โ blocks Type-3 and Type-5 LSAs |
NSSA (Not-So-Stubby Area)
Workaround for having an ASBR inside a stub area. ASBR generates Type-7 LSA; ABR converts Type-7 โ Type-5.
| Command | Description |
|---|---|
| area 2 nssa [no-summary] | Mark area as NSSA. Add `no-summary` to make it Totally NSSA |
Additional Features
| Command | Description |
|---|---|
| neighbor 10.0.2.1 | Manually define neighbor (NBMA / frame-relay โ no broadcast) |
| ip ospf authentication message-digest | Enable MD5 authentication on interface |
| ip ospf message-digest-key 1 md5 cisco | Set authentication key |
| show ip ospf int e0/1 | Verify authentication is enabled on the interface |
Cisco IOS Command Reference | OSPF