Saturday 16 June 2012

BGP Attributes: AS-PATH

BGP Attributes: AS-PATH

·         The AS-PATH is actually the list of AS numbers that a route has traversed in order to reach a destination.
·         By default, BGP takes the shortest AS-PATH list into account to find the best path. (If we don’t modify any other attributes like Weight, Local Preference etc)
·         Before sending an eBGP update, a router will prepend its own AS number to the AS-PATH.
·         This attribute is mainly used to prevent loops in the BGP domain.
·         If any router sees its own AS number in the received update, it knows that there is a loop and it drops the packet.


            R2---------------R1--------------R3

·         R2: Ser1/1 – 10.1.12.2 ßà R1: Ser1/1 – 10.1.12.1
·         R1: Ser1/0 – 100.1.13.1 ßà R3: Ser1/0 – 100.1.13.3

·         AS 100: R1
·         AS 200: R2
·         AS 300: R3

·         eBGP between R1 & R2
·         eBGP between R1 & R3
·         Created a loopback 23.23.23.23/32 on R2 and R3 and advertised into BGP.
·         Now, R1 gets 2 updates for the same prefix, one from R2 and another one from R3
·         Let’s see how to modify AS-PATH attribute in order to change the default path

BGP Configs:

R3(config-router)#do show run | begin router bgp 300
router bgp 300
 no synchronization
 bgp router-id 3.3.3.3
 bgp log-neighbor-changes
 network 23.23.23.23 mask 255.255.255.255
 neighbor 100.1.13.1 remote-as 100
 no auto-summary
!

R2(config-router)#do show run | begin router bgp 200
router bgp 200
 no synchronization
 bgp router-id 2.2.2.2
 bgp log-neighbor-changes
 network 23.23.23.23 mask 255.255.255.255
 neighbor 10.1.12.1 remote-as 100
 no auto-summary
!

R1(config-router)#do show run | begin router bgp 100
router bgp 100
 no synchronization
 bgp router-id 1.1.1.1
 bgp log-neighbor-changes
 neighbor 10.1.12.2 remote-as 200
 neighbor 100.1.13.3 remote-as 300
 no auto-summary
!

R3(config-router)#do show ip bgp sum
BGP router identifier 3.3.3.3, local AS number 300
BGP table version is 2, main routing table version 2
1 network entries using 117 bytes of memory
1 path entries using 52 bytes of memory
2/1 BGP path/bestpath attribute entries using 248 bytes of memory
0 BGP route-map cache entries using 0 bytes of memory
0 BGP filter-list cache entries using 0 bytes of memory
BGP using 417 total bytes of memory
BGP activity 1/0 prefixes, 1/0 paths, scan interval 60 secs

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
100.1.13.1      4   100       7       7        2    0    0 00:03:41        0
R3(config-router)#

R2(config-router)#do show ip bgp sum
BGP router identifier 2.2.2.2, local AS number 200
BGP table version is 2, main routing table version 2
1 network entries using 117 bytes of memory
2 path entries using 104 bytes of memory
3/1 BGP path/bestpath attribute entries using 372 bytes of memory
1 BGP AS-PATH entries using 24 bytes of memory
0 BGP route-map cache entries using 0 bytes of memory
0 BGP filter-list cache entries using 0 bytes of memory
BGP using 617 total bytes of memory
BGP activity 1/0 prefixes, 2/0 paths, scan interval 60 secs

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
10.1.12.1       4   100       7       7        2    0    0 00:03:53        1
R2(config-router)#

R1(config-router)#do show ip bgp sum
BGP router identifier 1.1.1.1, local AS number 100
BGP table version is 2, main routing table version 2
1 network entries using 117 bytes of memory
2 path entries using 104 bytes of memory
3/1 BGP path/bestpath attribute entries using 372 bytes of memory
2 BGP AS-PATH entries using 48 bytes of memory
0 BGP route-map cache entries using 0 bytes of memory
0 BGP filter-list cache entries using 0 bytes of memory
BGP using 641 total bytes of memory
BGP activity 1/0 prefixes, 2/0 paths, scan interval 60 secs

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
10.1.12.2       4   200       8       8        2    0    0 00:04:09        1
100.1.13.3      4   300       8       8        2    0    0 00:04:17        1
R1(config-router)#

R3(config-router)#do show ip bgp
BGP table version is 2, 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
*> 23.23.23.23/32   0.0.0.0                  0         32768 i
R3(config-router)#

R2(config-router)#do show ip bgp
BGP table version is 2, 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
*  23.23.23.23/32   10.1.12.1                              0 100 300 i
*>                  0.0.0.0                  0         32768 i
R2(config-router)#

R1(config-router)#do show ip bgp
BGP table version is 2, 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
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*  23.23.23.23/32   10.1.12.2                0             0 200 i
*>                  100.1.13.3               0             0 300 i
R1(config-router)#


·         R1 has chosen the path through R3 to reach the prefix 23.23.23.23/32
·         But if R3 doesn’t want this traffic to come from R1, it can try to influence R1 not to choose R3 as the best path.
·         Let me configure AS-PATH prepending from R3 to R1 outbound direction.


R3(config-router)#route-map PATH
R3(config-route-map)#set as-path prepend 300 300 300
R3(config-route-map)#router bgp 300
R3(config-router)#neighbor 100.1.13.1 route-map PATH out
R3(config-router)#


Now, let me check the BGP Table on R1:

R1(config-router)#do show ip bgp
BGP table version is 3, 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
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*  23.23.23.23/32   100.1.13.3               0             0 300 300 300 300 i
*>                  10.1.12.2                0             0 200 i
R1(config-router)#
R1(config-router)#do trace 23.23.23.23

Type escape sequence to abort.
Tracing the route to 23.23.23.23

  1 10.1.12.2 60 msec *  40 msec
R1(config-router)#

Observations:

·         R3 sending the route with AS-PATH LIST of “300 300 300 300”
·         Now, R1 got 2 updates for 23.23.23.23/32; one from R2 which has AS-PATH 200, and another from R3, which has AS-PATH “300 300 300 300”.
·         R1 has selected the path through R2 to reach 23.23.23.23/32, as it has the shortest AS-PATH List.

·         ***But remember, though R3 has tried to influence the path selection in R1, R1 has the better control of the traffic leaving its own AS.
·         Hence, if R1 configures Weight or Local Preference, that comes first in the BGP Best Path Selection and overrides R3’s influence.

No comments:

Post a Comment