← Back to portfolio

Lab 02 — BGP/OSPF Mutual Redistribution

Topology

[---- 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)

Goal

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.

Setup

Verify the Base State

This should all just work — no fixing needed.

Step 1 — Redistribute BGP into OSPF

So OSPF routers learn about the BGP side.

Step 2 — Redistribute OSPF into BGP

So BGP routers learn about the OSPF side.

Step 3 — End-to-End Test

Step 4 — Observe and Understand

Step 5 — Metric Experiments

Bonus (only if you have time)

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.

Verification Command Reference

OSPF state

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

BGP state

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

Redistribution-specific checks

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

Connectivity test

ping <ip> source <loopback-or-interface>
traceroute <ip> source <loopback-or-interface>

Forcing a refresh after redistribution change

clear ip ospf process                    ! prompts for confirmation
clear ip bgp <neighbor-ip> soft out

Basic Config Command Reference

OSPF process

configure terminal
router ospf <process-id>
 router-id <a.b.c.d>
 passive-interface <interface>
 passive-interface default
 no passive-interface <interface>

Activate OSPF on an 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

BGP process and neighbors

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>

Redistribution — the key commands for this lab

! 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

Route-map for filtering redistribution (bonus task)

! 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

Route-map with tags (loop prevention with two ASBRs)

! 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

Save the config

end
copy running-config startup-config
! or shorthand:
wr

Route Code Quick Reference

CodeMeaning
CConnected
LLocal (the interface IP itself)
SStatic
OOSPF intra-area
O IAOSPF inter-area
O E1OSPF external Type 1 — cost increases as the route propagates
O E2OSPF external Type 2 (default) — cost stays at the redistributed value
BBGP (could be iBGP or eBGP — admin distance differs: 200 vs 20)

BGP Origin Codes Quick Reference

CodeMeaning
iIGP — route was originated by a network statement
eEGP — legacy, rarely seen
?Incomplete — route was learned via redistribution (this is what you'll see on R3 after redistributing OSPF into BGP)