Wednesday, January 25, 2012

BGP COMMUNITIES

BGP Communities
----------------
BGP Implementation of a ROute tag
used to group prefixes togther for
 - advertisement
 - filtering policy
 - bestpath selection policy
community is an optional transitive attribute
  - not exchanged between peers by default
neighbor "ip address" send-community
BGP Community Values
---------------------
Standard community is a 4 byte value
can be denoted as
- Decimal (0-4294967296)
- AA:NN (0:0-65535:65535)
ip bgp-community new-format
same binary value regardless of visual format

3 Well Known  values are reserved

WELL KNOwN
----------
No export (0xFFFFFF01)
   - dont advertised to ebgp peers (Specfically EBGP peers)
No Advertise (0xFFFFFF02)
   - dont advertise to any peers
Local-AS (0xFFFFFF03)
   - DO not advertise to confed EBGP peers or Regular EBGP peers
   - RFC defines as NO-export-subconfed

Matching and Setting Communities
--------------------------------
Set occur directly in route-map
 - set communities {community-number [additive] [well known] none}
 - Not 'additive' by default
Match Occurs via community list
  - define list
      - standard list matches community none or number
      - ip community-list 1 standard permit no-export
   -expanded matches regular expressions
      - ip community-list expanded AS100 permit 100:[0-9]+
   - reference from route-map
       - match AS 100
Internet community tends to be every thing
if you set to none it strips the community attribute
additive - add to community list + does not remove previous values
generally providers will do additive on the internet
There is alot of agreed upon communities depending on server provider so you may be in case
you provider if you send me a community 500:70 i will make the following change to bgp
attribute it could be local preference as path prepend etc

LAB
----
OK on s1 i am advertising the route 22.1.1.1/32

r3
---

r3#sh ip bgp
BGP table version is 36, 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
*>i22.1.1.1/32      2.1.1.1                  0    100      0 i
r3#

sw3
---
s3#sh ip bgp
BGP table version is 30, local router ID is 2.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
*>i22.1.1.1/32      2.1.1.1                  0    100      0 i
s3#

r5
---
r5#sh ip bgp
BGP table version is 15, local router ID is 5.5.5.5
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
*  22.1.1.1/32      1.1.1.1                 10             0 100 100 300 i
*                   4.4.4.4         4294967295             0 100 100 300 i
*>                  3.3.3.3                  5             0 300 i
r5#

S1
---

We will create a prefix list to match the route advertisement
s1(config)#ip prefix-list COMM permit 22.1.1.1/32
s1(config)#

ok we will create a route-map
s1(config)#route-map COMM permit 10
s1(config-route-map)#match ip address prefix COMM
s1(config-route-map)#set community no-export
s1(config-route-map)#
which matches the prefix list and set community to no-export

s1(config-router)#router bgp 300
s1(config-router)#neighbor IBGP route-map COMM out
s1(config-router)#neighbor IBGP send-community

r3
==
r3#sh ip bgp
BGP table version is 40, 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
*>i22.1.1.1/32      2.1.1.1                  0    100      0 i
r3#sh ip bgp 22.1.1.1
BGP routing table entry for 22.1.1.1/32, version 40
Paths: (1 available, best #1, table Default-IP-Routing-Table, not advertised to EBGP peer)
Flag: 0x820
  Not advertised to any peer
  Local
    2.1.1.1 (metric 20645120) from 2.1.1.1 (22.1.1.1)
      Origin IGP, metric 0, localpref 100, valid, internal, best
      Community: no-export
r3#

we get with the attribute set


s3
---
s3#sh ip bgp
BGP table version is 34, local router ID is 2.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
*>i22.1.1.1/32      2.1.1.1                  0    100      0 i
s3#sh ip bgp 22.1.1.1
BGP routing table entry for 22.1.1.1/32, version 34
Paths: (1 available, best #1, table Default-IP-Routing-Table, not advertised to EBGP peer)
  Not advertised to any peer
  Local
    2.1.1.1 (metric 130816) from 2.1.1.1 (22.1.1.1)
      Origin IGP, metric 0, localpref 100, valid, internal, best
      Community: no-export
s3#

r5
---
r5#sh ip bgp
r5#

we do not get the route as the no-export comm is set

NO ADVERTISE
-------------

s1(config)#route-map COMM
s1(config-route-map)#match ip address prefix-list COMM
s1(config-route-map)#set community no-advertise
s1(config-route-map)#

r3
---


r3#sh ip bgp
BGP table version is 42, 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
*>i22.1.1.1/32      2.1.1.1                  0    100      0 i
r3#sh ip bgp 22.1.1.1/32
BGP routing table entry for 22.1.1.1/32, version 42
Paths: (1 available, best #1, table Default-IP-Routing-Table, not advertised to any peer)
Flag: 0x820
  Not advertised to any peer
  Local
    2.1.1.1 (metric 20645120) from 2.1.1.1 (22.1.1.1)
      Origin IGP, metric 0, localpref 100, valid, internal, best
      Community: no-advertise



S3 is recieving
----------------
s3#sh ip bgp
BGP table version is 36, local router ID is 2.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
*>i22.1.1.1/32      2.1.1.1                  0    100      0 i
s3#sh ip bgp 22.1.1.1
BGP routing table entry for 22.1.1.1/32, version 36
Paths: (1 available, best #1, table Default-IP-Routing-Table, not advertised to any peer)
  Not advertised to any peer
  Local
    2.1.1.1 (metric 130816) from 2.1.1.1 (22.1.1.1)
      Origin IGP, metric 0, localpref 100, valid, internal, best
      Community: no-advertise
s3#

r5
---
r5#sh ip bgp
r5#

No comments:

Post a Comment