First I would like to make a quick review on BGP Best path selection process:
BGP assigns the
first valid path as the current best path. BGP then compares the best path with
the next path in the list, until BGP reaches the end of the list of valid
paths. This list provides the rules that are used to determine the best path:
- Prefer the
path with the highest WEIGHT.
- Prefer the
path with the highest local preference (default value is 100)
- Prefer the
path that was locally originated via a network or aggregate
BGP subcommand or through redistribution from an IGP.
Note: Local
paths that are sourced by the network or redistribute commands
are preferred over local aggregates that are sourced by the aggregate-address
command.
- Prefer the
path with the shortest AS_PATH.
- Prefer the
path with the lowest origin type.
Note: IGP is lower than EGP, and EGP is lower than
INCOMPLETE.
- Prefer the
path with the lowest MED
- Prefer eBGP
over iBGP paths.
- Prefer the
path with the lowest IGP metric to the BGP next hop.
- Determine if
multiple paths require installation in the routing table for BGP
Multipath.
- When both
paths are external, prefer the path that was received first (the oldest
one).
- Prefer the
route that comes from the BGP router with the lowest router ID.
- If the
originator or router ID is the same for multiple paths, prefer the path
with the minimum cluster list length.
- Prefer the
path that comes from the lowest neighbor address.
In the following
lab, R6 is adverting prefix 192.168.61.0/24, where R1 is learning this prefix from
R2, R3 and R5, which are all external BGP, peers (eBGP), and choose R5 as the
best path:
R1#sh ip bgp
192.168.61.0/24
BGP routing
table entry for 192.168.61.0/24, version 2
Paths: (3
available, best #3, table Default-IP-Routing-Table)
Flag: 0x820
Advertised to update-groups:
1
65005 65006
10.1.15.5 from 10.1.15.5 (10.1.56.5)
Origin IGP, localpref 100, valid,
external
65003 65004 65006
10.1.13.3 from 10.1.13.3 (10.1.34.3)
Origin IGP, localpref 100, valid, external
65002 65006
10.1.12.2 from 10.1.12.2 (2.2.2.2)
Origin IGP, localpref 100, valid,
external, best
|
So who R1 is
choose the best path?
R1 is
comparing R5 path to R3 path and using the BGP bets path process list he choose
the winner – in this case R5 due to rule no. 4.
Then compare
R5 path to R2 path – both have the same path characteristic and R2 is chosen as
the winner following rule no. 13.
If I will shut
down R2 the path from R5 will be the preferred one:
R1#
*Mar 4 18:10:55.145: %BGP-5-ADJCHANGE: neighbor
10.1.12.2 Down Peer closed the session
R1#show ip
bgp 192.168.61.0/24
BGP routing
table entry for 192.168.61.0/24, version 3
Paths: (2
available, best #1, table Default-IP-Routing-Table)
Flag: 0x820
Advertised to update-groups:
1
65005 65006
10.1.15.5 from 10.1.15.5 (10.1.56.5)
Origin IGP, localpref 100, valid,
external, best
65003 65004 65006
10.1.13.3 from 10.1.13.3 (10.1.34.3)
Origin IGP, localpref 100, valid,
external
|
But if I bring
back R2, it won’t change that, and R5 will continue to be the bets path:
R1#
*Mar 4 18:11:18.365: %BGP-5-ADJCHANGE: neighbor
10.1.12.2 Up
R1#sh ip bgp
192.168.61.0/24
BGP routing
table entry for 192.168.61.0/24, version 3
Paths: (3
available, best #2, table Default-IP-Routing-Table)
Flag: 0x820
Advertised to update-groups:
1
65002 65006
10.1.12.2 from 10.1.12.2 (2.2.2.2)
Origin IGP, localpref 100, valid,
external
65005 65006
10.1.15.5 from 10.1.15.5 (10.1.56.5)
Origin IGP, localpref 100, valid, external, best
65003 65004 65006
10.1.13.3 from 10.1.13.3 (10.1.34.3)
Origin IGP, localpref 100, valid,
external
|
The reason will
be rule no. 10 – the oldest learned path.
Now let’s
configure some metrics and these routers, showing R2 as an example:
R2(config)# ip
prefix-list PL_NET61 per 192.168.61.0/24
R2(config)#
route-map RM_R1 permit 10
R2(config-route-map)#
match ip address prefix-list PL_NET61
R2(config-route-map)#
set metric 1000
R2(config-route-map)#
exit
R2(config-route-map)#
route-map RM_R1 permit 20
R2(config-route-map)#
router bgp 65002
R2(config-router)#
neighbor 10.1.12.1 route-map RM_R1 out
|
R3 and R5
are configured with the same beside the metric which is 300 and 500 respectively.
After clearing
the BGP peers from R1:
R1#sh ip bgp 192.168.61.0/24
BGP routing table entry for
192.168.61.0/24, version 2
Paths: (3 available, best #3,
table Default-IP-Routing-Table)
Advertised to update-groups:
1
65003 65004 65006
10.1.13.3 from 10.1.13.3 (10.1.34.3)
Origin IGP, metric 300, localpref 100, valid,
external
65005 65006
10.1.15.5 from 10.1.15.5 (10.1.56.5)
Origin IGP, metric 500, localpref 100, valid,
external
65002 65006
10.1.12.2 from 10.1.12.2 (2.2.2.2)
Origin IGP, metric 1000, localpref 100, valid,
external, best
|
R2 is still
the best path although his metric is the highest among the peers, the reason is
that R1 isn’t comparing MED from peers from different AS’s (following rule no.
6). This comparison will occur only if the first (the neighboring) AS is the
same in the two paths.
So now let’s
configure R1 to compare the MED although it comes from different AS’s:
R1# conf t
Enter configuration
commands, one per line. End with
CNTL/Z.
R1(config)#router
bgp 65001
R1(config-router)#bgp
always-compare-med
|
Clear the
BGP neighbor list and look again on the BGP table:
R1#sh ip bgp 192.168.61.0/24
BGP routing table entry for
192.168.61.0/24, version 2
Paths: (3 available, best #3,
table Default-IP-Routing-Table)
Flag: 0x820
Advertised to update-groups:
1
65002 65006
10.1.12.2 from 10.1.12.2 (2.2.2.2)
Origin IGP, metric 1000, localpref 100,
valid, external
65003 65004 65006
10.1.13.3 from 10.1.13.3 (10.1.34.3)
Origin IGP, metric 300, localpref 100,
valid, external
65005 65006
10.1.15.5 from 10.1.15.5 (10.1.56.5)
Origin IGP, metric 500, localpref 100,
valid, external, best
|
In MED lower
is better but we can see that R5 has chosen as the best path although R3 has
much lower metric, the reason is rule no. 4 – AS_PATH, which comes before the rule
no. 6 -MED, and we can see that R3 as-path is much longer.
We can
configure R1 to ignore the AS_PATH attribute using a hidden command:
R1# conf t
Enter configuration
commands, one per line. End with
CNTL/Z.
R1(config)#router
bgp 65001
R1(config-router)#
bgp bestpath as-path ignore
|
This command
is hidden since IOS 12.4 but it’s still valid and we can use it.
Let’s clear
the BGP neighbors and look on R1 BGP table:
R1#sh ip bgp 192.168.61.0/24
BGP routing table entry for
192.168.61.0/24, version 2
Paths: (3 available, best #1,
table Default-IP-Routing-Table)
Flag: 0x820
Advertised to update-groups:
1
65003 65004 65006
10.1.13.3 from 10.1.13.3 (10.1.34.3)
Origin IGP, metric 300, localpref 100,
valid, external, best
65002 65006
10.1.12.2 from 10.1.12.2 (2.2.2.2)
Origin IGP, metric 1000, localpref 100,
valid, external
65005 65006
10.1.15.5 from 10.1.15.5 (10.1.56.5)
Origin IGP, metric 500, localpref 100,
valid, external
|
And we can
see that R3 is the best path to prefix 192.168.61.0/24.
Now let’s
remove the metric from R5 and see what’s happen:
R1#sh ip bgp 192.168.61.0/24
BGP routing table entry for
192.168.61.0/24, version 2
Paths: (3 available, best #1,
table Default-IP-Routing-Table)
Flag: 0x820
Advertised to update-groups:
1
65005 65006
10.1.15.5 from 10.1.15.5 (10.1.56.5)
Origin IGP, localpref 100, valid,
external, best
65003 65004 65006
10.1.13.3 from 10.1.13.3 (10.1.34.3)
Origin IGP, metric 300, localpref 100,
valid, external
65002 65006
10.1.12.2 from 10.1.12.2 (2.2.2.2)
Origin IGP, metric 1000, localpref 100,
valid, external
|
We can see
that R5 is the best path as paths received with no
MED are assigned a MED of 0 which is lower.
Issuing the following command:
R1# conf t
Enter configuration
commands, one per line. End with
CNTL/Z.
R1(config)#router
bgp 65001
R1(config-router)#
bgp bestpath med missing-as-worst
|
This command
will cause R1 to treat paths with no MED as worst and give them the worst MED
value available:
R1#sh ip bgp 192.168.61.0/24
BGP routing table entry for
192.168.61.0/24, version 2
Paths: (3 available, best #1,
table Default-IP-Routing-Table)
Flag: 0x820
Advertised to update-groups:
1
65003 65004 65006
10.1.13.3 from 10.1.13.3 (10.1.34.3)
Origin IGP, metric 300, localpref 100,
valid, external, best
65002 65006
10.1.12.2 from 10.1.12.2 (2.2.2.2)
Origin IGP, metric 1000, localpref 100,
valid, external
65005 65006
10.1.15.5 from 10.1.15.5 (10.1.56.5)
Origin IGP, metric 4294967295, localpref
100, valid, external
|
No comments:
Post a Comment