BGP Attributes


AS-Path

We can use AS-Path attribute to influence choice of paths in another AS. Since routers chose the path with the shortest AS-Path, using set as-path prepend command can be used to add additional values of originating AS so the receiving router will choose the router with the least AS-path value.

We can use a route-map to assign AS-path value.

R1(config)#route-map NET permit
R1(config-route-map)#match ip add
R1(config-route-map)#match ip address 1
R1(config-route-map)#set as
R1(config-route-map)#set as-path pre
R1(config-route-map)#set as-path prepend 100 100 100 100
R1(config-route-map)#exit
R1(config)#route-map NET permit 20   

R1(config-router)#neighbor 10.1.12.4 route-map NET out

Now let's look at the output of this on the receiving router

R2#sh ip bgp
BGP table version is 7, 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
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*>i1.0.0.0          10.1.14.1                0    100      0 100 i
*                   10.1.12.1                0             0 100 100 100 100 i
*> 2.0.0.0          0.0.0.0                  0         32768 i
*>i3.0.0.0          10.1.23.3                0    100      0 i
*>i4.0.0.0          10.1.34.4                0    100      0 i
* i11.0.0.0         10.1.14.1                0    100      0 100 i
*>                  10.1.12.1                0             0 100 i

Local-Pref

We can use Local-Pref to influence outbound path selection. If you have two exit points out of a BGP AS, you can assign the higher local-pref value to the path that you want to prefer. Highest local-pref will always be the preferred path out. Unlike the weight attribute, the local-pref attribute is propagated through out the local AS.

Here is a output of the show ip bgp command before any changes:

R3#sh ip bgp
BGP table version is 6, local router ID is 3.3.3.3
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.0.0.0          10.1.14.1                0    100      0 100 i
*>i                 10.1.12.1                0    100      0 100 i

We can use route-map to set the local-pref value:

route-map TST1 permit 10
 match ip address 1
 set local-preference 500
!        
route-map TST1 permit 20

Here is an output after I made the change:

R3#sh ip bgp
BGP table version is 10, local router ID is 3.3.3.3
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.0.0.0          10.1.14.1                0    500      0 100 i

Weight

 The weight attribute is a Cisco-defined attribute that is local to a router. this attribute is NOT advertised to any BGP neighbor. Higher weight is a preferred value.

You can configure the weight for all the routes entering from a neighbor by using the neighbor command:

R1(config)#router bgp 100
R1(config-router)#neighbor 10.1.12.2 weight 555

R1#sh ip bgp
BGP table version is 17, local router ID is 11.1.1.1
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.0.0.0          0.0.0.0                  0         32768 i
*> 2.0.0.0          10.1.12.2                0           555 200 i
*  3.0.0.0          10.1.14.4                              0 400 300 i
*>                  10.1.12.2                            555 200 300 i
*> 4.0.0.0          10.1.14.4                0             0 400 i
*> 11.0.0.0         0.0.0.0                  0         32768 i
*> 22.0.0.0         10.1.12.2                0           555 200 i
*  33.0.0.0         10.1.14.4                              0 400 300 i
*>                  10.1.12.2                            555 200 300 i

You can also assign weight per prefix basis by using route-maps/ACLS:

R1(config)#route-map TST permit
R1(config-route-map)#match ip address 33
R1(config-route-map)#set weight 6060
R1(config-route-map)#exit
R1(config)#route-map TST permit 20
R1(config-route-map)#match ip address 4
R1(config-route-map)#set weight 6060
R1(config-route-map)#exit
R1(config)#route-map TST permit 30

R1(config-router)#neighbor 10.1.14.4 route-map TST in

Here is the output after making the changes:

R1#sh ip bgp
BGP table version is 8, local router ID is 11.1.1.1
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.0.0.0          0.0.0.0                  0         32768 i
*> 2.0.0.0          10.1.12.2                0         54000 200 i
*                   10.1.14.4                              0 400 300 200 i
*> 3.0.0.0          10.1.12.2                          54000 200 300 i
*                   10.1.14.4                              0 400 300 i
*  4.0.0.0          10.1.12.2                            555 200 300 400 i
*>                  10.1.14.4                0          6060 400 i
*> 11.0.0.0         0.0.0.0                  0         32768 i
*> 22.0.0.0         10.1.12.2                0         54000 200 i
*                   10.1.14.4                              0 400 300 200 i
*  33.0.0.0         10.1.12.2                            555 200 300 i
*>                  10.1.14.4                           6060 400 300 i

 MED (Multi Exit Discriminator)

MED can also be used to influence path selection for the other AS. If the routers in other AS are using attributes (such as weight) that are compared before MED, then this won't work. Lower MED value is preferred.

Here is an output before any changes:

R1#sh ip bgp
BGP table version is 8, local router ID is 11.1.1.1
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.0.0.0          0.0.0.0                  0         32768 i
*  2.0.0.0          10.1.14.4                              0 200 i
*>                  10.1.12.2                0             0 200 i
*  3.0.0.0          10.1.14.4                              0 200 i
*>                  10.1.12.2                              0 200 i
*  4.0.0.0          10.1.12.2                              0 200 i
*>                  10.1.14.4                0             0 200 i
*> 11.0.0.0         0.0.0.0                  0         32768 i
*  22.0.0.0         10.1.14.4                              0 200 i
*>                  10.1.12.2                0             0 200 i
*  33.0.0.0         10.1.14.4                              0 200 i
*>                  10.1.12.2                              0 200 i

We can use route-maps to configure MED:

R4(config)#route-map TST permit
R4(config-route-map)#match ip address 3
R4(config-route-map)#set metric 444
R4(config-route-map)#exit
R4(config)#route-map TST permit 20

R4(config-router)#neighbor 10.1.14.1 route-map TST out

Here is the output after MED was changed:

R1#sh ip bgp
BGP table version is 8, local router ID is 11.1.1.1
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.0.0.0          0.0.0.0                  0         32768 i
*  2.0.0.0          10.1.12.2                0             0 200 i
*>                  10.1.14.4                              0 200 i
*> 3.0.0.0          10.1.12.2                              0 200 i
*                   10.1.14.4              444             0 200 i
*  4.0.0.0          10.1.12.2                              0 200 i
*>                  10.1.14.4                0             0 200 i
*> 11.0.0.0         0.0.0.0                  0         32768 i
*  22.0.0.0         10.1.12.2                0             0 200 i
*>                  10.1.14.4                              0 200 i
*  33.0.0.0         10.1.12.2              222             0 200 i
*>                  10.1.14.4                              0 200 i

Missing MED value

The Internet Engineering Task Force (IETF) decision regarding BGP MED assigns a value of infinity to the missing MED, making the route that lacks the MED variable the least preferred. The default behavior of BGP routers that run Cisco IOS software is to treat routes without the MED attribute as having a MED of 0, making the route that lacks the MED variable the most preferred. To configure the router to conform to the IETF standard, use the bgp bestpath med missing-as-worst router configuration command.

R1#sh ip bgp
BGP table version is 18, local router ID is 11.1.1.1
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.0.0.0          0.0.0.0                  0         32768 i
*> 2.0.0.0          10.1.12.2                0             0 200 i
*                   10.1.14.4              100             0 400 300 200 i
*> 3.0.0.0          10.1.12.2       4294967295             0 200 300 i
*                   10.1.14.4              100             0 400 300 i
*> 4.0.0.0          10.1.12.2       4294967295             0 200 300 400 i
*                   10.1.14.4              100             0 400 i
*> 11.0.0.0         0.0.0.0                  0         32768 i
*> 22.0.0.0         10.1.12.2                0             0 200 i
*                   10.1.14.4              100             0 400 300 200 i
*> 33.0.0.0         10.1.12.2       4294967295             0 200 300 i
*                   10.1.14.4              100             0 400 300 i

 

Leave a Reply

You must be logged in to post a comment.