Redistribution between OSPF & BGP
Redistribution between OSPF & BGP
A routing protocol is a set of rules that routers use to communicate and share information with each other. This information helps them determine the best path to send data packets across a network to their final destination.What is Redistribution ?
Redistribution is the process of exchanging routing information across different routing protocols. It effectively allows routers to share network paths learned through one protocol with other protocols connected to the same router.
Redistribution allows a router to take routes learned from one protocol and advertise them to other routing protocols running on the same router. This enables networks utilizing different protocols to share information with each other.
Where can we do Redistribution ?
Redistribution can be done
- Between routing protocols (RIP, OSPF, EIGRP, BGP).
- Static routes can be redistributed into a routing protocol.
- Directly connected routes can be redistributed into a routing protocol.
⭐Related : BGP Cheat Sheet for Network Engineers
⭐Related : 51 facts about BGP routing Protocol for Network Engineers
⭐Related : Introduction to Redistribution
⭐Related : 51 facts about BGP routing Protocol for Network Engineers
⭐Related : Introduction to Redistribution
Redistribution Scenario
In our lab scenario, we are going to do redistribution between OSPF and BGP protocol. We have 11 routers but we will talk about the redistribution between Router R1 and Router R2 basically.
Fig 1.1- Redistribution between OSPF & BGP |
The redistribution happens on Router R2 as on one side it is connected to OSPF and on other interface it is connected to BGP.
Redistribution Scenario 1
Only OSPF intra-area and inter-area routes are redistributed into BGP by default if you configure OSPF redistribution into BGP without keywords. To redistribute OSPF Intra and Inter-area routes, use the internal keyword in conjunction with the redistribute command under router bgp.
hostname R2
!
interface GigabitEthernet0/0 (Towards Router R1)
ip address 20.20.20.1 255.255.255.252
duplex auto
speed auto
!
interface GigabitEthernet0/1 (Towards Router R3)
ip address 10.10.2.3 255.255.255.0
duplex auto
speed auto
!
interface GigabitEthernet0/2 (Towards Router R4)
ip address 10.10.2.5 255.255.255.0
duplex auto
speed auto
!
router ospf 1
network 10.10.2.0 0.0.0.255 area 1
!
router bgp 100
redistribute ospf 1
neighbor 10.3.3.2 remote-as 200
!
end
Now let's check what we are getting on the Router R2, You will see that Router R2 redistributes only OSPF Internal routes
R2# show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
a - application route
+ - replicated route, % - next hop override, p - overrides from PfR
Gateway of last resort is not set
10.0.0.0/8 is variably subnetted, 6 subnets, 2 masks
C 10.10.2.0/24 is directly connected, GigabitEthernet0/1
L 10.10.2.3/32 is directly connected, GigabitEthernet0/1
L 10.10.2.5/32 is directly connected, GigabitEthernet0/2
C 20.20.20.0/30 is directly connected, GigabitEthernet0/0
L 20.20.20.1/32 is directly connected, GigabitEthernet0/0
O IA 10.10.1.0/24 [110/3] via 10.2.2.2, 00:08:38, GigabitEthernet0/1
O 10.10.3.0/24 [110/2] via 10.2.2.2, 00:39:13, GigabitEthernet0/1
------------------------------------------BGP----------------------------------------------------------------
R2#show ip bgp
BGP table version is 12, local router ID is 20.20.20.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
x best-external, a additional-path, c RIB-compressed,
t secondary path,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
*> 10.10.2.0/24 0.0.0.0 0 32768 ?
*> 10.10.1.0/24 10.10.2.2 2 32768 ?
*> 10.10.3.0/24 10.10.2.2 3 32768 ?
R2#
Redistribution Scenario 2
To redistribute OSPF external routes into BGP, use the external keyword in conjunction with the redistribute command under router bgp. You have three options when it comes to the external keyword:
So now we are going to redistribute only OSPF External routes, but both Type-1 and Type-2
Redistribute Type-1
Redistribute Type-2
Redistribute both External Type-1 and Type-2 (Default)
So now we are going to redistribute only OSPF External routes, but both Type-1 and Type-2
hostname R2
!
interface GigabitEthernet0/0 (Towards Router R1)
ip address 20.20.20.1 255.255.255.252
duplex auto
speed auto
!
interface GigabitEthernet0/1 (Towards Router R3)
ip address 10.10.2.3 255.255.255.0
duplex auto
speed auto
!
interface GigabitEthernet0/2 (Towards Router R4)
ip address 10.10.2.5 255.255.255.0
duplex auto
speed auto
!
router ospf 1
network 10.10.2.0 0.0.0.255 area 1
!
router bgp 100
redistribute ospf 1 match external 1 external 2
neighbor 10.3.3.2 remote-as 200
!
end
As we match external 1 and external 2, So router R1 will learn all the external routes from Router R2. In our case we don't have any other external network connected to OSPF.
Redistribution Scenario 3
Similarly, you can redistribution of Only OSPF External Type 1 or Type 2 Routes into BGP
hostname R2
!
interface GigabitEthernet0/0 (Towards Router R1)
ip address 20.20.20.1 255.255.255.252
duplex auto
speed auto
!
interface GigabitEthernet0/1 (Towards Router R3)
ip address 10.10.2.3 255.255.255.0
duplex auto
speed auto
!
interface GigabitEthernet0/2 (Towards Router R4)
ip address 10.10.2.5 255.255.255.0
duplex auto
speed auto
!
router ospf 1
network 10.10.2.0 0.0.0.255 area 1
!
router bgp 100
redistribute ospf 1 match external 1
neighbor 10.3.3.2 remote-as 200
!
end
So here "redistribute ospf 1 match external 1 external 2" replaced with "redistribute ospf 1 match external 1"
We will talk another scenario where we will see OSPF NSSA area external routes in BGP. Hope the scenario helps you understand more on the redistribution between OSPF and BGP protocol.
Continue Reading...
- Why BGP-SRx is a Must-Have for Large Enterprises
- 51 facts about BGP routing Protocol for Network Engineers
- BGP Conditional Advertisement Feature
- Quick facts on BGP for interviews
- BGP Protocol : iBGP vs MP-iBGP protocol
- BGP : bgp deterministic-med and bgp always-compare-med
- BGP Attribute : AIGP-BGP Accumulative IGP
Free Tools...