Pages

Friday, March 8, 2013

BGP Community No-Advertise

Much like a community in real life -- a group of "people" (usually) with common beliefs, A BGP community "is a group of destinations which share some common attribute" - RFC 1997.

There are numerous BGP communities, but basically it is translated and interpreted as a 32bit value. BGP communities are optional transitive attributes meaning they are not required and they can be passed on to other AS only if the router(s) decides to do so. 

These are the well-known communities. More being suggested and drafted in other RFCs.

INTERNET - By default all destinations are assigned this community. 
NO_EXPORT - Do not send the route to any eBGP neighbors. 
NO_EXPORT_SUBCONFED - Do not send the route to any sub-confederations. 
NO_ADVERTISE - Do not send the route to any neighbors (iBGP or eBGP).
LOCAL-AS - Do not send to anyone other than your LOCAL-AS (So this will prevent the router from sending to sub-confederations). 

In this blogtorial we will look at the NO_ADVERTISE community and how it can be used in a BGP environment to control routing and we will look at the other well-known communities in subsequent posts. 

Complete configs can be downloaded here.

Here are the basic configs needed to get topology up and running.

  hostname R1    
 !    
  interface Loopback1    
  description loopback1    
  ip address 11.11.11.11 255.255.255.255    
 !    
  interface FastEthernet1/0    
  description connected to r2    
  ip address 1.1.1.1 255.255.255.0    
  duplex auto    
  speed auto    
 !    

  hostname R2    
 !    
  interface FastEthernet1/0    
  description connected to r1    
  ip address 1.1.1.2 255.255.255.0    
  duplex auto    
  speed auto    
 !    
  interface FastEthernet1/1    
  description connected to r3    
  ip address 2.2.2.2 255.255.255.0    
  duplex auto    
  speed auto    
 !    
  interface FastEthernet2/0    
  description connected to r4    
  ip address 4.4.4.2 255.255.255.0    
  duplex auto    
  speed auto    
 !    

 !    
  hostname R3    
 !    
  interface FastEthernet1/0    
  description connected to r2    
  ip address 2.2.2.3 255.255.255.0    
  duplex auto    
  speed auto    
 !    

 !    
  hostname R4    
 !    
  interface FastEthernet1/0    
  description connected to r2    
  ip address 4.4.4.4 255.255.255.0    
  duplex auto    
  speed auto    
 !    

Now let's move on to configuring the community. Since R1 is sourcing the advertisement of the loopback we will set the community on R1. Just remember that communities are optional transitive attributes, so R2 could potentially clear the community and still advertise, but by default they will honor well-known communities.

!  
 hostname R1  
!  
 ip access-list standard acl-loopback-advertise-with-community  
  remark match loopback  
  permit 11.11.11.11  
!  
route-map loopback-advertise-with-comunity permit 10
 match ip address acl-loopback-advertise-with-community
 set community no-advertise
!
 router bgp 1  
  no synchronization  
  bgp log-neighbor-changes  
  network 11.11.11.11 mask 255.255.255.255  
  neighbor 1.1.1.2 remote-as 2  
  neighbor 1.1.1.2 description R2  
  neighbor 1.1.1.2 send-community both  
  neighbor 1.1.1.2 route-map loopback-advertise-with-comunity out  
  no auto-summary  
!  

  • Create an access-list to match the loopback.
  • Create a route map to match the ACL and set the community
  • Attach the route-map to R2 peer statement in R1
Let's get the rest of the BGP configured on the other routers. 


!  
 hostname R2  
!  
 router bgp 2  
  no synchronization  
  bgp log-neighbor-changes  
  neighbor 1.1.1.1 remote-as 1  
  neighbor 1.1.1.1 description R1  
  neighbor 2.2.2.3 remote-as 2  
  neighbor 2.2.2.3 description R3  
  neighbor 4.4.4.4 remote-as 4  
  nieghbor 4.4.4.4 description R4  
  no auto-summary  
 !  

 !  
 hostname R3  
 !  
 router bgp 2  
  no synchronization  
  bgp log-neighbor-changes  
  neighbor 2.2.2.2 remote-as 2   
  neighbor 2.2.2.2 description R2  
  no auto-summary  
 !  

 !  
 hostname R4  
 !  
 router bgp 4  
  no synchronization  
  bgp log-neighbor-changes  
  neighbor 4.4.4.2 remote-as 2  
  neighbor 4.4.4.2 description R2  
  no auto-summary  
 !  

Time to verify that R2 is not advertising the loopback 11.11.11.11/32 to any other BGP peers (eBGP and iBGP).
BGP is up with all the routers and 1 prefix is being received from R1 as configured. 
The route in the BGP table is not being advertised to R3 or R4 but why??
There it is ...
In conclusion communities can be very flexible, however just keep in mind that they are optional transitive attributes and also remember to type "neighbor x.x.x.x send-community <standard|extended|both> or else the router will not send any communities even if you are setting them with route-map and set community command.


Many more articles to come so stay tuned.

Please subscribe/comment/+1 if you like my posts as it keeps me motivated to write more and spread the knowledge.


3 comments:

  1. I like your posts so much , Written in great detail.Expect your more articles.

    ReplyDelete
    Replies
    1. Thank you -- please subscribe by email. Posts will be made almost daily or a few of them / per week. Stay tuned :)

      Delete
  2. This comment has been removed by a blog administrator.

    ReplyDelete