Thursday, 28 June 2012

BGP: Communities: LOCAL-AS

BGP: Communities: LOCAL-AS

·         In BGP, communities are basically used to tag the routes so that we can filter them where ever we want.
·         LOCAL-AS is the community value that can be used in-side a Confederation AS.
·         LOCAL-AS is a special community value. It simply instructs the received router not to forward this route outside the Confederation AS.

·         Confederation is simply dividing the AS into Sub-ASs.

·         Let me take a small topology to understand this


·         AS 400: R4
·         AS 100: R1, R2, R3

·         Confederation AS 65531: R1 & R2
·         Confederation AS 65532: R3

·         EBGP: R2 – R4
·         Confederation EBGP: R2 – R3
·         Confederation IBGP: R1 – R2

·         I have 3 loopbacks in R1, 1.1.1.1/32, 11.11.11.11/32 and 111.111.111.111/32
·         Let me create a route-map, so that
o    LOCAL-AS community is set for 1.1.1.1/32
o    NO-EXPORT community is set for 11.11.11.11/32
o    No community is set for 111.111.111.111/32

R4#show run | begin router bgp 400
router bgp 400
 no synchronization
 bgp router-id 4.4.4.4
 bgp log-neighbor-changes
 network 4.4.4.4 mask 255.255.255.255
 neighbor 100.1.24.2 remote-as 100
 no auto-summary
!

R2#show run | begin router bgp
router bgp 65531
 no synchronization
 bgp router-id 2.2.2.2
 bgp log-neighbor-changes
 bgp confederation identifier 100
 bgp confederation peers 65532
 network 2.2.2.2 mask 255.255.255.255
 neighbor 100.1.12.1 remote-as 65531
 neighbor 100.1.12.1 send-community
 neighbor 100.1.23.3 remote-as 65532
 neighbor 100.1.23.3 send-community
 neighbor 100.1.24.4 remote-as 400
 neighbor 100.1.24.4 send-community
 no auto-summary
!

R1#show run
router bgp 65531
 no synchronization
 bgp router-id 1.1.1.1
 bgp log-neighbor-changes
 bgp confederation identifier 100
 network 1.1.1.1 mask 255.255.255.255
 network 11.11.11.11 mask 255.255.255.255
 network 111.111.111.111 mask 255.255.255.255
 neighbor 100.1.12.2 remote-as 65531
 neighbor 100.1.12.2 send-community
 neighbor 100.1.12.2 route-map COMMUNITY out
 no auto-summary
!
ip prefix-list 1 seq 5 permit 1.1.1.1/32
!
ip prefix-list 10 seq 5 permit 10.1.1.1/32
!
ip prefix-list 11 seq 5 permit 11.11.11.11/32
!
route-map COMMUNITY permit 10
 match ip address prefix-list 1
 set community local-AS
!
route-map COMMUNITY permit 20
 match ip address prefix-list 11
 set community no-export
!
route-map COMMUNITY permit 100
!

R3#show run | begin router bgp
router bgp 65532
 no synchronization
 bgp router-id 3.3.3.3
 bgp log-neighbor-changes
 bgp confederation identifier 100
 bgp confederation peers 65531
 network 3.3.3.3 mask 255.255.255.255
 neighbor 100.1.23.2 remote-as 65531
 no auto-summary
!

R1#show ip bgp
BGP table version is 6, 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
*> 1.1.1.1/32       0.0.0.0                  0         32768 i
*>i2.2.2.2/32       100.1.12.2               0    100      0 i
*>i3.3.3.3/32       100.1.23.3               0    100      0 (65532) i
* i4.4.4.4/32       100.1.24.4               0    100      0 400 i
*> 11.11.11.11/32   0.0.0.0                  0         32768 i
*> 111.111.111.111/32
                    0.0.0.0                  0         32768 i
R1#

R2#show ip bgp
BGP table version is 11, 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.1.1.1/32       100.1.12.1               0    100      0 i
*> 2.2.2.2/32       0.0.0.0                  0         32768 i
*> 3.3.3.3/32       100.1.23.3               0    100      0 (65532) i
*> 4.4.4.4/32       100.1.24.4               0             0 400 i
*>i11.11.11.11/32   100.1.12.1               0    100      0 i
*>i111.111.111.111/32
                    100.1.12.1               0    100      0 i
R2#

R3#show ip bgp
BGP table version is 5, 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
*> 2.2.2.2/32       100.1.23.2               0    100      0 (65531) i
*> 3.3.3.3/32       0.0.0.0                  0         32768 i
*  4.4.4.4/32       100.1.24.4               0    100      0 (65531) 400 i
*> 11.11.11.11/32   100.1.12.1               0    100      0 (65531) i
*> 111.111.111.111/32
                    100.1.12.1               0    100      0 (65531) i
R3#

R4#show ip bgp
BGP table version is 7, local router ID is 4.4.4.4
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
*> 2.2.2.2/32       100.1.24.2               0             0 100 i
*> 3.3.3.3/32       100.1.24.2                             0 100 i
*> 4.4.4.4/32       0.0.0.0                  0         32768 i
*> 111.111.111.111/32
                    100.1.24.2                             0 100 i
R4#

R2#show ip bgp 1.1.1.1
BGP routing table entry for 1.1.1.1/32, version 10
Paths: (1 available, best #1, table Default-IP-Routing-Table, not advertised outside local AS)
  Not advertised to any peer
  Local
    100.1.12.1 from 100.1.12.1 (1.1.1.1)
      Origin IGP, metric 0, localpref 100, valid, confed-internal, best
      Community: local-AS
R2#
R2#show ip bgp 11.11.11.11
BGP routing table entry for 11.11.11.11/32, version 11
Paths: (1 available, best #1, table Default-IP-Routing-Table, not advertised to EBGP peer)
  Advertised to update-groups:
     2
  Local
    100.1.12.1 from 100.1.12.1 (1.1.1.1)
      Origin IGP, metric 0, localpref 100, valid, confed-internal, best
      Community: no-export
R2#
R2#show ip bgp 111.111.111.111
BGP routing table entry for 111.111.111.111/32, version 9
Paths: (1 available, best #1, table Default-IP-Routing-Table)
  Advertised to update-groups:
     1          2
  Local
    100.1.12.1 from 100.1.12.1 (1.1.1.1)
      Origin IGP, metric 0, localpref 100, valid, confed-internal, best
R2#

Observations:

·         LOCAL-AS community value is set for 1.1.1.1
·         Because of LOCAL-AS community, 1.1.1.1/32 didn’t leave Confederation AS 65531, only R2 has this prefix.

·         NO-EXPORT community value is set for 11.11.11.11
·         Because of NO-EXPORT community, 11.11.11.11/32 didn’t leave AS 100, only R2 and R3 have this prefix.

·         No community value is configured for 111.111.111.111
·         Because of this, all routers got this prefix in their BGP table.


BGP: Confederations

BGP: Confederations

·         Confederation is simply dividing the AS into Sub-ASs.

·         Inside a Sub-AS, full-mesh required.
·         If we can’t have full-mesh, we can use Route Reflectors inside a Sub-AS.

·         Confederation EBGP connection acts like regular EBGP connection regarding TTL, because Confederation EBGP connection also has TTL of 1.

·         Next-hop will not change while advertising to Confederation EBGP peer. (NEXT-HO gets changed in regular EBGP update)
·         MED value is advertised to Confederation EBGP peer. (MED is non-transitive attribute, so it will not be advertised in regular EBGP update)
·         Local Preference also advertised to Confederation EBGP peer. (Local Preference value will not leave AS).

·         Let me take a small topology to configure this


·         AS 400: R4
·         AS 100: R1, R2, R3

·         Confederation AS 65531: R1 & R2
·         Confederation AS 65532: R3

·         EBGP: R2 – R4
·         Confederation EBGP: R2 – R3
·         Confederation IBGP: R1 – R2

R4#show run | begin router bgp
router bgp 400
 no synchronization
 bgp router-id 4.4.4.4
 bgp log-neighbor-changes
 network 4.4.4.4 mask 255.255.255.255
 neighbor 100.1.24.2 remote-as 100
 no auto-summary
!

R2#show run | begin router bgp
router bgp 65531
 no synchronization
 bgp router-id 2.2.2.2
 bgp log-neighbor-changes
 bgp confederation identifier 100
 bgp confederation peers 65532
 network 2.2.2.2 mask 255.255.255.255
 neighbor 100.1.12.1 remote-as 65531
 neighbor 100.1.23.3 remote-as 65532
 neighbor 100.1.24.4 remote-as 400
 no auto-summary
!

R1#show run | begin router bgp
router bgp 65531
 no synchronization
 bgp router-id 1.1.1.1
 bgp log-neighbor-changes
 bgp confederation identifier 100
 network 1.1.1.1 mask 255.255.255.255
 neighbor 100.1.12.2 remote-as 65531
 no auto-summary
!

R3#show run | begin router bgp
router bgp 65532
 no synchronization
 bgp router-id 3.3.3.3
 bgp log-neighbor-changes
 bgp confederation identifier 100
 bgp confederation peers 65531
 network 3.3.3.3 mask 255.255.255.255
 neighbor 100.1.23.2 remote-as 65531
 no auto-summary
!

R4#show ip bgp sum
BGP router identifier 4.4.4.4, local AS number 400
BGP table version is 5, main routing table version 5
4 network entries using 468 bytes of memory
4 path entries using 208 bytes of memory
4/3 BGP path/bestpath attribute entries using 496 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 1196 total bytes of memory
BGP activity 4/0 prefixes, 4/0 paths, scan interval 60 secs

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
100.1.24.2      4   100      27      26        5    0    0 00:03:52        3
R4#

R2#show ip bgp sum
BGP router identifier 2.2.2.2, local AS number 65531
BGP table version is 5, main routing table version 5
4 network entries using 468 bytes of memory
4 path entries using 208 bytes of memory
5/4 BGP path/bestpath attribute entries using 620 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 1344 total bytes of memory
BGP activity 4/0 prefixes, 4/0 paths, scan interval 60 secs

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
100.1.12.1      4 65531       8      10        5    0    0 00:04:02        1
100.1.23.3      4 65532       7       9        5    0    0 00:03:50        1
100.1.24.4      4   400       8      10        5    0    0 00:03:55        1
R2#

R1#show ip bgp sum
BGP router identifier 1.1.1.1, local AS number 65531
BGP table version is 3, main routing table version 3
4 network entries using 468 bytes of memory
4 path entries using 208 bytes of memory
5/2 BGP path/bestpath attribute entries using 620 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 1344 total bytes of memory
BGP activity 4/0 prefixes, 4/0 paths, scan interval 60 secs

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
100.1.12.2      4 65531      10       8        3    0    0 00:04:03        3
R1#

R3#show ip bgp sum
BGP router identifier 3.3.3.3, local AS number 65532
BGP table version is 3, main routing table version 3
4 network entries using 468 bytes of memory
4 path entries using 208 bytes of memory
4/2 BGP path/bestpath attribute entries using 496 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 1220 total bytes of memory
BGP activity 4/0 prefixes, 4/0 paths, scan interval 60 secs

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
100.1.23.2      4 65531       9       7        3    0    0 00:03:51        3
R3#

R4#show ip bgp
BGP table version is 5, local router ID is 4.4.4.4
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.1.1.1/32       100.1.24.2                             0 100 i
*> 2.2.2.2/32       100.1.24.2               0             0 100 i
*> 3.3.3.3/32       100.1.24.2                             0 100 i
*> 4.4.4.4/32       0.0.0.0                  0         32768 i
R4#

R2#show ip bgp
BGP table version is 5, 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.1.1.1/32       100.1.12.1               0    100      0 i
*> 2.2.2.2/32       0.0.0.0                  0         32768 i
*> 3.3.3.3/32       100.1.23.3               0    100      0 (65532) i
*> 4.4.4.4/32       100.1.24.4               0             0 400 i
R2#

R1#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
*> 1.1.1.1/32       0.0.0.0                  0         32768 i
*>i2.2.2.2/32       100.1.12.2               0    100      0 i
* i3.3.3.3/32       100.1.23.3               0    100      0 (65532) i
* i4.4.4.4/32       100.1.24.4               0    100      0 400 i
R1#

R3#show ip bgp
BGP table version is 3, 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
*  1.1.1.1/32       100.1.12.1               0    100      0 (65531) i
*> 2.2.2.2/32       100.1.23.2               0    100      0 (65531) i
*> 3.3.3.3/32       0.0.0.0                  0         32768 i
*  4.4.4.4/32       100.1.24.4               0    100      0 (65531) 400 i
R3#

Observations:

·         All BGP Neighbors are Up.

·         Next-hop is not changed for Confederation EBGP update. (next-hop will change for regular EBGP updates).
·         For the prefix 4.4.4.4/32 which is advertised by R4, R2 didn’t change the next-hop value while forwarding the update to R3, which is Confederation EBGP peer.

·         Let me configure MED and Local Preference values to see what happens

R4(config)#route-map MED
R4(config-route-map)#set metric 444
R4(config-route-map)#router bgp 400
R4(config-router)#neighbor 100.1.24.2 route-map MED out
R4(config-router)#

R2(config)#route-map LOCAL
R2(config-route-map)#set local-preference 222
R2(config-route-map)#router bgp 65531
R2(config-router)#neighbor 100.1.24.4 route-map LOCAL in
R2(config-router)#

R2#show ip bgp
BGP table version is 5, 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.1.1.1/32       100.1.12.1               0    100      0 i
*> 2.2.2.2/32       0.0.0.0                  0         32768 i
*> 3.3.3.3/32       100.1.23.3               0    100      0 (65532) i
*> 4.4.4.4/32       100.1.24.4             444    222      0 400 i
R2#

R1#show ip bgp
BGP table version is 5, 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
*> 1.1.1.1/32       0.0.0.0                  0         32768 i
*>i2.2.2.2/32       100.1.12.2               0    100      0 i
* i3.3.3.3/32       100.1.23.3               0    100      0 (65532) i
* i4.4.4.4/32       100.1.24.4             444    222      0 400 i
R1#

R3#show ip bgp
BGP table version is 5, 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
*  1.1.1.1/32       100.1.12.1               0    100      0 (65531) i
*> 2.2.2.2/32       100.1.23.2               0    100      0 (65531) i
*> 3.3.3.3/32       0.0.0.0                  0         32768 i
*  4.4.4.4/32       100.1.24.4             444    222      0 (65531) 400 i
R3#

Observations:

·         MED is advertised to Confederation EBGP Peer
·         Local Preference also advertised to Confederation EBGP Peer