BGP Path Attributes
ccnp-routing
Overview of the BGP best path selection order and a lab that uses local preference to steer an autonomous system toward a preferred exit point.
Unlike IGPs, BGP needs to choose one and only one route as best, in part because BGP advertises only best routes to its neighbor.
BGP Best Path Algorithm:
- Next hop: is reachable? if not, that path will be set aside.
- Bigger Weight: It is not a PA. It is a Cisco feature. Since it is not a PA, it is not advertised in BGP updates. Hence the scope is on inbound route updates and influences only that one router’s choice.
- Bigger LOCAL_PREF
- Locally injected routes: locally injected is better than iBGP/eBGP
- shorter AS_PATH (default in BGP)
- Origin: i>e>?
- i: network command. In aggregation if as_set is not used; if as_set is used and all subnets use origin code
i. andneighbor default-originatecommand - e: egp (no longer exists)
- ?: redistribution. In aggregation if as_set is used and at least one subnets uses origin code
?. anddefault information originatecommand
- Smaller MED:
- Neighbor type: eBGP > iBGP
- Smaller IGP metric to next hop:
- Oldest eBGP route
- Lowest neighbor BGP RID
- Lowest neighbor IP address
Some of the BGP best path steps purposefully give the engineer a tool for influencing the choice of best path.
- Popular to influence outbound routes
- Weight
- Local preference
- AS_PATH
- Popular to influence inbound routes
- MED
Local Preference
- It is a path attribute. Hence we can advertise it (not to eBGP but to iBGP).
- gives the routers inside a single AS a value that they can set per-route and advertise to all iBGP routers inside the AS to agree about the best exit point.
- As our AS routers decide the exit points, it is in iBGP scope, not in eBGP.
- Default is 100, the higher the better.
- We can change the default using
bgp default local-preference <0-4294967295>BGP subcommand. - Configuration:
neighbor route-mapcommand withinoption for updates from an eBGP peer.
Scenario
In our scenario, the best AS to work on is 64500 where we have R2 and R3 as exit points. Currently R2 is selected to reach network 45.45.45.0/24 for R1 and R3.R1#show ip bgp 45.45.45.0/24 longer-prefixes
BGP table version is 14, local router ID is 1.1.1.1
Network Next Hop Metric LocPrf Weight Path
*>i 45.45.45.0/24 2.2.2.2 0 100 0 64510 i
R3#show ip bgp 45.45.45.0/24 longer-prefixes
BGP table version is 15, local router ID is 3.3.3.3
Network Next Hop Metric LocPrf Weight Path
*>i 45.45.45.0/24 2.2.2.2 0 100 0 64510 i
* 6.6.6.6 0 64520 64510 i
R3 wants R1 and R2 to agree that it is the better preference to reach network 45.45.45.0/24.
R3(config)#ip prefix-list Local_pref_200 seq 10 permit 45.45.45.0/24 R3(config)#route-map RmLP200 permit 10 R3(config-route-map)#match ip address prefix-list Local_pref_200 R3(config-route-map)#set local-preference 200 R3(config-route-map)#exit R3(config)#route-map RmLP200 permit 20 R3(config-route-map)#exit R3(config)#router bgp 64500 R3(config-router)#neighbor 6.6.6.6 route-map RmLP200 in R3(config-router)#end R3#clear ip bgp 6.6.6.6 softLet us verify on R1
R1#show ip bgp 45.45.45.0/24 longer-prefixes
BGP table version is 15, local router ID is 1.1.1.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,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
*>i 45.45.45.0/24 3.3.3.3 0 200 0 64520 64510 i
* i 2.2.2.2 0 100 0 64510 i
Let us see the result in R2. In R2 weight is 60 (configured in the previous 06_04 file). Local preference is 200. Because weight is before local preference in the bestpath selection order, R2 chose R4 to reach 45.45.45.0/24
R2#show ip bgp 45.45.45.0/24 longer-prefixes
BGP table version is 8, local router ID is 2.2.2.2
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,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
* i 45.45.45.0/24 3.3.3.3 0 200 0 64520 64510 i
* 5.5.5.5 0 50 64510 i
*> 4.4.4.4 0 60 64510 i