This tutorial explains the BGP synchronization rule. To understand what this is all about, make sure you understand why we need IBGP first. If you are a little fuzzy about IBGP, BGP split horizon and why we need IBGP full mesh adjacencies then please read my IBGP tutorial first. Having said that, let’s look at the synchronization rule.
BGP synchronization is an old rule from the days where we didn’t run IBGP on all routers within a transit AS. In short, BGP will not advertise something that it learns from an IBGP neighbor to an EBGP neighbor if the prefix can’t be validated in its IGP.
It’s best explained with an example, take a look below:
Above we see 5 routers and 3 autonomous systems. When we want to get from R1 to R5 we’ll have to cross AS2, this makes AS2 our transit AS.
EBGP has been configured between R1/R2 and also between R4/R5. IBGP is configured between R2/R4 and R3 on top doesn’t run BGP at all.
The routers within AS2 are configured with OSPF, this is required since R2/R4 have to be able to reach each other to establish the IBGP session.
R1 will advertise a prefix in BGP, AS2 and AS3 will learn about this prefix…
Let me show you the configurations. We’ll use the topology from above but I added some IP addresses to it:
OSPF Configuration
The OSPF configuration is really straight-forward. R2 and R4 have a loopback interface that is used for the IBGP peering which is advertised in OSPF:
R2#
router ospf 1
network 2.2.2.0 0.0.0.255 area 0
network 192.168.23.0 0.0.0.255 area 0
R3#
router ospf 1
network 3.3.3.0 0.0.0.255 area 0
network 192.168.23.0 0.0.0.255 area 0
network 192.168.34.0 0.0.0.255 area 0
R4#
router ospf 1
network 4.4.4.0 0.0.0.255 area 0
network 192.168.34.0 0.0.0.255 area 0
Let me also show you the BGP configuration…
BGP Configuration
The configuration of R1 is simple, it’s configured to run EBGP with R2 and it advertises network 1.1.1.0 /24 into BGP:
R1#
router bgp 1
no synchronization
bgp log-neighbor-changes
network 1.1.1.0 mask 255.255.255.0
neighbor 192.168.12.2 remote-as 2
no auto-summary
R2 runs EBGP with R1 and IBGP with R4:
R2#
router bgp 2
no synchronization
bgp log-neighbor-changes
neighbor 4.4.4.4 remote-as 2
neighbor 4.4.4.4 update-source Loopback0
neighbor 4.4.4.4 next-hop-self
neighbor 192.168.12.1 remote-as 1
no auto-summary
R4 is similar to R2:
R4#
router bgp 2
no synchronization
bgp log-neighbor-changes
neighbor 2.2.2.2 remote-as 2
neighbor 2.2.2.2 update-source Loopback0
neighbor 2.2.2.2 next-hop-self
neighbor 192.168.45.5 remote-as 3
no auto-summary
And finally R5, it only runs EBGP with R4:
R5#show run | b router bgp
router bgp 3
no synchronization
bgp log-neighbor-changes
neighbor 192.168.45.4 remote-as 2
no auto-summary
By default, BGP synchronization is disabled. You can see the no synchronization command in the configurations of the routers above. Let’s take a “before” and “after” look..
BGP synchronization disabled
We’ll take a look at R4 and R5, see if they learned about the 1.1.1.0 /24 network which is advertised on R1 and forwarded by R2 through IBGP:
R4#show ip bgp
BGP table version is 10, local router ID is 4.4.4.4
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*>i1.1.1.0/24 2.2.2.2 0 100 0 1 i
R4 knows about this prefix and installed it…what about R5?
R5#show ip bgp
BGP table version is 6, local router ID is 5.5.5.5
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 1.1.1.0/24 192.168.45.4 0 2 1 i
Great, R5 also knows about this network. The problem in this scenario however is that we will never get any IP packets from AS3 to AS1 since R3 doesn’t run BGP…it will never learn about network 1.1.1.0 /24 so whenever R4 forwards something, it will be dropped. Take a look at R3 here:
R3#show ip route 1.1.1.0
% Network not in table
To synchronization rule was created to prevent this problem. Let’s find out how it works…
BGP synchronization enabled
Let me show you what happens when we enable it, you have to do this on the border routers (R2 and R4):
R2(config)#router bgp 2
R2(config-router)#synchronization
R4(config)#router bgp 2
R4(config-router)#synchronization
Take a look again at R4:
R4#show ip bgp
BGP table version is 11, local router ID is 4.4.4.4
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
* i1.1.1.0/24 2.2.2.2 0 100 0 1 i
R4 sees the network in its BGP table but refuses to install it.
This is because the synchronization rule states that the prefix has to be in its IGP before it can advertise it to an EBGP neighbor. Since R4 can’t install it, R5 will never learn about it:
This is because the synchronization rule states that the prefix has to be in its IGP before it can advertise it to an EBGP neighbor. Since R4 can’t install it, R5 will never learn about it:
R5#show ip bgp
So to fix this, you can either disable synchronization OR redistribute the prefix into your IGP (OSPF in our case). Let’s do that:
R2(config)#router ospf 1
R2(config-router)#redistribute bgp 2 route-map PREFIX subnets
R2(config)#route-map PREFIX permit 10
R2(config-route-map)#match ip address 1
R2(config)#access-list 1 permit 1.1.1.0 0.0.0.255
I am using a route-map to redistribute only this particular prefix, you don’t have to but you don’t want to accidently redistribute your entire BGP table into OSPF.
Because of the redistribution, R3 knows how to reach network 1.1.1.0 /24:
R3#show ip route 1.1.1.0
Routing entry for 1.1.1.0/24
Known via "ospf 1", distance 110, metric 1
Tag 1, type extern 2, forward metric 1
Last update from 192.168.23.2 on FastEthernet0/0, 00:00:41 ago
Routing Descriptor Blocks:
* 192.168.23.2, from 2.2.2.2, 00:00:41 ago, via FastEthernet0/0
Route metric is 1, traffic share count is 1
Route tag 1
According to the BGP synchronization rule, we are now allowed to advertise it to our EBGP neighbor. Take a look at R4:
R4#show ip bgp
BGP table version is 13, local router ID is 4.4.4.4
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
r>i 1.1.1.0/24 2.2.2.2 0 100 0 1 i
R4 selected this one as the best one. the “r” in front is there because this router will install the OSPF (AD 110) entry for 1.1.1.0 /24 instead of the IBGP (AD 200) route. What about R5?
R5#show ip bgp
BGP table version is 8, local router ID is 5.5.5.5
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 1.1.1.0/24 192.168.45.4 0 2 1 i
R5 once again learned the prefix from R4.
hostname R1
!
ip cef
!
interface Loopback0
ip address 1.1.1.1 255.255.255.0
!
interface FastEthernet0/0
ip address 192.168.12.1 255.255.255.0
!
router bgp 1
bgp log-neighbor-changes
network 1.1.1.0 mask 255.255.255.0
neighbor 192.168.12.2 remote-as 2
!
end
hostname R2
!
ip cef
!
interface Loopback0
ip address 2.2.2.2 255.255.255.0
!
interface FastEthernet0/1
ip address 192.168.23.2 255.255.255.0
!
router ospf 1
redistribute bgp 2 subnets route-map PREFIX
network 2.2.2.0 0.0.0.255 area 0
network 192.168.23.0 0.0.0.255 area 0
!
router bgp 2
synchronization
bgp log-neighbor-changes
neighbor 4.4.4.4 remote-as 2
neighbor 4.4.4.4 update-source Loopback0
neighbor 4.4.4.4 next-hop-self
neighbor 192.168.12.1 remote-as 1
!
access-list 1 permit 1.1.1.0 0.0.0.255
!
route-map PREFIX permit 10
match ip address 1
!
end
hostname R3
!
ip cef
!
interface Loopback0
ip address 3.3.3.3 255.255.255.0
!
interface FastEthernet0/0
ip address 192.168.23.3 255.255.255.0
!
interface FastEthernet0/1
ip address 192.168.34.3 255.255.255.0
!
router ospf 1
network 3.3.3.0 0.0.0.255 area 0
network 192.168.23.0 0.0.0.255 area 0
network 192.168.34.0 0.0.0.255 area 0
!
end
hostname R4
!
ip cef
!
interface Loopback0
ip address 4.4.4.4 255.255.255.0
!
interface FastEthernet0/0
ip address 192.168.34.4 255.255.255.0
!
router ospf 1
network 4.4.4.0 0.0.0.255 area 0
network 192.168.34.0 0.0.0.255 area 0
!
router bgp 2
synchronization
bgp log-neighbor-changes
neighbor 2.2.2.2 remote-as 2
neighbor 2.2.2.2 update-source Loopback0
neighbor 2.2.2.2 next-hop-self
neighbor 192.168.45.5 remote-as 3
!
end
hostname R5
!
ip cef
!
interface Loopback0
ip address 5.5.5.5 255.255.255.0
!
router bgp 3
bgp log-neighbor-changes
neighbor 192.168.45.4 remote-as 2
!
end
That’s all there is to it! I hope this was helpful for you to understand the BGP synchronization rule. If you have any questions, please leave a comment.
No comments:
Post a Comment