Here is the topology we will be using.
Entire config can be downloaded here.
First we will see how we can set communities. On R1 we are going to advertise 1.1.1.0/24 to R2 with a community set. If you need a primer on communities check out my other articles on BGP communities.
R1#
interface FastEthernet1/0
description connected to r2
ip address 192.168.1.1 255.255.255.252
duplex auto
speed auto
end
!
interface Loopback0
description loopback 0
ip address 1.1.1.1 255.255.255.0
end
!
route-map add-community permit 10
set community 77881 66325
!
router bgp 1
no synchronization
bgp log-neighbor-changes
network 1.1.1.0 mask 255.255.255.0 route-map add-community out
neighbor 192.168.1.2 remote-as 2
neighbor 192.168.1.2 send-community both
no auto-summary
Please note that without the "send-community" the communities will not be sent to the peer. "both" is used because there are two types of communities you can send -- standard or extended. Long discussion but for the most part standard communities should be fine unless you are doing VRFs/MPLS or some network-kung fu.
R2#
interface FastEthernet1/0
description connected to r1
ip address 192.168.1.2 255.255.255.0
duplex auto
speed auto
end
!
router bgp 2
bgp log-neighbor-changes
neighbor 192.168.1.1 remote-as 1
!
address-family ipv4
neighbor 192.168.1.1 activate
no auto-summary
no synchronization
exit-address-family
!!
R2#sh ip bgp 1.1.1.0
BGP routing table entry for 1.1.1.0/24, version 4
Paths: (1 available, best #1, table Default-IP-Routing-Table)
Flag: 0x820
Not advertised to any peer
1
192.168.1.1 from 192.168.1.1 (1.1.1.1)
Origin IGP, metric 0, localpref 100, valid, external, best
Community: 66325 77881
Notice that on R2 1.1.1.0/24 is tagged with communities. Now let's see how we can delete communities.
Deleting certain communities or clear communities all together.
First we will see how we can delete a certain community, in this case say we wanted to delete 66325.
R2#
!
ip community-list 1 permit 66325
!
route-map delete-community permit 10
set comm-list 1 delete
!
router bgp 2
bgp log-neighbor-changes
neighbor 192.168.1.1 remote-as 1
!
address-family ipv4
neighbor 192.168.1.1 activate
neighbor 192.168.1.1 route-map delete-community in
no auto-summary
no synchronization
exit-address-family
- Create a community-list to match what we want to delete.
- Create a route-map to match all routes coming in from R1 and delete communities with a set statement.
- Apply the route-map in the inbound direction on the peer.
ip community-list 1 permit instead of ip community-list 1 permit 66325
Please keep in mind that this is a routing policy change so BGP needs to be cleared with a "clear ip bgp <IP|*|ASN> <soft>"
How about if you wanted to append to the existing list of communities?
R2#
!
route-map add-communities permit 10
set community 12789 additive
!
router bgp 2
bgp log-neighbor-changes
neighbor 192.168.1.1 remote-as 1
!
address-family ipv4
neighbor 192.168.1.1 activate
neighbor 192.168.1.1 soft-reconfiguration inbound
neighbor 192.168.1.1 route-map add-communities in
no auto-summary
no synchronization
exit-address-family
!
R2#sh ip bgp 1.1.1.0
BGP routing table entry for 1.1.1.0/24, version 3
Paths: (2 available, best #1, table Default-IP-Routing-Table)
Flag: 0x880
Not advertised to any peer
1
192.168.1.1 from 192.168.1.1 (1.1.1.1)
Origin IGP, metric 0, localpref 100, valid, external, best
Community: 12789 66325 77881
Notice that the community is now being added to the rest of the communities.
Please keep in mind that this is a routing policy change so BGP needs to be cleared with a "clear ip bgp <IP|*|ASN> <soft>"
I have used BGP communities in various scenarios --
- In the ISP world to affect customer routes coming into our ISP backbone.
- I've also used as a end customer to blackhole my public subnet when we are under DDOS attacks.
- I've used it to tag routes as multicast prefixes so it can be used for mBGP.
Great reference on BGP communities http://www.cisco.com/web/about/ac123/ac147/archived_issues/ipj_6-2/bgp_communities.html
Many more articles to come so stay tuned.
Please reshare/subscribe/comment/+1 if you like my posts as it keeps me motivated to write more and spread the knowledge.
Hi fella
ReplyDeleteGreat Article. How did you use the community to black hole your public subnet?
We would send our route with a certain community set and based on that community the ISP would send traffic destined to that network to null.
Delete