BGP Path Attributes I

The BGP path attributes are the characteristics for all BGP advertised routes. Additionally to the necessary informations to perform basic routing , the path attributes allow BGP to set routing policies and advertise them. Each attribute is a member of one of the following categories:

  • Well-known mandatory – This attribute has to be known and implemented by all BGP implementations
  • Well-known discretionary – This attribute has to be known by all BGP implementations, but does not have to be sent in an update message.
  • Optional transitive – This attribute does not have to be known by all BGP implementations but the BGP prozess has to accept the path within the attribute is found and forward it to other BGP peers, even though the BGP process doesnt know the attribute.
  • Optional non-transitive – An update with an attribute from this category can be ignored. The router does not have to advertise this route nor the path to its peers.

All examples in this document will use the following diagram

Origin

Category: well-known mandatory
Preference: lowest origin code – while IGP > EGP > incomplete

This attribute identifies the source of the route. Possible sources are:

  • Is the route from an IGP, the routing entry is marked in the BGP table with an ‘i’
  • Is the route from an external EGP, the routing entry is marked with an ‘e’.
  • Was the route redistributed into BGP, the origin informations are missing and the entry is marked with a ‘?’.

Origin configuration

At the moment the BGP table on R3 looks like this:

R3#sh ip bgp
BGP table version is 15, local router ID is 99.99.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
*> 99.99.1.0/24     116.1.13.1                      0                               0  12  i
*                                     116.1.23.2                                                       0  12  i
*> 99.99.2.0/24     116.1.13.1                                                        0  12  i
*                                     116.1.23.2                     0                                0  12  i
*> 99.99.3.0/24      0.0.0.0                          0                     32768  i

To prefer the direct path to R1s Loopack Interface, R3 will set the route 99.99.1.0/24 from R2 to incomplete, so it will prefer the route from R1.

router bgp 3
 no synchronization
 bgp log-neighbor-changes
 network 99.99.3.0 mask 255.255.255.0
 neighbor 116.1.13.1 remote-as 12
 neighbor 116.1.23.2 remote-as 12
 neighbor 116.1.23.2 route-map ORIGIN in
 no auto-summary
!
access-list 1 permit 99.99.1.0 0.0.0.255
!
route-map ORIGIN permit 10
 match ip address 1
 set origin incomplete
!
route-map ORIGIN permit 20

R3s BGP table now shows the change we made:

R3#sh ip bgp
BGP table version is 15, local router ID is 99.99.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
*> 99.99.1.0/24     116.1.13.1                     0                               0 12 i
*                                     116.1.23.2                                                      0 12 ?
*> 99.99.2.0/24     116.1.13.1                                                       0 12 i
*                                     116.1.23.2                    0                               0 12 i
*> 99.99.3.0/24     0.0.0.0                         0                     32768 i

AS_Path

Category: well-known mandatory
Preference: shortest path

This attributes includes a path of all AS’ a route has passed through. A router adds his own AS if the route is advertised to an eBGP peer. The first entry in the list is the last AS which the route has passed before it arrived in the current AS, while the last entry shows the originating AS. The AS_Path attribute is also used to detect loops, a loop is detected when a router receives a route from an eBGP peer with his own AS in the AS_Path. The attribute can be either sorted (AS_Sequence) or unsorted (AS_Set).
The so called as path prepending can be used to control which path traffic for a particular route will use. BGP will prefer the shortest AS_Path to a destination, so if we want to prefer one path over the other, we can add additional instances of our own AS to the AS_Path attribute before its advertised to an eBGP peer which tells BGP that the path is “longer” then it really is.

AS_Path prepending configuration

R3 receives from both R1 and R2 both of their loopback addresses:

R3#sh ip bgp
BGP table version is 4, local router ID is 99.99.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
*  99.99.1.0/24     116.1.23.2                                0 12 i
*>                  116.1.13.1                  0             0 12 i
*  99.99.2.0/24     116.1.13.1                                0 12 i
*>                  116.1.23.2                  0             0 12 i
*> 99.99.3.0/24     0.0.0.0                     0         32768 i

To show how as-prepending works, R3 shall use the path over R1 to reach R2s Loopback Interface and vice-versa. This is done with the above mentioned AS_Path prepending:

R1:
router bgp 12
 no synchronization
 bgp log-neighbor-changes
 network 99.99.1.0 mask 255.255.255.0
 neighbor 116.1.12.2 remote-as 12
 neighbor 116.1.13.3 remote-as 3
 neighbor 116.1.13.3 route-map To-R3 out
 no auto-summary
!
ip prefix-list Lo0 seq 5 permit 99.99.1.0/24
!
route-map To-R3 permit 10
 match ip address prefix-list Lo0
 set as-path prepend 12 12 12
!
route-map To-R3 permit 20

R2:
router bgp 12
 no synchronization
 bgp log-neighbor-changes
 network 99.99.2.0 mask 255.255.255.0
 neighbor 116.1.12.1 remote-as 12
 neighbor 116.1.23.3 remote-as 3
 neighbor 116.1.23.3 route-map To-R3 out
 no auto-summary
!
ip prefix-list Lo0 seq 5 permit 99.99.2.0/24
!
route-map To-R3 permit 10
 match ip address prefix-list Lo0
 set as-path prepend 12 12 12
!
route-map To-R3 permit 20

Both routes use the outbound Route-Map To-R3 to match their loopback addresses with an ip prefix-list called Lo0 and add three additional instances of their own AS to the Routes AS-Path. For R3 now the direct paths to the loopback addresses seem to be longer then the indirect path over the other router:

R3#sh ip bgp
BGP table version is 6, local router ID is 99.99.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
*> 99.99.1.0/24     116.1.23.2                             0 12 i
*                   116.1.13.1               0             0 12 12 12 12 i
*> 99.99.2.0/24     116.1.13.1                             0 12 i
*                   116.1.23.2               0             0 12 12 12 12 i
*> 99.99.3.0/24     0.0.0.0                  0         32768 i

As you can see, R3 now uses the path over R2 to reach R1’s Lo0 and vice-versa.

3 comments

  1. Noorullah

    sir
    my name is Noorullah. right now i put up in new delhi
    and i am searching for a institute to do my ccie in R/S
    i requsets from yours to send my the address of any institute to do my ccie course.

    thnxxxx

Leave a reply to David Cancel reply