BGP IPv4 - Conditional Advertisement

Conditional Advertisement

BGP IPv4 Conditional Advertisement is a feature within the Border Gateway Protocol (BGP) that allows network administrators to selectively advertise routes based on predefined conditions. With conditional advertisement, network operators can control the announcement of specific prefixes to BGP peers, triggering route advertisements only when certain criteria are met. This feature is particularly useful in scenarios where dynamic routing decisions need to be influenced based on specific network conditions or policies. By leveraging BGP conditional advertisement, operators can implement more granular control over the distribution of routing information, optimizing network behavior and resource utilization. This capability enhances the flexibility and precision of BGP routing strategies, contributing to efficient network management and better alignment with organizational requirements.

Lab:

BGP Topology

Disclaimer

This Configuration Guide is designed to assist members to enhance their skills in particular technology area. While every effort has been made to ensure that all material is as complete and accurate as possible, the enclosed material is presented on an “as is” basis. Neither the authors nor Forum assume any liability or responsibility to any person or entity with respect to loss or damages incurred from the information contained in this guide. This configuration guide was developed by Forum. Any similarities between material presented in this configuration guide and any other material is completely coincidental.

Cisco IOS Software, Linux Software (I86BI_LINUX-ADVENTERPRISEK9-M), Version 15.2(4)M1, DEVELOPMENT TEST SOFTWARE

Task 1: Configure IPv4 BGP Conditional Advertisement when network 33.33.33.33/24 exist in R2 BGP table.

Step 1: In the configuration mode of router configure IPv4 BGP Process by following command:

R1: 
interface Serial2/0
ip address 12.0.0.1 255.255.255.0
no shutdown
interface Loopback1
ip address 11.11.11.11 255.255.255.0

router bgp 65001
neighbor 12.0.0.2 remote-as 65002
address-family ipv4
network 11.11.11.0 mask 255.255.255.0
exit

R2: 
interface Serial2/0
ip address 12.0.0.2 255.255.255.0
no shutdown
interface Ethernet0/0
ip address 23.0.0.2 255.255.255.0
no shutdown
interface Loopback1
ip address 22.22.22.22 255.255.255.0

router bgp 65002
neighbor 12.0.0.1 remote-as 65001
neighbor 23.0.0.3 remote-as 65003
address-family ipv4
network 22.22.22.0 mask 255.255.255.0 
exit

R3: 
interface Ethernet0/0
ip address 23.0.0.3 255.255.255.0
no shutdown
interface Loopback1
ip address 33.33.33.33 255.255.255.0

router bgp 65003
neighbor 23.0.0.2 remote-as 65002
address-family ipv4
network 33.33.33.0 mask 255.255.255.0
exit

Step 2: Configure BGP Conditional Advertisement on router R2

R2:
router bgp 65002
neighbor 12.0.0.1 remote-as 65001
address-family ipv4
neighbor 12.0.0.1 advertise-map ADVERTISE non-exist-map NON-EXIST
//Advertises the routes matched in the route−map ADVERTISE (22.22.22.22/24) only if the routes matched in route−map NON−EXIST (33.33.33.33/24) do not exist in the BGP table.

route-map ADVERTISE permit 5
match ip address 5
exit
route-map NON-EXIST permit 10
match ip address 10
exit

access-list 5 permit 22.22.22.22 0.0.0.255
access-list 10 permit 33.33.33.33 0.0.0.255

Step 3: Verify the output when 33.33.33.33/24 exist in R2 BGP table

R2#show bgp ipv4 unicast
BGP table version is 7, local router ID is 22.22.22.22
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          	Next Hop       Metric 	LocPrf  	Weight  	Path
 *>  11.11.11.0/24    	12.0.0.1         0        0 	    	        65001 i
 *>  22.22.22.0/24    	0.0.0.0          0         		    32768 	    i
 *>  33.33.33.0/24    	23.0.0.3         0        0 		            65003 i

Since 33.33.33.33/24 is in R2's BGP table, then R2 must not advertise 22.22.22.22/24 to R1
R2#show ip bgp neighbors 12.0.0.1 advertised-routes
BGP table version is 7, local router ID is 22.22.22.22
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop      Metric     LocPrf     Weight      Path
 *>  33.33.33.0/24    23.0.0.3        0          0                    65003 i
Total number of prefixes 1

R2#show ip bgp neighbors 12.0.0.1
BGP neighbor is 12.0.0.1,  remote AS 65001, external link
BGP version 4, remote router ID 11.11.11.11
BGP state = Established, up for 20:14:11
Last read 00:00:14, last write 00:00:31, hold time is 180, keepalive interval is 60 seconds
For address family: IPv4 Unicast
Session: 12.0.0.1
BGP table version 7, neighbor version 7/0
Index 2, Advertise bit 1
2 update-group member
Condition-map NON-EXIST, Advertise-map ADVERTISE, status: Withdraw
The output shows that the conditional advertisement is "Withdrawn" and that the networks that match the route−map "ADVERTISE" are not announced to the peer 12.0.0.1
R1#show ip bgp 22.22.22.22
% Network not in table

R1#show ip bgp
BGP table version is 7, local router ID is 11.11.11.11
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          	Next Hop        Metric  	LocPrf 	  Weight 	Path
 *>  11.11.11.0/24    	0.0.0.0           0                   32768 	i
 *>  33.33.33.0/24    	12.0.0.2                       0 		        65002 65003 i

Hence when 33.33.33.33/24 is in R2's BGP table, then R2 will not advertise 22.22.22.22/24 to R1 due to conditional advertisement.

Task 2: Configure IPv4 BGP Conditional Advertisement when network 33.33.33.33/24 does not exist in R2 BGP table.

Step 1: Shutdown Loopback interface 1 on router R3, so that R3 no longer announce 33.33.33.33/24 to router R2

R3:
interface loopback1
shutdown

R2#debug ip bgp updates
BGP updates debugging is on for address family: IPv4 Unicast
R2#
*Oct  8 04:03:20.698: BGP(0): 23.0.0.3 rcv UPDATE about 33.33.33.0/24 -- withdrawn
*Oct  8 04:03:20.698: BGP(0): no valid path for 33.33.33.0/24
*Oct  8 04:03:20.699: BGP: topo global:IPv4 Unicast:base Remove_fwdroute for 33.33.33.0/24
*Oct  8 04:03:20.699: BGP(0): (base) 12.0.0.1 send unreachable (format) 33.33.33.0/24
R2#
*Oct  8 04:03:30.455: BPG(0): Condition NON-EXIST changes to Advertise
*Oct  8 04:03:30.455: BGP(0): net 22.22.22.0/24 matches ADV MAP ADVERTISE: bump version to 9
*Oct  8 04:03:30.472: BGP: topo global:IPv4 Unicast:base Remove_fwdroute for 22.22.22.0/24
*Oct  8 04:03:50.759: BGP(0): (base) 12.0.0.1 send UPDATE (format) 22.22.22.0/24, next 12.0.0.2, metric 0, path Local

R2#show ip bgp
BGP table version is 9, local router ID is 22.22.22.22
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
     Network          	Next Hop        Metric 	    LocPrf 	   Weight 	  Path
*>  11.11.11.0/24    	12.0.0.1          0           0 		          65001 i
*>  22.22.22.0/24    	0.0.0.0           0         		   32768 	  i

The conditional advertisement process is triggered by the BGP scanner process, which runs every 60 seconds. This means that the maximum time for the conditional advertisement to take effect is 60 seconds
R2#show ip bgp neighbors 12.0.0.1
BGP neighbor is 12.0.0.1,  remote AS 65001, external link
BGP version 4, remote router ID 11.11.11.11
BGP state = Established, up for 20:53:33
Last read 00:00:43, last write 00:00:43, hold time is 180, keepalive interval is 60 seconds
For address family: IPv4 Unicast
Session: 12.0.0.1
BGP table version 9, neighbor version 9/0
Output queue size : 0
Index 2, Advertise bit 1
2 update-group member
Condition-map NON-EXIST, Advertise-map ADVERTISE, status: Advertise
R1#show ip bgp
BGP table version is 3, local router ID is 11.11.11.11
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop       Metric      LocPrf      Weight       Path
 *>  11.11.11.0/24    0.0.0.0          0                     32768         i
 *>  22.22.22.0/24    12.0.0.2         0           0                      65002 i

Hence when 33.33.33.33/24 is not announce by R3 to R2's, then R2 will advertise 22.22.22.22/24 to R1 due to conditional advertisement.

Task 3: BGP Conditional Advertisement by reversing the condition

Step 1: Configure router R2 by reversing the condition for neighbor R1

R2:
router bgp 65002
neighbor 12.0.0.1 remote-as 65001
address-family ipv4
neighbor 12.0.0.1 advertise-map ADVERTISE exist-map EXIST
exit
//Advertises the routes matched in the route−map ADVERTISE (22.22.22.22/24) only if the routes matched in route−map EXIST (33.33.33.33/24) do exist in the BGP table.

route-map ADVERTISE permit 5
match ip address 5
exit
route-map EXIST permit 10
match ip address 10
exit

access-list 5 permit 22.22.22.22 0.0.0.255
access-list 10 permit 33.33.33.33 0.0.0.255

Step 2: Verify BGP Conditional Advertisement

R2#show ip bgp
BGP table version is 15, local router ID is 22.22.22.22
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          	Next Hop        Metric   	LocPrf  	Weight  	Path
*>  11.11.11.0/24    	12.0.0.1          0           0 		            65001 i
*>  22.22.22.0/24    	0.0.0.0           0         		    32768 	    i
*>  33.33.33.0/24    	23.0.0.3          0           0 		            65003 i

R2#show ip bgp neighbors 12.0.0.1
BGP neighbor is 12.0.0.1,  remote AS 65001, external link
BGP version 4, remote router ID 11.11.11.11
BGP state = Established, up for 00:20:44
Last read 00:00:12, last write 00:00:06, hold time is 180, keepalive interval is 60 seconds
For address family: IPv4 Unicast
Session: 12.0.0.1
BGP table version 15, neighbor version 15/0
Output queue size : 0
Index 3, Advertise bit 1
3 update-group member
Condition-map EXIST, Advertise-map ADVERTISE, status: Advertise

R1#show ip bgp
BGP table version is 6, local router ID is 11.11.11.11
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          	Next Hop        Metric   	LocPrf  	Weight     Path
 *>  11.11.11.0/24    	0.0.0.0            0         	        32768 	   i
 *>  22.22.22.0/24    	12.0.0.2           0                    0 	       65002 i
 *>  33.33.33.0/24    	12.0.0.2                               	0 	       65002 65003 i

Hence when 33.33.33.33/24 is announce by R3 to R2's, then R2 will advertise 22.22.22.22/24 to R1 due to conditional advertisement.

R3:
interface loopback1
shutdown

R2#show ip bgp
BGP table version is 17, local router ID is 22.22.22.22
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          	Next Hop       Metric 	  LocPrf 	Weight 	Path
*>  11.11.11.0/24    	12.0.0.1         0          	      0      65001 i
*>  22.22.22.0/24    	0.0.0.0          0         		    32768 	i

R2#debug ip bgp updates
*Oct  8 04:40:32.029: BPG(0): Condition EXIST changes to Withdraw
*Oct  8 04:40:32.029: BGP(0): net 22.22.22.0/24 matches ADV MAP ADVERTISE: bump version to 17
*Oct  8 04:40:32.047: BGP: topo global:IPv4 Unicast:base Remove_fwdroute for 22.22.22.0/24
R2#
*Oct  8 04:40:40.875: BGP(0): (base) 12.0.0.1 send unreachable (format) 22.22.22.0/24

R2#show ip bgp neighbors 12.0.0.1
BGP neighbor is 12.0.0.1,  remote AS 65001, external link
BGP version 4, remote router ID 11.11.11.11
BGP state = Established, up for 01:08:44
Last read 00:00:21, last write 00:00:08, hold time is 180, keepalive interval is 60 seconds
For address family: IPv4 Unicast
Session: 12.0.0.1
BGP table version 17, neighbor version 17/0
Output queue size : 0
Index 3, Advertise bit 1
3 update-group member
Condition-map EXIST, Advertise-map ADVERTISE, status: Withdraw

R1#show ip bgp
BGP table version is 8, local router ID is 11.11.11.11
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          	Next Hop      Metric 	LocPrf 	Weight 	Path
*>  11.11.11.0/24    	0.0.0.0         0         		32768 	i

Hence when 33.33.33.33/24 is not announce by R3 to R2's, then R2 also will not advertise 22.22.22.22/24 to R1 due to conditional advertisement.