Showing posts with label Communities. Show all posts
Showing posts with label Communities. Show all posts

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.


Wednesday, 27 June 2012

BGP: Route Filtering Using Communities

BGP: Route Filtering Using Communities
·         In BGP, communities are basically used to tag the routes so that we can filter them where ever we want.
·         Let me take a small topology to configure and verify route filtering based on communities.


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

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

·         R1 is advertising a prefix 1.1.1.1/32 with community value 1
·         R1 is advertising a prefix 11.11.11.11/32 with community value 11

·         Configuration in R2:
·         Strip the community value 1 while forwarding it to R3 for 1.1.1.1/32
·         Change the community value to 123 for 11.11.11.11/32

·         Let me configure it and see…
R1#show run
router bgp 100
 no synchronization
 bgp router-id 1.1.1.1
 bgp log-neighbor-changes
 network 1.1.1.1 mask 255.255.255.255
 network 11.11.11.11 mask 255.255.255.255
 neighbor 100.1.12.2 remote-as 200
 neighbor 100.1.12.2 send-community
 neighbor 100.1.12.2 route-map COMM out
 no auto-summary
!
!
ip prefix-list 1 seq 5 permit 1.1.1.1/32
!
ip prefix-list 11 seq 5 permit 11.11.11.11/32
!
route-map COMM permit 10
 match ip address prefix-list 1
 set community 1
!
route-map COMM permit 20
 match ip address prefix-list 11
 set community 11
!
route-map COMM permit 100
!
R1#

R2(config)#do show run | begin router bgp 200
router bgp 200
 no synchronization
 bgp log-neighbor-changes
 neighbor 100.1.12.1 remote-as 100
 neighbor 100.1.23.3 remote-as 300
 neighbor 100.1.23.3 send-community
 no auto-summary
!
R2#show ip bgp
BGP table version is 10, 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
*> 1.1.1.1/32       100.1.12.1               0             0 100 i
*> 11.11.11.11/32   100.1.12.1               0             0 100 i
R2#
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)
Flag: 0x820
  Advertised to update-groups:
     2
  100
    100.1.12.1 from 100.1.12.1 (1.1.1.1)
      Origin IGP, metric 0, localpref 100, valid, external, best
      Community: 1
R2#
R2#show ip bgp 11.11.11.11
BGP routing table entry for 11.11.11.11/32, version 9
Paths: (1 available, best #1, table Default-IP-Routing-Table)
  Advertised to update-groups:
     2
  100
    100.1.12.1 from 100.1.12.1 (1.1.1.1)
      Origin IGP, metric 0, localpref 100, valid, external, best
      Community: 11
R2#

Observations:

·         R2 has received 2 prefixes from R1, 1.1.1.1/32 and 11.11.11.11/32
·         1.1.1.1/32 has community value of 1
·         11.11.11.11 has community value of 11

Let me configure to change these community values on R2:

R2(config-router)#do show run | begin router bgp 200
router bgp 200
 no synchronization
 bgp log-neighbor-changes
 neighbor 100.1.12.1 remote-as 100
 neighbor 100.1.23.3 remote-as 300
 neighbor 100.1.23.3 send-community
 neighbor 100.1.23.3 route-map COMM1 out
 no auto-summary
!
ip forward-protocol nd
!
no ip http server
!
!
!
ip prefix-list 1 seq 5 permit 1.1.1.1/32
!
ip prefix-list 11 seq 5 permit 11.11.11.11/32
!
route-map COMM1 permit 10
 match ip address prefix-list 1
 set community none
!
route-map COMM1 permit 20
 match ip address prefix-list 11
 set community 123
!
route-map COMM1 permit 100
!
!
R2(config-router)#

R3#show ip bgp
BGP table version is 13, 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.23.2                             0 200 100 i
*> 11.11.11.11/32   100.1.23.2                             0 200 100 i
R3#
R3#
R3#show ip bgp 1.1.1.1
BGP routing table entry for 1.1.1.1/32, version 12
Paths: (1 available, best #1, table Default-IP-Routing-Table)
Flag: 0x820
  Not advertised to any peer
  200 100
    100.1.23.2 from 100.1.23.2 (2.2.2.2)
      Origin IGP, localpref 100, valid, external, best
R3#
R3#show ip bgp 11.11.11.11
BGP routing table entry for 11.11.11.11/32, version 13
Paths: (1 available, best #1, table Default-IP-Routing-Table)
Flag: 0x820
  Not advertised to any peer
  200 100
    100.1.23.2 from 100.1.23.2 (2.2.2.2)
      Origin IGP, localpref 100, valid, external, best
      Community: 123
R3#

Observations:

·         R2 is stripping the community value for 1.1.1.1/32 while forwarding it to R3, that’s why I didn’t see any community value for 1.1.1.1/32 in R3
·         R2 is changing the community value to 123 for 11.11.11.11/32 while forwarding it to R3, that’s why I have community value as 123 for 11.11.11.11/32 in R3.

BGP: Communities: No-Export

BGP: Communities:  No-Export
·         In BGP, communities are basically used to tag the routes so that we can filter them where ever we want.
·         NO-EXPORT is a special community value. It simply instructs the received router not to forward this route outside the AS.

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

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

·         R1 is advertising a prefix 1.1.1.1/32 to R2 with no-export community
·         R2 will not forward this prefix to R3.
·         Let me configure it and see…

R1#show run | begin router bgp
router bgp 100
 no synchronization
 bgp router-id 1.1.1.1
 bgp log-neighbor-changes
 network 1.1.1.1 mask 255.255.255.255
 network 11.11.11.11 mask 255.255.255.255
 neighbor 100.1.12.2 remote-as 200
 neighbor 100.1.12.2 send-community
 neighbor 100.1.12.2 route-map NO-EXPORT out
 no auto-summary
!
!
!
ip prefix-list 1 seq 5 permit 1.1.1.1/32
!
route-map NO-EXPORT permit 10
 match ip address prefix-list 1
 set community no-export
!
route-map NO-EXPORT permit 100
!

R2#show run | begin router bgp 200
router bgp 200
no synchronization
bgp log-neighbor-changes
neighbor 100.1.12.1 remote-as 100
neighbor 100.1.23.3 remote-as 300
neighbor 100.1.23.3 send-community
no auto-summary
!

R3#show run | begin router bgp 300
router bgp 300
 no synchronization
 bgp log-neighbor-changes
 neighbor 100.1.23.2 remote-as 200
 no auto-summary
!
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
*> 11.11.11.11/32   0.0.0.0                  0         32768 i
R1#

R2#show ip bgp
BGP table version is 3, 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
*> 1.1.1.1/32       100.1.12.1               0             0 100 i
*> 11.11.11.11/32   100.1.12.1               0             0 100 i
R2#

R3#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
*> 11.11.11.11/32   100.1.23.2                             0 200 100 i
R3#

R2#show ip bgp 1.1.1.1
BGP routing table entry for 1.1.1.1/32, version 3
Paths: (1 available, best #1, table Default-IP-Routing-Table, not advertised to EBGP peer)
  Not advertised to any peer
  100
    100.1.12.1 from 100.1.12.1 (1.1.1.1)
      Origin IGP, metric 0, localpref 100, valid, external, best
      Community: no-export
R2#

Observations:
·         R1 advertised 1.1.1.1/32 into BGP with no-export community.
·         R2 got the route and it didn’t forward it to R3 since R3 is in different AS.