TTR Networks

Beginner · OSPF Fundamentals · section 8 of 9

OSPF as the underlay for BGP

✓ Lab-tested 17 October 2026 on FRR 10.2.1

Most networks that run BGP also run an IGP, and they have different jobs:

OSPFBGP
CarriesLoopbacks and internal links — hundreds of routesCustomer and internet prefixes — up to a full table
Optimises forFast convergence, shortest internal pathPolicy, stability, scale
Trust modelEveryone in the area is trustedEvery neighbour is filtered
Loop preventionIdentical database + SPFAS_PATH (eBGP), split horizon/RR attributes (iBGP)

Three ways OSPF directly shapes your BGP:

  1. iBGP sessions run between loopbacks, and OSPF is what makes those loopbacks reachable. Lose OSPF and every iBGP session drops after its hold timer.
  2. BGP next hops are resolved through the IGP. A BGP path whose NEXT_HOP isn't in the routing table is invalid. That's why you either set next-hop-self on border routers or carry the external link subnets in OSPF (usually as passive interfaces).
  3. Best-path step 8 — lowest IGP metric to the next hop — is OSPF cost. When the BGP attributes tie, each router exits at the nearest edge ("hot-potato" routing). Changing an OSPF cost can move external traffic.

Never redistribute a full BGP table into OSPF. Every router would flood and run SPF over hundreds of thousands of external LSAs. The IGP carries infrastructure; BGP carries customers and the internet.

Diagram: OSPF underneath iBGP — OSPF carries loopbacks; iBGP carries the internet prefix; OSPF cost decides which exit wins.
  1. OSPF carries the loopbacks. Inside AS 64500, OSPF advertises every router's loopback and every internal link. It carries nothing from the internet — the IGP stays small and fast.
  2. Both edges learn the same prefix. Each edge router learns 203.0.113.0/24 over eBGP with identical LOCAL_PREF, AS_PATH length, ORIGIN and MED.
  3. iBGP next hops are loopbacks. The edges advertise the prefix to R3 over iBGP with next-hop-self, so the BGP next hops are 10.255.0.1 and 10.255.0.2. R3 can only use these paths because OSPF gave it routes to those loopbacks.
  4. Hot potato: the IGP breaks the tie. Every BGP attribute ties, so R3 reaches step 8 of best-path: lowest IGP metric to the next hop. OSPF says Edge1 costs 10 and Edge2 costs 50 — traffic leaves via Edge1 and ISP A.
  5. OSPF changes, BGP follows. If the R3–Edge1 link fails, OSPF reconverges: Edge1 is now 150 away (50 to Edge2, plus 100 across), while Edge2 is still 50. R3's best path flips to Edge2 and ISP B without a single BGP UPDATE being sent.

Check your understanding

R3 receives 203.0.113.0/24 from Edge1 over iBGP with NEXT_HOP 10.255.0.1, but show bgp marks the path as inaccessible. What's wrong?

  • Edge1's loopback isn't advertised into OSPF, so R3 has no route to the next hop
  • Edge1 needs a higher LOCAL_PREF
  • R3 needs an eBGP session to ISP A
  • OSPF must redistribute 203.0.113.0/24