3.7.d Implement, Optimize and Troubleshoot Routing Policies
3.7d(i) Attribute Manipulation
The BGP Path attributes can be manipulated to influence the BGP best path decision. In short, the BGP best path selection process is based on the following items:
- Largest WEIGHT attribute.
- Largest LOCAL_PREF attribute.
- Locally originated routes (Next hop 0.0.0.0 in the BGP RIB).
- Shortest AS_PATH attribute.
- Best route ORIGIN attribute: IGP, EGP, INCOMPLETE.
- Lowest MED attribute.
- EBGP routes are preferred over IBGP routes (and also have lower administrative distance).
- The oldest route first (older routes are more stable).
- The path that originated from the router with the lowest BGP router ID.
- If the router is a route reflector, the lowest CLUSTER_ID attribute length.
- Routes received from the peer with the lowest IP address.
The BGP path attributes can be altered in a number of ways to modify BGP routing on a Cisco router—using route maps, attribute maps, prefix lists, AS path access lists, regular expressions, and more.
More information about the BGP path attributes: On The Table: BGP Path Attributes.
Let's look at some common ways to manipulate the BGP path attributes.
Manipulating the WEIGHT
- WEIGHT is a Cisco proprietary attribute.
- Only locally significant. Not advertised to any BGP peers.
- WEIGHT values range from 0 to 65,535.
- Paths that the router originates have a WEIGHT of 32,768 by default, and other paths have a WEIGHT of 0.
- A higher WEIGHT is preferred.
Per neighbor.
router bgp 100
neighbor 1.1.1.1 weight 100
Selectively per route(s). Note: private IP addresses are normally filtered in BGP (only used as an example here).
ip prefix-list RFC1918 seq 10 permit 10.0.0.0/8
ip prefix-list RFC1918 seq 20 permit 172.16.0.0/12
ip prefix-list RFC1918 seq 20 permit 192.168.0.0/16
!
route-map WEIGHT-100 permit 10
match ip address prefix-list RFC1918
set weight 100
route-map WEIGHT-100 permit 20
!
router bgp 100
neighbor 1.1.1.1 route-map WEIGHT-100 in
Manipulating the LOCAL PREFERENCE
- The concept is similar to WEIGHT.
- Range 0-4294967295.
- Advertised within the local AS.
- A higher local preference value is preferred.
Apply a local preference of 200 to RFC 1918 defined private IP address ranges. Note: private IP addresses are normally filtered in BGP (only used as an example here).
ip prefix-list RFC1918 seq 10 permit 10.0.0.0/8
ip prefix-list RFC1918 seq 20 permit 172.16.0.0/12
ip prefix-list RFC1918 seq 30 permit 192.168.0.0/16
!
route-map LP-200 permit 10
match ip address prefix-list RFC1918
set local-preference 200
route-map LP-200 permit 20
router bgp 100
neighbor 150.1.2.2 route-map LP-200 out
The result.
R2#show ip bgp
BGP table version is 28, local router ID is 150.1.2.2
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
*>i10.0.0.0 150.1.3.3 0 200 0 i
*>i172.16.0.0/12 150.1.3.3 0 200 0 i
*>i192.0.2.0 150.1.3.3 0 100 0 100 i
*>i192.168.0.0/16 150.1.3.3 0 200 0 i
*>i198.51.100.0 150.1.3.3 0 100 0 100 i
*>i203.0.113.0 150.1.3.3 0 100 0 100 i
Manipulating the AS_PATH
- The local AS number is prepended into the AS_PATH attribute when the route is advertised to external BGP peers.
- The AS_PATH attribute is a common tie breaker for Internet routes. By default, a route received from two ISPs and the preceding attributes unmodified, the AS_PATH length is the deciding factor.
- A shorter AS_PATH length is preferred.
- Multiple AS numbers can be manually forced into the AS_PATH, making the length longer and the route less preferred for inbound traffic.
Before manipulation.
R2#show ip bgp
BGP table version is 4, local router ID is 150.1.2.2
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
*> 192.0.2.0 150.1.1.1 0 0 100 i
*> 198.51.100.0 150.1.1.1 0 0 100 i
*> 203.0.113.0 150.1.1.1 0 0 100 i
The configuration. Prepend {100 100} into the AS_PATH for RFC 5737 defined public subnets.
ip prefix-list RFC5737 seq 10 permit 192.0.2.0/24
ip prefix-list RFC5737 seq 20 permit 198.51.100.0/24
ip prefix-list RFC5737 seq 30 permit 203.0.113.0/24
!
route-map AS-ADD permit 10
match ip prefix-list RFC5737
set as-path 100 100
route-map AS-ADD permit 20
!
router bgp 100
no synchronization
neighbor 150.1.2.2 remote-as 200
neighbor 150.1.2.2 update-source Loopback0
neighbor 150.1.2.2 ebgp-multihop 2
neighbor 150.1.2.2 route-map AS-ADD out
network 192.0.2.0
network 198.51.100.0
network 203.0.113.0
no auto-summary
After manipulation.
R2#show ip bgp
BGP table version is 7, local router ID is 150.1.2.2
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
*> 192.0.2.0 150.1.1.1 0 0 100 100 100 i
*> 198.51.100.0 150.1.1.1 0 0 100 100 100 i
*> 203.0.113.0 150.1.1.1 0 0 100 100 100 i
Manipulating the MED
- The MED attribute is advertised to external peers to influence incoming traffic.
- The neighbor AS propagates the MED within its local AS but does not advertise it outside the AS.
- A lower MED is preferred.
- The MED attribute is commonly referred to as the BGP metric.
Adding to the configuration from the previous example. Advertise the routes to BGP neighbor 150.1.2.2 with a MED of 50.
route-map AS-ADD permit 10
match ip address prefix-list RFC5737
set metric 50
set as-path prepend 100 100
!
router bgp 100
neighbor 150.1.2.2 route-map AS-ADD out
Add R3 to AS 200. Do not manipulate any attributes.
router bgp 100
neighbor 150.1.3.3 remote-as 200
neighbor 150.1.3.3 ebgp-multihop 2
neighbor 150.1.3.3 update-source Loopback0
The result. R2 learns the routes from both R1 (EBGP) and R3 (IBGP; next-hop-self).
R2#show ip bgp
BGP table version is 22, local router ID is 150.1.2.2
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
*>i192.0.2.0 150.1.3.3 0 100 0 100 i
* 150.1.1.1 50 0 100 100 100 i
*>i198.51.100.0 150.1.3.3 0 100 0 100 i
* 150.1.1.1 50 0 100 100 100 i
*>i203.0.113.0 150.1.3.3 0 100 0 100 i
* 150.1.1.1 50 0 100 100 100 i
No comments:
Post a Comment