[---- OSPF Area 0, BGP AS 65001 ----][---------- BGP AS 65002 ----------]
R1 ----- R2 ----- R3 (ASBR) ----- R4 ----- R5
Lo:1 Lo:2 Lo:3 Lo:4 Lo:5
OSPF + eBGP iBGP --- iBGP
R1-R2: 10.12.12.0/24
R2-R3: 10.23.23.0/24
R3-R4: 10.34.34.0/24 (eBGP, 65001 ↔ 65002)
R4-R5: 10.45.45.0/24 (iBGP)
Out of the box everything establishes (OSPF neighbors, BGP neighbors), but routes don't cross the boundary because no redistribution is configured. Configure mutual redistribution on R3 such that ping 5.5.5.5 source 1.1.1.1 from R1 and ping 1.1.1.1 source 5.5.5.5 from R5 both succeed.
This should all just work — no fixing needed.
show ip ospf neighbor — expect R2 in FULL state.show ip ospf neighbor — expect R1 and R3 both FULL.show ip ospf neighbor — expect R2 in FULL.show ip route ospf — should show 1.1.1.1/32 and 2.2.2.2/32 as O routes.show ip bgp summary — expect R4 (10.34.34.4) Established with one prefix received.show ip bgp summary — expect both R3 and R5 Established.show ip bgp summary — expect R4 Established.show ip bgp — should see 4.4.4.4/32 (and only that).show ip route — should NOT see anything from the BGP side yet. Confirm.ping 5.5.5.5 source 1.1.1.1 — expect failure. This is your baseline.So OSPF routers learn about the BGP side.
router ospf 1
redistribute bgp 65001 subnets
show ip route ospf — no change expected (R3 already learns those via BGP).show ip route ospf — should now see 4.4.4.4/32 and 5.5.5.5/32 as O E2.show ip route ospf — same: O E2 routes for 4.4.4.4/32 and 5.5.5.5/32.ping 5.5.5.5 source 1.1.1.1 — still expect failure (return path isn't there yet).So BGP routers learn about the OSPF side.
router bgp 65001
redistribute ospf 1
show ip bgp — should now show 1.1.1.1/32, 2.2.2.2/32, and 3.3.3.3/32 as locally originated (> with origin code ? for incomplete).show ip bgp — should see 1.1.1.1/32, 2.2.2.2/32, 3.3.3.3/32 learned from 10.34.34.3.show ip bgp — same prefixes, learned from 10.45.45.4 (via iBGP).show ip route bgp — should show all three OSPF-side loopbacks installed.ping 5.5.5.5 source 1.1.1.1 — should succeed.ping 1.1.1.1 source 5.5.5.5 — should succeed.traceroute 5.5.5.5 source 1.1.1.1 — confirm path R1 → R2 → R3 → R4 → R5.subnets keyword: router ospf 1 then redistribute bgp 65001. Watch what happens (show ip route ospf on R1 — the /32s disappear because they're not classful boundary networks).subnets. Verify routes return.show ip ospf database external — see the Type-5 LSAs being injected.show ip bgp — note the origin code ? (incomplete) on redistributed routes versus i (IGP) on network-statement routes.router ospf 1 → redistribute bgp 65001 subnets metric-type 1.show ip route ospf — note the metric of 4.4.4.4/32 now includes the path cost to R3 plus the redistribution metric, instead of just the redistribution metric.1.1.1.1/32 into BGP (drop R2 and R3's loopbacks). Verify on R5.redistribute ospf 1 match internal external 1 external 2 instead of plain redistribute ospf 1 and explain to yourself when each match keyword matters.The pattern in both labs is the same and worth internalizing: observe → hypothesize → change one thing → verify → repeat. Don't fix three things at once or you won't know which fix did what.
show ip ospf neighbor
show ip ospf neighbor detail
show ip ospf interface
show ip ospf interface brief
show ip ospf
show ip ospf database
show ip ospf database external ! Type-5 LSAs (redistributed routes)
show ip ospf database router
show ip route ospf
show ip protocols ! confirms redistribute statements
show ip bgp summary
show ip bgp
show ip bgp <prefix>
show ip bgp neighbors <ip>
show ip bgp neighbors <ip> advertised-routes
show ip bgp neighbors <ip> routes
show ip route bgp
show ip protocols ! shows what's being redistributed in/out
show ip route ! look for code letters: O E1, O E2, B
show ip ospf database external ! confirms BGP routes are being injected
show ip bgp ! origin code "?" means redistributed in
ping <ip> source <loopback-or-interface>
traceroute <ip> source <loopback-or-interface>
clear ip ospf process ! prompts for confirmation
clear ip bgp <neighbor-ip> soft out
configure terminal
router ospf <process-id>
router-id <a.b.c.d>
passive-interface <interface>
passive-interface default
no passive-interface <interface>
! Modern style — per-interface
interface GigabitEthernet0/0
ip ospf <process-id> area <area-id>
! Legacy style — under the OSPF process
router ospf 1
network 10.12.12.0 0.0.0.255 area 0
router bgp <local-AS>
bgp log-neighbor-changes
neighbor <ip> remote-as <as>
neighbor <ip> update-source Loopback0
neighbor <ip> next-hop-self
network <prefix> mask <mask>
! BGP into OSPF — "subnets" is REQUIRED for non-classful prefixes
router ospf 1
redistribute bgp <as> subnets
redistribute bgp <as> subnets metric <cost>
redistribute bgp <as> subnets metric-type 1 ! E1 (cumulative cost)
redistribute bgp <as> subnets metric-type 2 ! E2 (default, redist cost only)
redistribute bgp <as> subnets route-map <name>
! OSPF into BGP
router bgp <as>
redistribute ospf <process-id>
redistribute ospf <process-id> match internal external 1 external 2
redistribute ospf <process-id> route-map <name>
bgp redistribute-internal ! needed only if redistributing iBGP-learned routes
! Permit only specific prefixes
ip prefix-list ALLOW-R1-LOOP seq 10 permit 1.1.1.1/32
route-map FILTER-OSPF-TO-BGP permit 10
match ip address prefix-list ALLOW-R1-LOOP
! Apply it
router bgp 65001
redistribute ospf 1 route-map FILTER-OSPF-TO-BGP
! On the way OUT — tag the redistributed routes
route-map TAG-INTO-OSPF permit 10
set tag 100
route-map BLOCK-TAGGED-INTO-BGP deny 10
match tag 100
route-map BLOCK-TAGGED-INTO-BGP permit 20
router ospf 1
redistribute bgp 65001 subnets route-map TAG-INTO-OSPF
router bgp 65001
redistribute ospf 1 route-map BLOCK-TAGGED-INTO-BGP
end
copy running-config startup-config
! or shorthand:
wr
| Code | Meaning |
|---|---|
C | Connected |
L | Local (the interface IP itself) |
S | Static |
O | OSPF intra-area |
O IA | OSPF inter-area |
O E1 | OSPF external Type 1 — cost increases as the route propagates |
O E2 | OSPF external Type 2 (default) — cost stays at the redistributed value |
B | BGP (could be iBGP or eBGP — admin distance differs: 200 vs 20) |
| Code | Meaning |
|---|---|
i | IGP — route was originated by a network statement |
e | EGP — legacy, rarely seen |
? | Incomplete — route was learned via redistribution (this is what you'll see on R3 after redistributing OSPF into BGP) |