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.
- 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.
| Prefix | Code | Cost | Next hop | Detail |
|---|---|---|---|---|
| 10.1.1.0/24 | O | 1 | connected | directly attached |
| 10.0.10.0/24 | O IA | 4 | ABR | B1 → ABR → X1 → CORE |
| 10.0.11.0/24 | O IA | 3 | ABR | B1 → ABR → X1 |
| 10.0.12.0/24 | O IA | 5 | ABR | B1 → ABR → X1 → CORE → X2 |
| 198.51.100.0/24 | O E2 | 20 (E2 — internal cost to the ASBR is ignored) | ABR | type 5 from X1 |
| 203.0.113.0/24 | O E2 | 20 (E2 — internal cost to the ASBR is ignored) | ABR | type 5 from X1 |
Slide sideways to see the whole table.
ASBR selection
With E2, the metric ties and the internal cost decides.
| Prefix | ASBR | Internal cost | Advertised | Result |
|---|---|---|---|---|
| 203.0.113.0/24 | X1 | 2 | 20 | installed |
| 198.51.100.0/24 | X1 | 2 | 20 | installed |
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.
| LSA | Link state ID | Advertising router | Type | Metric | Tag | Seq | Age |
|---|---|---|---|---|---|---|---|
| 5 · AS external | 203.0.113.0/24 | 10.0.0.11 | E2 | 20 | 65002 | 0x8000013E | 1489s |
| 5 · AS external | 198.51.100.0/24 | 10.0.0.11 | E2 | 20 | 65002 | 0x8000010E | 728s |
| 4 · ASBR summary | 10.0.0.11 | 1.1.1.9 | — | 2 | — | 0x80000112 | 1672s |
Slide sideways to see the whole table.
BGP table at AS 65002
What the neighbor sees when OSPF is redistributed outward.
| Prefix | AS path | Origin | MED | Tag | State |
|---|---|---|---|---|---|
| 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.