Network Diagram:

***************************************************************** AIM: See how to add communities to updates ***************************************************************** ================================================ R2 Configuration: =================================================
router bgp 1 no synchronization bgp router-id 2.2.2.2 bgp default local-preference 500 network 2.2.2.2 mask 255.255.255.255 network 10.1.1.0 mask 255.255.255.0 network 10.1.2.0 mask 255.255.255.0 network 10.1.3.0 mask 255.255.255.0 neighbor 1.1.1.1 remote-as 1 neighbor 1.1.1.1 ebgp-multihop 255 neighbor 1.1.1.1 update-source Loopback0 neighbor 1.1.1.1 route-reflector-client neighbor 1.1.1.1 prefix-list david in neighbor 3.3.3.3 remote-as 1 neighbor 3.3.3.3 ebgp-multihop 255 neighbor 3.3.3.3 update-source Loopback0 neighbor 3.3.3.3 route-reflector-client neighbor 3.3.3.3 send-community <= Send community to neighbor neighbor 3.3.3.3 route-map setcommunity out <= Specify community with a route-map neighbor 4.4.4.4 remote-as 2 neighbor 4.4.4.4 ebgp-multihop 255 neighbor 4.4.4.4 update-source Loopback0 neighbor 4.4.4.4 send-community neighbor 4.4.4.4 route-map setcommunity out no auto-summary ! ip classless ip route 1.1.1.1 255.255.255.255 10.1.1.1 ip route 3.3.3.3 255.255.255.255 10.1.3.2 ip route 4.4.4.4 255.255.255.255 10.1.2.2 no ip http server ip bgp-community new-format ! ! ip prefix-list david seq 5 deny 7.7.7.7/32 ip prefix-list david seq 10 permit 0.0.0.0/0 le 32 access-list 1 permit any <======= Community applies to all routes route-map setmetricout permit 10 set metric 100 ! route-map setcommunity permit 10 <======= Specify community with a route-map match ip address 1 set community 1:1
================================================ R4 Configuration: =================================================
! router bgp 2 no synchronization bgp router-id 4.4.4.4 network 4.4.4.4 mask 255.255.255.255 network 10.1.2.0 mask 255.255.255.0 network 10.1.5.0 mask 255.255.255.0 neighbor 2.2.2.2 remote-as 1 neighbor 2.2.2.2 ebgp-multihop 255 neighbor 2.2.2.2 update-source Loopback0 neighbor 5.5.5.5 remote-as 2 neighbor 5.5.5.5 ebgp-multihop 255 neighbor 5.5.5.5 update-source Loopback0 neighbor 5.5.5.5 next-hop-self neighbor 5.5.5.5 send-community <= Send community to neighbor Do this on all the other routers neighbor 5.5.5.5 route-map setnexthop in no auto-summary ! no ip http server ip classless ip route 2.2.2.2 255.255.255.255 10.1.2.1 ip route 5.5.5.5 255.255.255.255 10.1.5.2 ! route-map setnexthop permit 10 set ip next-hop peer-address !
================================================ R4 Output: ================================================

================================================ R4 Config changes ================================================
r4(config)#ip bgp new-format
================================================ R4 Output: ================================================

================================================ R6 Output: ================================================

***************************************************************** AIM: Change the community on R4 - you will see it overrides other community *****************************************************************
================================================ R4 Config Changes: ================================================
router bgp 2 no synchronization bgp router-id 4.4.4.4 network 4.4.4.4 mask 255.255.255.255 network 10.1.2.0 mask 255.255.255.0 network 10.1.5.0 mask 255.255.255.0 neighbor 2.2.2.2 remote-as 1 neighbor 2.2.2.2 ebgp-multihop 255 neighbor 2.2.2.2 update-source Loopback0 neighbor 5.5.5.5 remote-as 2 neighbor 5.5.5.5 ebgp-multihop 255 neighbor 5.5.5.5 update-source Loopback0 neighbor 5.5.5.5 next-hop-self neighbor 5.5.5.5 send-community neighbor 5.5.5.5 route-map setnexthop in neighbor 5.5.5.5 route-map sendcommunity out no auto-summary ! no ip http server ip classless ip route 2.2.2.2 255.255.255.255 10.1.2.1 ip route 5.5.5.5 255.255.255.255 10.1.5.2 ip bgp-community new-format ! access-list 2 permit any route-map setnexthop permit 10 set ip next-hop peer-address ! route-map sendcommunity permit 10 <===== Change community to 2:2 match ip address 2 set community 2:2 !
================================================ R5 Output: ================================================

***************************************************************** AIM: Change the community on R4 - don't override other community *****************************************************************
================================================ R4 Config Changes: ================================================
router bgp 2 no synchronization bgp router-id 4.4.4.4 network 4.4.4.4 mask 255.255.255.255 network 10.1.2.0 mask 255.255.255.0 network 10.1.5.0 mask 255.255.255.0 neighbor 2.2.2.2 remote-as 1 neighbor 2.2.2.2 ebgp-multihop 255 neighbor 2.2.2.2 update-source Loopback0 neighbor 5.5.5.5 remote-as 2 neighbor 5.5.5.5 ebgp-multihop 255 neighbor 5.5.5.5 update-source Loopback0 neighbor 5.5.5.5 next-hop-self neighbor 5.5.5.5 send-community neighbor 5.5.5.5 route-map setnexthop in neighbor 5.5.5.5 route-map sendcommunity out no auto-summary ! no ip http server ip classless ip route 2.2.2.2 255.255.255.255 10.1.2.1 ip route 5.5.5.5 255.255.255.255 10.1.5.2 ip bgp-community new-format ! access-list 2 permit any route-map setnexthop permit 10 set ip next-hop peer-address ! route-map sendcommunity permit 10 <===== Add to community list use - ADDITIVE - doesn't override community match ip address 2 set community 2:2 additive !
================================================ R5 Output: ================================================

================================================ R6 Output: ================================================

***************************************************************** AIM: Lets set weights based on the community *****************************************************************
================================================ R6 Config changes: ================================================
router bgp 3 no synchronization bgp router-id 6.6.6.6 network 6.6.6.6 mask 255.255.255.255 network 10.1.6.0 mask 255.255.255.0 neighbor 5.5.5.5 remote-as 2 neighbor 5.5.5.5 ebgp-multihop 255 neighbor 5.5.5.5 update-source Loopback0 neighbor 5.5.5.5 route-map checkcommunity in <===== Check communities coming in no auto-summary ! ip classless ip route 5.5.5.5 255.255.255.255 10.1.6.1 no ip http server ip bgp-community new-format <===== Display in new format ip community-list 5 permit 1:1 <===== For communtiy 1:1 ip community-list 6 permit internet <===== For everything else ! access-list 1 permit any route-map setnexthop permit 10 match ip address 1 set ip next-hop peer-address ! route-map setnexthop permit 20 ! route-map checkcommunity permit 10 <===== Check communities coming in match community 5 set weight 20 ! route-map checkcommunity permit 20 <===== Check communities coming in match community 6 set weight 1
================================================ R6 Output: ================================================

Notice above - routers with AS 1 in the AS path have weight set to 20, and those with AS path set to 2 only have weight set to 1
I hope that this has been beneficial to you.
To your success,
David Bombal
|