Redistribution OSPF and BGP: External LSAs, Metrics, and Loops

Redistribution OSPF and BGP: External LSAs, Metrics, and Loops

Redistribution between OSPF and BGP is where the enterprise meets the internet: an IGP that knows the inside, a path-vector protocol that knows the outside, and a boundary router that must translate between them without starting a routing loop. This walk-through goes from why you redistribute to external LSA metric types, seed metrics, and the tag-based defense that keeps mutual redistribution from eating itself.

1. Why redistribute OSPF and BGP at all

OSPF carries your internal topology; BGP carries reachability to and from other autonomous systems. At the edge — a dual-homed enterprise, a provider PE — one router sits in both worlds and must move selected routes across. You redistribute OSPF into BGP so the outside can reach your networks, and BGP into OSPF so the inside can reach external destinations. The art is moving only what should move, in one controlled direction where possible.

Why redistribute OSPF and BGPNET BY MEOSPF domaininternal topologyASBR / edgeredistributes both waysBGP / internetexternal reachability

2. The two directions are not symmetric

Each direction has its own rules. OSPF into BGP: by default only internal OSPF routes are taken; external OSPF routes need an explicit match external. BGP into OSPF: only eBGP routes are redistributed by default — iBGP routes are held back unless you enable bgp redistribute-internal, a safety valve that exists precisely because redistributing iBGP carelessly is a classic way to build a loop.

OSPF->BGP vs BGP->OSPFNET BY MEOSPF -> BGPinternal OSPF taken by defaultexternal needs match externalBGP -> OSPFeBGP routes by defaultiBGP needs redistribute-internal

3. BGP into OSPF becomes a Type 5 External LSA

When BGP routes enter OSPF, they are not ordinary intra-area routes — they arrive as Type 5 External LSAs, flooded across the whole OSPF domain (outside stub areas), originated by the ASBR. Every router then sees them as O E1 or O E2 routes. Recognising that redistributed routes are externals is the key to reading the routing table and to understanding the metric behaviour that follows.

BGP into OSPF = Type 5 External LSANET BY MEASBRoriginates Type 5 LSArouter sees O E2router sees O E2router sees O E2flooded domain-wide (except stub areas)

4. E1 vs E2 — the metric type that trips everyone

External OSPF routes carry a metric type. E2 (the default) keeps the external metric constant everywhere in the domain — the internal cost to reach the ASBR is ignored, so all routers see the same metric and pick the ASBR by lowest internal cost only as a tiebreak. E1 adds the internal cost to the external metric, so the total grows with distance to the ASBR. Use E1 when you have multiple ASBRs and want routers to prefer the nearest one.

OSPF external metric types E1 vs E2NET BY MEE2 (default)metric = external only (constant)internal cost ignoredE1metric = external + internal costprefers the nearest ASBR

5. The seed metric — redistribution needs a starting cost

Metrics do not translate across protocols: an OSPF cost means nothing to BGP’s MED, and a BGP path means nothing to OSPF’s cost. So redistribution assigns a seed metric — the metric the route starts with in the new protocol. Into OSPF you set the external cost (and E1/E2 type); into BGP the IGP metric can become the MED. Leave it unset and you may get a protocol default that is either unreachable or wildly wrong, so always set it deliberately.

Seed metricNET BY MEinto OSPFset external cost + E1/E2into BGPIGP metric -> MED (optional)seed

6. Admin distance decides who wins a tie

When the same prefix is learned by more than one protocol, the router installs the one with the lowest administrative distance. The relevant values here: eBGP 20, OSPF 110, iBGP 200. That eBGP (20) beats OSPF (110) is exactly what makes mutual redistribution dangerous — a route you sent out via BGP can come back and be preferred over the original OSPF route, silently. Knowing the AD order is how you predict, and prevent, that.

Administrative distanceNET BY MEeBGPAD 20OSPFAD 110iBGPAD 200Lowest AD wins — eBGP (20) beats OSPF (110), the root of feedback loops

7. Mutual redistribution and the feedback loop

Redistribute both ways at two or more boundary routers and you create a path for a route to leave OSPF, traverse BGP, and re-enter OSPF at another ASBR with a better administrative distance — so the router believes the external copy and a loop or black hole forms. This is the single most important failure mode of two-way redistribution, and it is entirely predictable from the AD values above.

The mutual-redistribution loopNET BY MEASBR 1ASBR 2OSPF route -> BGPcomes back via BGP (AD 20) and winsThe re-learned external route beats the original -> loop / black hole

8. Route tags — the standard defense

The clean fix is route tagging. When a route is redistributed from OSPF into BGP, tag it; at every boundary that redistributes back into OSPF, deny any route carrying that tag. The route can never return to the protocol it came from, so the loop cannot close. Tags are protocol-neutral 32-bit values that survive redistribution, which is exactly why they are the textbook mechanism — pair them with prefix filtering and one-way redistribution wherever the design allows.

Route tags break the loopNET BY MEOSPF -> BGPtag = 100BGP -> OSPFdeny tag 100loop brokenroute cannot return

Takeaways

OSPF-BGP redistribution is two asymmetric directions, external LSAs with an E1/E2 metric type, a mandatory seed metric, and an administrative-distance order (eBGP 20 < OSPF 110) that makes two-way redistribution loop-prone by default. Tag on the way out, deny the tag on the way back, filter to exactly the prefixes intended, and redistribute one-way wherever you can — and the edge stays stable.

Mokrane ASSAM

Comments are closed.