05 · ospf ↔ bgp

OSPF and BGP Redistribution Visualization

X1 speaks eBGP to AS 65002 and OSPF to the backbone. BGP carries no cost and OSPF carries no AS path, so the border router applies a seed metric on the way in and an origin code on the way out. Switch redistribution on in either direction, choose E1 or E2 externals, set the seed metric and route tag, filter individual prefixes, and add a second border router to expose the redistribution loop.

AREA 1branchAREA 0 · BACKBONEAS 65001cost 1cost 11 Gbcost 1010 Mbcost 1cost 1eBGP 65001–65002B11.1.1.1ABR1.1.1.9ABRX110.0.0.11ASBRX210.0.0.12CORE10.0.0.10AS 65002eBGP neighbor
Highlighted cables are B1's path to the winning ASBR. Dashed links are eBGP sessions — no OSPF runs there.
  • path to the chosen ASBR
  • eBGP session
  • OSPF link, not on the path

Viewpoint

B1

External type

E2

Externals in table

2

ASBRs

X1

Routing table · B1

Externals sort last: O, O IA, O E1, then O E2.

PrefixCodeCostNext hopDetail
10.1.1.0/24O1connecteddirectly attached
10.0.10.0/24O IA4ABRB1 → ABR → X1 → CORE
10.0.11.0/24O IA3ABRB1 → ABR → X1
10.0.12.0/24O IA5ABRB1 → ABR → X1 → CORE → X2
198.51.100.0/24O E220 (E2 — internal cost to the ASBR is ignored)ABRtype 5 from X1
203.0.113.0/24O E220 (E2 — internal cost to the ASBR is ignored)ABRtype 5 from X1

Slide sideways to see the whole table.

ASBR selection

With E2, the metric ties and the internal cost decides.

PrefixASBRInternal costAdvertisedResult
203.0.113.0/24X1220installed
198.51.100.0/24X1220installed

Slide sideways to see the whole table.

Key point

With E2 both ASBRs advertise the identical metric 20. OSPF breaks the tie on the forward cost to the ASBR — and if that also ties, it installs both and load-shares. Switch to E1 and the arithmetic becomes visible in the cost column.

LSAs created by redistribution

Type 5 floods domain-wide; type 4 tells you how to reach the ASBR.

LSALink state IDAdvertising routerTypeMetricTagSeqAge
5 · AS external203.0.113.0/2410.0.0.11E220650020x8000013E1489s
5 · AS external198.51.100.0/2410.0.0.11E220650020x8000010E728s
4 · ASBR summary10.0.0.111.1.1.920x800001121672s

Slide sideways to see the whole table.

BGP table at AS 65002

What the neighbor sees when OSPF is redistributed outward.

PrefixAS pathOriginMEDTagState
OSPF → BGP is off, so AS 65002 learns nothing from us.

Slide sideways to see the whole table.

Key point

Redistributing OSPF into BGP advertises every internal prefix to the neighbor — including the ones you never meant to expose. In production this is a prefix list, not a bare redistribute ospf.

Configuration · Aruba AOS-CX

X1, matching exactly what is set on screen.

X1(config)# router bgp 65001
X1(config-bgp)#   neighbor 198.51.100.2 remote-as 65002
X1(config-bgp)#   address-family ipv4 unicast
X1(config-bgp-ipv4-uni)#     ! no redistribute ospf
!
X1(config)# router ospf 1
X1(config-ospf-1)#   default-metric 20
X1(config-ospf-1)#   redistribute bgp route-map BGP-TO-OSPF
!
X1(config)# route-map BGP-TO-OSPF permit seq 10
X1(config-route-map-BGP-TO-OSPF-10)#   match ip address prefix-list EXT-IN
X1(config-route-map-BGP-TO-OSPF-10)#   set metric 20
X1(config-route-map-BGP-TO-OSPF-10)#   set metric-type type-2
X1(config-route-map-BGP-TO-OSPF-10)#   set tag 65002
!
X1(config)# ip prefix-list EXT-IN seq 10 permit 203.0.113.0/24
X1(config)# ip prefix-list EXT-IN seq 20 permit 198.51.100.0/24
X1(config)# ip prefix-list EXT-IN seq 30 deny 192.0.2.0/24
!
X1(config)# route-map OSPF-TO-BGP permit seq 10   ! nothing blocks the tagged routes
!
X1# show ip ospf routes
X1# show ip ospf lsdb external
X1# show bgp ipv4 unicast

Key takeaways

Key point

Metrics do not translate. BGP has no concept of cost and OSPF has no concept of AS path, so the ASBR assigns a seed metric. Everything downstream trusts that invented number.

E2 is flat, E1 accumulates. E2 is the default: the same metric everywhere, which hides the distance to the exit. Use E1 when you want each router to pick its nearest border.

Tag on the way in, filter on the way out. Tags cost nothing, are carried in the type 5, and are the cleanest way to stop a route re-entering the protocol it came from.

Type 4 makes type 5 usable. A router in area 1 can read the external LSA but has no idea where X1 is until the ABR advertises the type 4 ASBR summary.