The BGP No Advertise community is one of the four well known communities. If you have no idea what BGP communities are about, I would suggest to check the introduction lesson first. That’s where you will learn about the basics of BGP communities.
When you add the no-advertise community to a prefix then the receiving BGP router will use and store the prefix in its BGP table but it won’t advertise the prefix to any other neighbors.
Let’s look at an example, this is the topology I will use:
Above you can see R1 with a loopback interface that has network 18.104.22.168 /32. We will advertise this network in BGP towards R2 with the no advertise community set. As a result, R2 will not advertise it to R3 (eBGP) or R4 (iBGP).
Here’s the basic BGP configuration in case you want to try this example yourself.
Want to take a look for yourself? Here you will find the startup configuration of each device.
hostname R1 ! ip cef ! interface Loopback0 ip address 22.214.171.124 255.255.255.255 ! interface GigabitEthernet0/1 ip address 192.168.12.1 255.255.255.0 ! router bgp 1 bgp log-neighbor-changes network 126.96.36.199 mask 255.255.255.255 neighbor 192.168.12.2 remote-as 24 ! end
hostname R2 ! ip cef ! interface GigabitEthernet0/1 ip address 192.168.12.2 255.255.255.0 ! interface GigabitEthernet0/2 ip address 192.168.23.2 255.255.255.0 ! interface GigabitEthernet0/3 ip address 192.168.24.2 255.255.255.0 ! router bgp 24 bgp log-neighbor-changes neighbor 192.168.12.1 remote-as 1 neighbor 192.168.23.3 remote-as 3 neighbor 192.168.24.4 remote-as 24 neighbor 192.168.24.4 next-hop-self ! end
hostname R3 ! ip cef ! interface GigabitEthernet0/1 ip address 192.168.23.3 255.255.255.0 ! router bgp 3 bgp log-neighbor-changes neighbor 192.168.23.2 remote-as 24 ! end
hostname R4 ! ip cef ! interface GigabitEthernet0/1 ip address 192.168.24.4 255.255.255.0 ! router bgp 24 bgp log-neighbor-changes neighbor 192.168.24.2 remote-as 24 ! end
Let’s see if R2, R3 and R4 have learned our prefix:
R2#show ip bgp | include 188.8.131.52 *> 184.108.40.206/32 192.168.12.1 0 0 1 i
R3#show ip bgp | include 220.127.116.11 *> 18.104.22.168/32 192.168.23.2 0 24 1 i
R4#show ip bgp | include 22.214.171.124 * i126.96.36.199/32 192.168.24.2 0 100 0 1 i
It’s in the BGP table of these routers. Now let’s configure R1 to add the no advertise community:
R1(config)#router bgp 1 R1(config-router)#neighbor 192.168.12.2 send-community
First we have to tell R1 to send BGP communities, by default this is disabled. Now we can create a route-map that sets the community value:
R1(config)#route-map NO_ADVERTISE permit 10 R1(config-route-map)#set community no-advertise
This route-map doesn’t have any match statements so it will set the no advertise community to all prefixes. Let’s activate it: