Friday, February 21, 2020

BGP Community No Advertise

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:
BGP Community No Advertise Topology
Above you can see R1 with a loopback interface that has network 1.1.1.1 /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).

Configuration

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.
Let’s see if R2, R3 and R4 have learned our prefix:
R2#show ip bgp | include 1.1.1.1
*> 1.1.1.1/32       192.168.12.1             0             0 1 i
R3#show ip bgp | include 1.1.1.1
*> 1.1.1.1/32       192.168.23.2                           0 24 1 i
R4#show ip bgp | include 1.1.1.1
* i1.1.1.1/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:
R1(config)#router bgp 1
R1(config-router)#neighbor 192.168.12.2 route-map NO_ADVERTISE out
The route-map is now activated on R1 for everything that is advertises to R2.
In this example I set the BGP community outbound on R1. It’s also possible to configure it inbound on R2.
Before we reset BGP to activate our changes, let’s take a closer look at the BGP table:
R2#show ip bgp 1.1.1.1
BGP routing table entry for 1.1.1.1/32, version 2
Paths: (1 available, best #1, table Default-IP-Routing-Table)
Flag: 0x820
  Advertised to update-groups:
        1    2
  1
    192.168.12.1 from 192.168.12.1 (192.168.12.1)
      Origin IGP, metric 0, localpref 100, valid, external, best
Above you see the BGP table entry for 1.1.1.1/32 without any community information. Let’s reset BGP so you can see the difference:
R2#clear ip bgp *
Now you will see this:
R2#show ip bgp 1.1.1.1
BGP routing table entry for 1.1.1.1/32, version 2
Paths: (1 available, best #1, table Default-IP-Routing-Table, not advertised to any peer)
Flag: 0x820
  Not advertised to any peer
  1
    192.168.12.1 from 192.168.12.1 (192.168.12.1)
      Origin IGP, metric 0, localpref 100, valid, external, best
      Community: no-advertise
R2 learned the prefix and you can see the no-advertise community. As a result, it will no longer advertise this prefix to R3 or R4:
R2#show ip bgp neighbors 192.168.24.4 advertised-routes

Total number of prefixes 0
R2#show ip bgp neighbors 192.168.23.3 advertised-routes

Total number of prefixes 0
The advertised-routes parameter is a great way to see what you are advertising on your routers. Another option would be to check the BGP table of R3 and R4 directly:
R3#show ip bgp 1.1.1.1
% Network not in table
R4#show ip bgp 1.1.1.1
% Network not in table
There’s nothing there…mission accomplished.
hostname R1
!
ip cef
!
interface Loopback0
 ip address 1.1.1.1 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 1.1.1.1 mask 255.255.255.255
 neighbor 192.168.12.2 remote-as 24
 neighbor 192.168.12.2 send-community
 neighbor 192.168.12.2 route-map NO_ADVERTISE out
!
route-map NO_ADVERTISE permit 10
 set community no-advertise
!
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

Make sure you also check out the other two BGP communities:
I hope this example has been helpful to understand the BGP no advertise community, if you have any questions just leave a comment!

No comments:

Post a Comment