BGP Best Path Selection Lab
In this lab, we will be demonstrating BGP best path selection process practically. As this lab is based on Cisco BGP best path selection process, there will be total 13 steps involved here. Please refer to Cisco documentations for more information and you can always read RFC documents to solidify your knowledge and they are available for free. I have to be creative to demonstrate all the best path selection process. Like many other programming languages, and firewalls, BGP also read from top to bottom. This mean that if there is a match found with "Weight" attribute, it won't go any further and select the path as best. If it is not it will continue to the next steps and son on. I used Cisco C8000v images with EVE-NG in this lab.
R-1 Configuration
hostname R-1
!
interface Loopback0
ip address 1.1.1.1 255.255.255.255
ip ospf 1 area 0
!
interface GigabitEthernet1
ip address 172.16.3.1 255.255.255.0
ip ospf 1 area 0
no shutdown
!
interface GigabitEthernet3
ip address 172.16.2.1 255.255.255.0
no shutdown
!
interface GigabitEthernet4
ip address 172.16.0.1 255.255.255.0
ip ospf 1 area 0
no shutdown
!
router ospf 1
router-id 1.1.1.1
!
router bgp 1000
bgp router-id 1.1.1.1
neighbor 172.16.0.3 remote-as 1000
neighbor 172.16.0.3 description R-3
neighbor 172.16.0.3 next-hop-self
neighbor 172.16.2.2 remote-as 1000
neighbor 172.16.2.2 description R-2
neighbor 172.16.2.2 next-hop-self
neighbor 172.16.3.4 remote-as 2000
neighbor 172.16.3.4 description R-4
!
ip prefix-list R3-Subnets seq 5 permit 192.168.31.0/24
ip prefix-list R3-Subnets seq 10 permit 192.168.32.0/24
ip prefix-list R3-Subnets seq 15 permit 192.168.33.0/24
ip prefix-list R3-Subnets seq 20 permit 192.168.34.0/24
!
route-map R3-Subnets permit 10
match ip address prefix-list R3-Subnets
set ip next-hop self
R-2 Configuration
hostname R-2
!
interface Loopback0
ip address 2.2.2.2 255.255.255.255
ip ospf 1 area 0
!
interface GigabitEthernet1
ip address 172.16.4.2 255.255.255.0
ip ospf 1 area 0
no shutdown
!
interface GigabitEthernet2
ip address 172.16.1.2 255.255.255.0
ip ospf 1 area 0
no shutdown
!
interface GigabitEthernet3
ip address 172.16.2.2 255.255.255.0
no shutdown
!
interface GigabitEthernet5
ip address 172.16.5.2 255.255.255.0
ip ospf 1 area 0
no shutdown
!
router ospf 1
router-id 2.2.2.2
!
router bgp 1000
bgp router-id 2.2.2.2
neighbor 172.16.1.3 remote-as 1000
neighbor 172.16.1.3 description R-3
neighbor 172.16.1.3 next-hop-self
neighbor 172.16.2.1 remote-as 1000
neighbor 172.16.2.1 description R-1
neighbor 172.16.2.1 next-hop-self
neighbor 172.16.4.5 remote-as 2000
neighbor 172.16.4.5 description R-5
neighbor 172.16.5.13 remote-as 3000
neighbor 172.16.5.13 description R-13
R-3 Configuration
hostname R-3
!
interface Loopback0
ip address 3.3.3.3 255.255.255.255
ip ospf 1 area 0
!
interface Loopback1
ip address 192.168.31.1 255.255.255.0
ip ospf 1 area 0
!
interface Loopback2
ip address 192.168.32.1 255.255.255.0
ip ospf 1 area 0
!
interface Loopback3
ip address 192.168.33.1 255.255.255.0
ip ospf 1 area 0
!
interface Loopback4
ip address 192.168.34.1 255.255.255.0
ip ospf 1 area 0
!
interface GigabitEthernet2
ip address 172.16.1.3 255.255.255.0
ip ospf 1 area 0
no shutdown
!
interface GigabitEthernet4
ip address 172.16.0.3 255.255.255.0
ip ospf 1 area 0
no shutdown
!
router ospf 1
router-id 3.3.3.3
!
router bgp 1000
bgp router-id 3.3.3.3
network 3.3.3.3 mask 255.255.255.255
redistribute connected route-map R3-Subnets
neighbor 172.16.0.1 remote-as 1000
neighbor 172.16.0.1 description R-1
neighbor 172.16.1.2 remote-as 1000
neighbor 172.16.1.2 description R-2
!
ip prefix-list R3-Subnets seq 5 permit 192.168.31.0/24
ip prefix-list R3-Subnets seq 10 permit 192.168.32.0/24
ip prefix-list R3-Subnets seq 15 permit 192.168.33.0/24
ip prefix-list R3-Subnets seq 20 permit 192.168.34.0/24
!
route-map R3-Subnets permit 10
match ip address prefix-list R3-Subnets
R-4 Configuration
hostname R-4
!
interface Loopback0
ip address 4.4.4.4 255.255.255.255
!
interface GigabitEthernet1
ip address 172.16.3.4 255.255.255.0
no shutdown
!
interface GigabitEthernet4
ip address 172.16.6.4 255.255.255.0
no shutdown
!
router bgp 2000
bgp router-id 4.4.4.4
neighbor 172.16.3.1 remote-as 1000
neighbor 172.16.3.1 description R-1
neighbor 172.16.6.13 remote-as 3000
neighbor 172.16.6.13 description R-13
R-5 Configuration
hostname R-5
!
interface Loopback0
ip address 5.5.5.5 255.255.255.255
!
interface GigabitEthernet1
ip address 172.16.4.5 255.255.255.0
no shutdown
!
interface GigabitEthernet3
ip address 172.16.7.5 255.255.255.0
no shutdown
!
router bgp 2000
bgp router-id 5.5.5.5
neighbor 172.16.4.2 remote-as 1000
neighbor 172.16.4.2 description R-2
neighbor 172.16.7.13 remote-as 3000
neighbor 172.16.7.13 description R-13
R-13 Configuration
hostname R-13
!
interface Loopback0
ip address 13.13.13.13 255.255.255.255
ip ospf 1 area 0
!
interface GigabitEthernet2
ip address 172.16.9.13 255.255.255.0
ip ospf 1 area 0
no shutdown
!
interface GigabitEthernet3
ip address 172.16.7.13 255.255.255.0
ip ospf 1 area 0
no shutdown
!
interface GigabitEthernet4
ip address 172.16.6.13 255.255.255.0
ip ospf 1 area 0
no shutdown
!
interface GigabitEthernet5
ip address 172.16.5.13 255.255.255.0
ip ospf 1 area 0
no shutdown
!
interface GigabitEthernet6
ip address 172.16.8.13 255.255.255.0
ip ospf 1 area 0
no shutdown
!
router ospf 1
router-id 13.13.13.13
!
router bgp 3000
bgp router-id 13.13.13.13
neighbor 172.16.5.2 remote-as 1000
neighbor 172.16.5.2 description R-2
neighbor 172.16.6.4 remote-as 2000
neighbor 172.16.6.4 description R-4
neighbor 172.16.7.5 remote-as 2000
neighbor 172.16.7.5 description R-5
neighbor 172.16.8.9 remote-as 3000
neighbor 172.16.8.9 description RR-9
neighbor 172.16.9.10 remote-as 3000
neighbor 172.16.9.10 description RR-10
RR-9 Configuration
hostname RR-9
!
interface Loopback0
ip address 9.9.9.9 255.255.255.255
ip ospf 1 area 0
!
interface GigabitEthernet1
ip address 172.16.11.9 255.255.255.0
ip ospf 1 area 0
no shutdown
!
interface GigabitEthernet6
ip address 172.16.8.9 255.255.255.0
ip ospf 1 area 0
no shutdown
!
router ospf 1
router-id 9.9.9.9
!
router bgp 3000
bgp router-id 9.9.9.9
neighbor RR9-PEER-GROUP peer-group
neighbor RR9-PEER-GROUP remote-as 3000
neighbor RR9-PEER-GROUP cluster-id 9.9.9.9
neighbor RR9-PEER-GROUP route-reflector-client
neighbor 172.16.8.13 peer-group RR9-PEER-GROUP
neighbor 172.16.8.13 description R-13
neighbor 172.16.11.8 peer-group RR9-PEER-GROUP
neighbor 172.16.11.8 description RR-8
RR-8 Configuration
hostname RR-8
!
interface Loopback0
ip address 8.8.8.8 255.255.255.255
ip ospf 1 area 0
!
interface GigabitEthernet1
ip address 172.16.11.8 255.255.255.0
ip ospf 1 area 0
no shutdown
!
interface GigabitEthernet2
ip address 172.16.10.8 255.255.255.0
ip ospf 1 area 0
no shutdown
!
router ospf 1
router-id 8.8.8.8
!
router bgp 3000
bgp router-id 8.8.8.8
neighbor RR8-PEER-GROUP peer-group
neighbor RR8-PEER-GROUP remote-as 3000
neighbor RR8-PEER-GROUP cluster-id 8.8.8.8
neighbor RR8-PEER-GROUP route-reflector-client
neighbor 172.16.10.6 peer-group RR8-PEER-GROUP
neighbor 172.16.10.6 description RR-6
neighbor 172.16.11.9 peer-group RR8-PEER-GROUP
neighbor 172.16.11.9 description RR-9
RR-6 Configuration
hostname RR-6
!
interface Loopback0
ip address 6.6.6.6 255.255.255.255
ip ospf 1 area 0
!
interface GigabitEthernet2
ip address 172.16.10.6 255.255.255.0
ip ospf 1 area 0
no shutdown
!
interface GigabitEthernet4
ip address 172.16.12.6 255.255.255.0
ip ospf 1 area 0
no shutdown
!
router ospf 1
router-id 6.6.6.6
!
router bgp 3000
bgp router-id 6.6.6.6
neighbor RR6-PEER-GROUP peer-group
neighbor RR6-PEER-GROUP remote-as 3000
neighbor RR6-PEER-GROUP cluster-id 6.6.6.6
neighbor RR6-PEER-GROUP route-reflector-client
neighbor 172.16.10.8 peer-group RR6-PEER-GROUP
neighbor 172.16.10.8 description RR-8
neighbor 172.16.12.11 peer-group RR6-PEER-GROUP
neighbor 172.16.12.11 description R-11
R-11 Configuration
hostname R-11
!
interface Loopback0
ip address 11.11.11.11 255.255.255.255
ip ospf 1 area 0
!
interface GigabitEthernet1
ip address 172.16.15.11 255.255.255.0
ip ospf 1 area 0
no shutdown
!
interface GigabitEthernet4
ip address 172.16.12.11 255.255.255.0
ip ospf 1 area 0
no shutdown
!
router ospf 1
router-id 11.11.11.11
!
router bgp 3000
bgp router-id 11.11.11.11
neighbor 172.16.12.6 remote-as 3000
neighbor 172.16.12.6 description RR-6
neighbor 172.16.12.6 next-hop-self
neighbor 172.16.15.14 remote-as 4000
neighbor 172.16.15.14 description R-14
RR-10 Configuration
hostname RR-10
!
interface Loopback0
ip address 10.10.10.10 255.255.255.255
ip ospf 1 area 0
!
interface GigabitEthernet1
ip address 172.16.13.10 255.255.255.0
ip ospf 1 area 0
no shutdown
!
interface GigabitEthernet2
ip address 172.16.9.10 255.255.255.0
ip ospf 1 area 0
no shutdown
!
router ospf 1
router-id 10.10.10.10
!
router bgp 3000
bgp router-id 10.10.10.10
neighbor RR10-PEER-GROUP peer-group
neighbor RR10-PEER-GROUP remote-as 3000
neighbor RR10-PEER-GROUP cluster-id 10.10.10.10
neighbor RR10-PEER-GROUP route-reflector-client
neighbor 172.16.9.13 peer-group RR10-PEER-GROUP
neighbor 172.16.9.13 description R-13
neighbor 172.16.13.7 peer-group RR10-PEER-GROUP
neighbor 172.16.13.7 description RR-7
RR-7 Configuration
hostname RR-7
!
interface Loopback0
ip address 7.7.7.7 255.255.255.255
ip ospf 1 area 0
!
interface GigabitEthernet1
ip address 172.16.13.7 255.255.255.0
ip ospf 1 area 0
no shutdown
!
interface GigabitEthernet3
ip address 172.16.14.7 255.255.255.0
ip ospf 1 area 0
no shutdown
!
router ospf 1
router-id 7.7.7.7
!
router bgp 3000
bgp router-id 7.7.7.7
neighbor RR7-PEER-GROUP peer-group
neighbor RR7-PEER-GROUP remote-as 3000
neighbor RR7-PEER-GROUP cluster-id 7.7.7.7
neighbor RR7-PEER-GROUP route-reflector-client
neighbor 172.16.13.10 peer-group RR7-PEER-GROUP
neighbor 172.16.13.10 description RR-10
neighbor 172.16.14.12 peer-group RR7-PEER-GROUP
neighbor 172.16.14.12 description R-12
R-12 Configuration
hostname R-12
!
interface Loopback0
ip address 12.12.12.12 255.255.255.255
ip ospf 1 area 0
!
interface GigabitEthernet2
ip address 172.16.16.12 255.255.255.0
ip ospf 1 area 0
no shutdown
!
interface GigabitEthernet3
ip address 172.16.14.12 255.255.255.0
ip ospf 1 area 0
no shutdown
!
router ospf 1
router-id 12.12.12.12
!
router bgp 3000
bgp router-id 12.12.12.12
neighbor 172.16.14.7 remote-as 3000
neighbor 172.16.14.7 description R-7
neighbor 172.16.14.7 next-hop-self
neighbor 172.16.16.14 remote-as 4000
neighbor 172.16.16.14 description R-14
R-14 Configuration
hostname R-14
!
interface Loopback0
ip address 14.14.14.14 255.255.255.255
!
interface GigabitEthernet1
ip address 172.16.15.14 255.255.255.0
no shutdown
!
interface GigabitEthernet2
ip address 172.16.16.14 255.255.255.0
no shutdown
!
router bgp 4000
bgp router-id 14.14.14.14
network 14.14.14.14 mask 255.255.255.255
neighbor 172.16.15.11 remote-as 3000
neighbor 172.16.15.11 description R-11
neighbor 172.16.16.12 remote-as 3000
neighbor 172.16.16.12 description R-12
1. Using Weight to influence BGP AS Path Selection
Weight is only for Cisco routers, and it is only local to router. Let's assign weight to choose the R-1 path.
route-map WEIGHT permit 10
set weight 65535
!
router bgp 1000
neighbor 172.16.0.1 description R-1
neighbor 172.16.0.1 route-map WEIGHT in
!
do clear ip bgp * soft
Now you will see that the R-1 path will be preferred over R-2 path despite having longer AS path list. The highest weight is usually preferred.
When you set higher "Weight" on a prefix received from a particular neighbor (i.e., incoming update), you are telling the router that all the traffic destined to that particular prefix must use this path towards the particular neighbor (i.e., outgoing traffic).
2. Using Local Preference to Influence BGP Best Path Selection
Before we start, let's remove the weight configuration from R-3. And also clear the BGP process.
no route-map WEIGHT
!
router bgp 1000
no neighbor 172.16.0.1 route-map WEIGHT in
!
do clear ip bgp * soft
Local preference is propagated inside the AS and as usual the highest value is preferred. So, let's configure from R-1. Local preference is well-known discretionary value, and it is only applicable to IBGP (Internal BGP). So, we applied when the route is coming "in" from neighbor "172.16.3.4".
route-map LOCAL-PREFERENCE permit 10
set local-preference 500
!
router bgp 1000
neighbor 172.16.3.4 route-map LOCAL-PREFERENCE in
!
do clear ip bgp * soft
Now, go to R-3 and check the best-path. You will see that the Local Preference is propagated to R-3 and R-1 route is preferred due to highest local preference.
When you set higher "Local Preference" on a prefix received from a particular neighbor (i.e., incoming update), you are telling the IBGP neighbors that all the traffic destined to that particular prefix must use this specific path towards the particular neighbor (i.e., outgoing traffic).
3. BGP Preferring Locally Generated Routes via Network Command, Redistribution or Aggregation
Before this process begin, let's remove the Local Preference Configuration from previous steps.
no route-map LOCAL-PREFERENCE
!
router bgp 1000
no neighbor 172.16.3.4 route-map LOCAL-PREFERENCE in
!
do clear ip bgp * soft
BGP preference for locally generated route is applicable to local router only. When we manually inject routes via network command, it marks the route with Origin IGP attribute. To manually inject the route "14.14.14.14/32" via network command first we need to configure a route pointing to Null 0. You can also use "redistribute static" with route map as well.
ip route 14.14.14.14 255.255.255.255 Null0
!
router bgp 1000
network 14.14.14.14 mask 255.255.255.255
!
do clear ip bgp * soft
After that you will only see locally generate route "14.14.14.14/32" taking preference over the routes learn from other BGP neighbors.
Since, this is only local to the router, there will not be any impact on IBGP or EBGP neighbors. We will talk about the Origin Code later.
4. Using AS Path to Influence BGP Best Path Selection
Before we do anything, let's remove all the previous configuration from R-1.
no ip route 14.14.14.14 255.255.255.255 Null0
!
router bgp 1000
network 14.14.14.14 mask 255.255.255.255
!
do clear ip bgp * soft
AS Path is one of the well-known mandatory BGP attributes, and BGP will prefer the prefix with shortest AS path. We do not need to configure anything here to see this because R-2 has the direct link to R-13 (AS 3000) and it is obviously a shorter path if you look at the topology diagram.
It is usually not a good idea to configure AS path prepend while advertising internal Public IP addresses to ISPs. Nonetheless, let's take a look at how we can set via route-map.
Before we configure AS path, let's verify the current R-13 path selection towards 14.14.14.14/32. Now the path towards R-10 is being preferred due to "Longer cluster length" for now.
We will configure AS Path prepends at R-14 and see how it affects the R-13 path selection.
ip prefix-list R-14-Loopback permit 14.14.14.14/32
!
route-map AS-PATH
match ip address prefix-list R-14-Loopback
set as-path prepend 4000 4001 4002 4003
!
router bgp 4000
neighbor 172.16.15.11 route-map AS-PATH out
!
do clear ip bgp * soft
You will see the now R-13 is preferring the path towards R-9 because of shorter AS Path.
5. Using Origin Code to Influence BGP Best Path Selection
Before we continue, let's perform housekeeping here at R-14
router bgp 4000
no neighbor 172.16.15.11 route-map AS-PATH out
!
no ip prefix-list R-14-Loopback seq 5 permit 14.14.14.14/32
!
no route-map AS-PATH permit 10
!
do clear ip bgp * soft
Usually when a BGP prefix is configured with network command, it marked the prefix with "Origin IGP". But when you redistribute the routes using redistribute commands, it marks the prefix with "Origin Incomplete". The other EGP is obsolete so I would not bother mentioning here. Usually, Origin IGP is preferred over Incomplete. Let's try to redistribute routes into BGP by using redistribution on R-3.
ip prefix-list R3-Subnets seq 5 permit 192.168.31.0/24
ip prefix-list R3-Subnets seq 10 permit 192.168.32.0/24
ip prefix-list R3-Subnets seq 15 permit 192.168.33.0/24
ip prefix-list R3-Subnets seq 20 permit 192.168.34.0/24
!
route-map R3-Subnets permit 10
match ip address prefix-list R3-Subnets
!
router bgp 1000
redistribute connected route-map R3-Subnets
!
If you check the prefix "192.168.31.0/24", you will see that it is marked with "Origin incomplete".
Let's configure the same routes with network command without removing the previous configuration.
router bgp 1000
network 192.168.31.0 mask 255.255.255.0
network 192.168.32.0 mask 255.255.255.0
network 192.168.33.0 mask 255.255.255.0
network 192.168.34.0 mask 255.255.255.0
This time when you check the prefix, you will see that it is marked with "Origin IGP".
Now, let's configure aggregation on R-1 and see what's happen on R-4 regarding the Origin Code.
router bgp 1000
aggregate-address 192.168.0.0 255.255.0.0 summary-only
After aggregation, you will see the individual prefixes status code change to "s>" saying that the prefixes are suppressed.
Now let's check the summary (aggregated) prefix at the R-4. You will see that it is marked with "Origin IGP".
领英推荐
Now you got the idea of how BGP got these Origin Attributes. These attributes can also be set manually using the route-map command as well. We can try setting the origin incomplete at R-2. We will also be shutting down R-2 Gi5 interface, so the AS path becomes equal for both R-1 and R-2.
route-map ORIGIN-CODE permit 10
set origin incomplete
We will also remove the aggregation on R-1.
router bgp 1000
no aggregate-address 192.168.0.0 255.255.0.0 summary-only
!
do clear ip bgp * soft
When we check the prefixes in R-13, you will see that the prefix from R-4 learned via R-1 is being preferred because it was learned 11 seconds earlier (making this older and stable prefix).
Now, go to R-5 and set Origin Code to IGP so that it is preferred over the prefix learned from R-4.
ip prefix-list R3-Subnets seq 5 permit 192.168.31.0/24
ip prefix-list R3-Subnets seq 10 permit 192.168.32.0/24
ip prefix-list R3-Subnets seq 15 permit 192.168.33.0/24
ip prefix-list R3-Subnets seq 20 permit 192.168.34.0/24
!
route-map ORIGIN-CODE permit 10
set origin igp
match ip address prefix-list R3-Subnets
!
router bgp 2000
neighbor 172.16.7.13 route-map ORIGIN-CODE out
!
do clear ip bgp * soft
If we go and check at R-13 again, you will see that the path from R-4 is no longer being preferred due to "Origin incomplete".
Remember Origin is a well-known mandatory attribute so it can pass to other IBGP or EBGP peers and it can be used for both incoming and outgoing updates.
6. Using MED to Influence BGP Best Path Selection
Let's remove the previous configuration from R-5 before we continue.
router bgp 2000
no neighbor 172.16.7.13 route-map ORIGIN-CODE out
!
no route-map ORIGIN-CODE permit 10
!
no ip prefix-list R3-Subnets seq 5 permit 192.168.31.0/24
no ip prefix-list R3-Subnets seq 10 permit 192.168.32.0/24
no ip prefix-list R3-Subnets seq 15 permit 192.168.33.0/24
no ip prefix-list R3-Subnets seq 20 permit 192.168.34.0/24
!
do clear ip bgp * soft
MED is an optional non-transitive attribute. Using MED to Influence BGP Best Path Selection only makes sense if the two paths are coming from the same AS, and they use the same internal routing protocol as OSPF or EIGRP. Also, the two AS must be adjacent.
Currently, if we perform traceroute from R-3 to 14.14.14.14/32 you will see that it is taking the path from RR-10.
At R-14, we can set higher metric to so that it will prefer the path from RR-9.
ip prefix-list R-14-Loopback permit 14.14.14.14/32
!
route-map MED
set metric 10000
!
router bgp 4000
neighbor 172.16.16.12 route-map MED out
!
do clear ip bgp * soft
Now, the path through RR-6 is preferred even-though the path is longer.
You can also check the BGP routing table entry at R-13 to see why it is preferred because AS3000 is using OSPF as IGP for all the routers.
7. BGP Best Path Selection - EBGP Over IBGP
As usual, let's remove previous configuration from R-14.
router bgp 4000
no neighbor 172.16.16.12 route-map MED out
!
no route-map MED
!
no ip prefix-list R-14-Loopback seq 5 permit 14.14.14.14/32
!
do clear ip bgp * soft
EBGP routes are generally preferred over IBGP routes because of the lower administrative distance. Another reason is that the EBGP is more scalable than IBGP and it is easier for policy control. EBGP routes have AD value of 20 and IBGP routes have AD value of 200.
Let's create a link between R-1 and R-2 to demonstrate this and form IBGP neighborship between R-1 and R-2.
#R-1 Configuration
interface GigabitEthernet3
ip address 172.16.2.1 255.255.255.0
no shutdown
!
router bgp 1000
neighbor 172.16.2.2 remote-as 1000
neighbor 172.16.2.2 description R-2
neighbor 172.16.2.2 next-hop-self
#R-2 Configuration
interface GigabitEthernet3
ip address 172.16.2.2 255.255.255.0
no shutdown
!
router bgp 1000
neighbor 172.16.2.1 remote-as 1000
neighbor 172.16.2.1 description R-1
neighbor 172.16.2.1 next-hop-self
Now, we have 14.14.14.14/32 received from internal neighbor at R-1. Let's verify the best path reason on R-1.
8. BGP Best Path Selection Using IGP Metric
BGP will prefer the path with lowest IGP metric to the next hop. This is obvious from R-13 point of view while learning 14.14.14.14/32. The path towards RR-10 has lesser OSPF metric because it has to pass the traffic via 3 links or 3 routers to deliver the traffic while the paths towards RR-9 has higher OSPF metric because it has to pass the traffic via 4 links or 4 routers.
You can manipulate OSPF metric using "ip ospf cost" command to manipulate the best path selection. Now, let's set OSPF cost to RR-10 Gi1 interface.
interface Gi1
ip ospf cost 65534
Now, you will see that the path toward R-9 is being preferred.
This only applies to IBGP neighbors as OSPF or EIGRP is not run with other AS.
9. BGP Best Path Selection BGP Multipath
Let's remove previous configuration on RR-10
interface Gi1
no ip ospf cost 65534
The next step for BGP is to check if the BGP multipath is required. So, let's go to R-3 and create BGP Multipath.
router bgp 1000
maximum-paths eibgp 2
You will see Status Codes "m" saying that the path is used for BGP multipath. Please note that the BGP multipath will not be installed if the path does not match the following criteria.
These criteria match for 14.14.14.14/32 from R-3 since we have shutdown R-2 Gi5 link.
How BGP will perform load balancing is totally depends on Cisco CEF (Cisco Express Forwarding) and it is not defined in BGP.
Now, let's do the trace route and verify that the traffic is being load balanced.
You can also use this for EBGP as well. So, this applies to both EBGP and IBGP.
10. BGP Best Path Selection - Oldest Path
Now, let's remove the BGP multipath configuration from R-3 and let's advertise R-3 Loopback 0 on BGP.
router bgp 1000
no maximum-paths ibgp 2
network 3.3.3.3 mask 255.255.255.255
!
do clear ip bgp * soft
Now, let's check the prefix 3.3.3.3/32 at R-13, you will see that the path from R-4 is being preferred over the bath from R-5 because R-1 path is 59 second older (meaning it was received earlier that the R-4 routes).
If you want to change just do BGP hard reset using "clear ip bgp *" on the oldest path router. It will reset the uptime making the other path favorable. This will usually be a tie breaker for EBGP because this preference is only applicable to EBGP, and it will be one in the 14 million possibilities that the BGP router received the same prefix at the exact time (we are talking about seconds or milliseconds here).
11. BGP Best Path Selection - Lowest Router ID
As I explained earlier, it is extremely rare for EBGP paths to reach this step of the path selection process. So, I went to R-3 and see the best path selection process based on "Lowest Router ID".
Well, it is simple to influence this process, just adjust the router ID with "bgp router-id" command.
12. BGP Best Path Selection - Minimum Cluster List Length
Well, I designed this lab to demonstrate so if you look at the topology diagram, I added three route reflectors in RR Cluster 1 and two route reflectors in RR Cluster 2. However, we have OSPF configured, so we need to issue additional command in R-13 to demonstrate this.
router bgp 3000
bgp bestpath igp-metric ignore
BGP will prefer the path with minimum cluster list length. When a BGP prefix is reflected from one RR, the cluster list attribute is added along with cluster ID. When it is reflected by another RR router, it will add another cluster ID to the list. So, cluster list length is a representation of how many RRs the particular prefix has pass through. So, cluster list serves two purposes: loop prevention and path selection.
Well, it is not possible to add one more cluster member and manipulate the path selection. You can add one or two RRs to influence the best path selection. But does it worth it and why will we do this? We can play with other attributes for sure unless all the other attributes cease to exist.
13. BGP Best Path Selection - Lowest Neighbor IP Address/Peer IP Address
Now, we reached the final judgement day for the BGP prefix. Let's configure the same router ID on R-2 as 1.1.1.1 to demonstrate this.
router bgp 1000
bgp router-id 1.1.1.1
Now, if you check on R-3 that the BGP best path selection factor is changed to peer IP address. In this case R-1 has the lowest peer IP address and preferred as the best route.
I hope this lab is information for you. I would love to hear comments from experts.
Sales Manager | IT | Telecommunication | BSS | OSS
4 个月Vishel, I hope you are doing fine. First of all, thanks for your lab and contribution. I would like to suggest you in some future moment to add the static routes as an alternative to create new subnets and advertise it as well. In my ISP experience we had to create subnets to load balance different links with different bandwidth in the backbone?and to provide to the CPEs new IP address pool. Anyway, I could remember some BGP attributes reproducing your lab. I really appreciate it!
Network Engineer and System Administrator - Cisco Certified Network Professional Enterprise (Encor+Enarsi) - Still Learning...CCNP Service Provider and DataCenter technologies in progress. Thinking in CCIE.
4 个月Interesting! ??
Thanks for sharing this lab! Practical examples like these are so valuable for understanding BGP path selection. Do you have any tips for troubleshooting common issues that arise during the BGP best path selection process?