Revise OSPF
OSPF (Open Shortest Path First) β Complete Beginner to Advanced Notes
π° 1. Absolute Basics: What is OSPF?
π§ Simple Explanation
OSPF is a routing protocol used by routers to find the best path for data.
π Think of it like Google Maps for a network:
- It doesnβt just follow directions blindly
- It builds a full map of the network and decides the best route itself
π Example
Router A β wants to send data to Router C
Instead of asking:
βHey B, how do I reach C?β
It already knows:
- All paths
- Link speeds
So it calculates the fastest route itself
π― Why Itβs Important
- Open standard (works on Cisco, Juniper, MikroTik, etc.)
- Fast convergence (quickly adapts to failures)
- Loop-free routing
- Scalable for large networks
π Connect to Next Concept
Before routers build a map, they need identity
β‘οΈ Next: Router ID (RID)
π Quick Revision
- OSPF = Link-State Protocol
- Builds full network map (LSDB)
- Chooses best path using logic (not guess)
π 2. Router Identity: Router ID (RID)
π§ Simple Explanation
Every router needs a unique name
π That name is called Router ID (RID)
Format: Looks like an IP
Example: 1.1.1.1
βοΈ How RID is Selected (Priority Order)
- Manual β
router-id 1.1.1.1 - Highest Loopback IP
- Highest Physical Interface IP
π Example
- Loopback0 β 10.10.10.10
- Interface β 192.168.1.1
π RID = 10.10.10.10 (Loopback wins)
π― Why Itβs Important
- Identifies routers uniquely
- Used in LSAs and topology
- Prevents confusion in network
π§ Memory Trick
π RID = Aadhaar Card of Router
- Unique
- Fixed (until restart)
β οΈ Common Mistake
- Changing RID without restarting OSPF β No effect
π Connect to Next Concept
Now router has identity
β‘οΈ Next: How routers discover neighbors
π Quick Revision
- RID = Unique router identity
- Must be unique
- Selected in priority order
π€ 3. Neighbors & Adjacency
β οΈ Before Understanding This
You must know: π Routers donβt share data with everyone β only trusted neighbors
π§ Simple Explanation
Step 1: Discover
Routers send Hello packets
π‘ Multicast: 224.0.0.5
Step 2: Become Neighbors
If rules match β become Neighbors
Step 3: Become Adjacent
If fully synced β become Full (Adjacency)
π Example
Router A & B:
- Same subnet βοΈ
- Same area βοΈ
- Same timers βοΈ
π Result: FULL adjacency
π Adjacency Requirements
| Requirement | Must Match |
|---|---|
| Area ID | Yes |
| Subnet | Yes |
| Hello Timer | Yes |
| Dead Timer | Yes |
| RID | Must be unique |
π― Why Itβs Important
- Only adjacent routers share full topology
- Prevents incorrect routing
β οΈ Common Mistakes
- MTU mismatch β stuck in EXSTART
- Timer mismatch β no neighbor
- Same RID β OSPF failure
π Connect to Next Concept
Too many routers = too much communication
β‘οΈ Solution: DR & BDR
π Quick Revision
- Hello β Neighbor β Adjacency
- FULL state = synchronized LSDB
- Matching parameters is critical
π 4. DR & BDR (Designated Router)
β οΈ Before Understanding This
In large networks: π Every router talking to every router = chaos
π§ Simple Explanation
OSPF elects:
- DR (Leader)
- BDR (Backup Leader)
π Analogy
Classroom:
- Students = Routers
- Class Monitor = DR
- Assistant Monitor = BDR
Instead of everyone talking: π All talk to DR
βοΈ Election Process
- Highest Priority (default = 1)
- Highest RID (tie-breaker)
π Priority 0 = Never DR
π Example
| Router | Priority | RID | |βββ|βββ|ββ| | R1 | 1 | 1.1.1.1 | | R2 | 1 | 2.2.2.2 |
π DR = R2 (higher RID)
π― Why Itβs Important
- Reduces traffic
- Saves CPU/memory
- Efficient communication
β οΈ Common Mistake
- DR election is non-preemptive π New better router wonβt replace DR
π Connect to Next Concept
We optimized one network segment
But what about 1000 routers?
β‘οΈ Next: Areas
π Quick Revision
- DR = Leader
- BDR = Backup
- Reduces communication
π 5. OSPF Areas
π§ Simple Explanation
OSPF divides network into Areas
π Like dividing a city into zones
ποΈ Types of Areas
π΅ Area 0 (Backbone)
- Core of OSPF
- All areas must connect here
π’ Other Areas
- Branch networks
π₯ Router Types
| Router | Role |
|---|---|
| Internal | Inside one area |
| ABR | Connects Area 0 + other areas |
| ASBR | Connects external network |
π Example
- Area 1 β Branch office
- Area 0 β HQ
- ABR connects both
π― Why Itβs Important
- Reduces LSDB size
- Improves scalability
- Faster performance
β οΈ Common Mistake
- Area not connected to Area 0 β OSPF fails
π Connect to Next Concept
Now routers have map
β‘οΈ How do they choose best path?
Next: Cost (Metric)
π Quick Revision
- Area 0 = Backbone
- ABR connects areas
- Areas = scalability
π° 6. Cost (Metric)
π§ Simple Explanation
OSPF uses Cost to choose best path
π Lower cost = Better path
βοΈ Formula
::contentReference[oaicite:0]{index=0}
π Example
| Bandwidth | Cost |
|---|---|
| 10 Mbps | 10 |
| 100 Mbps | 1 |
π― Why Itβs Important
- Determines routing path
- Based on speed (not hops)
β οΈ Common Mistake
Default Reference Bandwidth = 100 Mbps
π So:
- 100 Mbps = cost 1
- 10 Gbps = cost 1 β (wrong)
βοΈ Fix: Manually increase reference bandwidth
π Connect to Next Concept
Routers share topology using messages
β‘οΈ Next: LSAs
π Quick Revision
- Cost = based on bandwidth
- Lower = better
- Must tune reference bandwidth
π© 7. LSAs (Link-State Advertisements)
β οΈ Before Understanding This
LSA = Information packet about network
π§ Simple Explanation
Routers send LSAs like: π βHereβs my network infoβ
π¦ Types of LSAs
π’ Type 1 (Router LSA)
- Created by every router
- Contains its links
π΅ Type 2 (Network LSA)
- Created by DR
- Lists routers in network
π‘ Type 3 (Summary LSA)
- Created by ABR
- Shares between areas
π΄ Type 5 (External LSA)
- Created by ASBR
- External routes (Internet)
π― Why Itβs Important
- Builds LSDB (network map)
- Keeps routers updated
π Connect to Next Concept
Now letβs configure OSPF
β‘οΈ Next: Configuration
π Quick Revision
- LSA = network info packet
- Type 1 = router
- Type 3 = inter-area
- Type 5 = external
βοΈ 8. Basic Configuration (OSPFv2)
π§ Steps
Step 1: Start OSPF
1
router ospf 1
Step 2: Set RID
1
router-id 1.1.1.1
Step 3: Add Networks
Method 1:
1
network 10.0.0.1 0.0.0.0 area 0
Method 2:
1
2
interface g0/0
ip ospf 1 area 0
Step 4: Passive Interface
1
passive-interface g0/1
π Used for LAN (no OSPF hellos sent)
π― Why Itβs Important
- Enables routing
- Controls OSPF behavior
β οΈ Common Mistake
- Forgetting wildcard mask
- Wrong area assignment
π Quick Revision
- router ospf β start
- network β enable interfaces
- passive β optimize
π 9. OSPFv3 (IPv6)
π§ Simple Explanation
OSPFv3 = OSPF for IPv6
π Key Differences
| Feature | OSPFv2 | OSPFv3 |
|---|---|---|
| Address | IPv4 | IPv6 |
| RID | Auto | Manual required |
| Discovery | Normal IP | Link-local (FE80::) |
π― Why Itβs Important
- Required for IPv6 networks
- Same logic, new structure
π Quick Revision
- OSPFv3 = IPv6 version
- Manual RID required
- Uses link-local
π§ 10. BIG PICTURE (Final Understanding)
π Full Workflow
- Router gets RID
- Sends Hello packets
- Forms Neighbors
- Becomes Adjacent (FULL)
- Elects DR/BDR
- Exchanges LSAs
- Builds LSDB (Map)
- Calculates path using Cost + SPF
- Routes traffic
π― Final Analogy
π OSPF = Google Maps System
| OSPF Concept | Real Life |
|---|---|
| RID | Phone number |
| LSDB | Map |
| LSA | Updates |
| Cost | Travel time |
| SPF | Route calculation |
β οΈ Common Mistakes (VERY IMPORTANT)
- Same Router ID β
- Area mismatch β
- Timer mismatch β
- MTU mismatch β
- Not connecting to Area 0 β
- Not updating reference bandwidth β
π§ Memory Tricks
- RID = Aadhaar Card
- DR = Class Monitor
- LSA = WhatsApp Updates
- Cost = Travel Time
- Area 0 = Main Highway
β FINAL REVISION SUMMARY
- OSPF = Link-State Protocol
- Builds full network map (LSDB)
- Uses RID for identity
- Uses Hello packets for neighbors
- DR/BDR reduces traffic
- Areas improve scalability
- Cost decides best path
- LSAs share information
- OSPFv3 = IPv6 version
π You Are Now OSPF Ready
If you want next level: π I can help you with:
- OSPF packet flow deep dive
- LSA flooding lab
- DR election packet capture (Wireshark)
- Interview questions (real-world)
Just tell me π