BGP Advertise-Map for Conditional BGP Route Advertisement
Table of Contents
- What is BGP conditional advertisement? ‹
- How to configure BGP advertise-map? ‹
- BGP advertise-map with default route ‹
- Download section ‹
What is BGP conditional advertisement?
BGP conditional advertisement is a mechanism to influence inbound routing decisions or ingress routing. It is useful in dual homed scenarios where a router advertises its local prefixes to multiple BGP neighbors. Note that any BGP advertisement by a local router will attract traffic for that particular prefix. In response, conditional advertisement ensures that a local prefix is advertised to only one BGP neighbor at any given time.
Specifically, a BGP advertise-map configuration instructs a local router to advertise a particular route only if another particular route is received in its routing table. Thus, a router verifies the presence of a route (such as a default route) in its RIB, and if it is present, then the local router may withdraw any number of prefix from redundant/secondary BGP neigbors.
How to configure BGP advertise-map?
In this example scenario, R1 receives the prefix 192.168.2.0 /24 from R2 and R3. In order to reach 192.168.2.0 /24, R1 prefers R2 as the next-hop. This is configured with the local preference attribute. However, R1 can also influence inbound routing decisions. By configuring BGP conditional advertisement, R1 can monitor the prefix 192.168.2.0 /24 received from R2 and trigger actions.
With an advertise-map R1 can be instructed to do the following:
- if R1 receives 192.168.2.0 /24 from R2, then R1 does not advertise 192.168.1.0 /24 to R3
- if R1 does not receive 192.168.2.0 /24 from R2, then R1 advertises 192.168.1.0 /24 to R3
Configuration:
R1
R1#show run int Gi0/0 | sec int interface GigabitEthernet0/0 description ** to Host ** ip address 192.168.1.1 255.255.255.0 duplex auto speed auto media-type rj45 R1#show run int Gi0/1 | sec int interface GigabitEthernet0/1 description ** to R2 ** ip address 10.1.0.1 255.255.255.252 duplex auto speed auto media-type rj45 R1#show run int Gi0/2 | sec int interface GigabitEthernet0/2 description ** to R3 ** ip address 10.2.0.1 255.255.255.252 duplex auto speed auto media-type rj45 R1#show run int Lo10 | sec int interface Loopback10 ip address 1.1.1.1 255.255.255.255 R1#show run | sec ^router router bgp 65001 bgp router-id 1.1.1.1 bgp log-neighbor-changes network 192.168.1.0 neighbor 2.2.2.2 remote-as 65010 neighbor 2.2.2.2 ebgp-multihop 255 neighbor 2.2.2.2 update-source Loopback10 neighbor 2.2.2.2 route-map RM-LOC-PREF in neighbor 3.3.3.3 remote-as 65020 neighbor 3.3.3.3 ebgp-multihop 255 neighbor 3.3.3.3 update-source Loopback10 neighbor 3.3.3.3 advertise-map RM-ADVERTISE non-exist-map RM-NON-EXIST R1#show run | sec ^route-map route-map RM-NON-EXIST permit 10 match ip address prefix-list PL-NON-EXIST match ip route-source prefix-list PL-ROUTE-SOURCE route-map RM-LOC-PREF permit 10 match ip address prefix-list PL-LOC-PREF set local-preference 200 route-map RM-ADVERTISE permit 10 match ip address prefix-list PL-ADVERTISE R1#show run | sec ^ip prefix ip prefix-list PL-ADVERTISE seq 5 permit 192.168.1.0/24 ip prefix-list PL-LOC-PREF seq 5 permit 192.168.2.0/24 ip prefix-list PL-NON-EXIST seq 5 permit 192.168.2.0/24 ip prefix-list PL-ROUTE-SOURCE seq 5 permit 2.2.2.2/32 R1#show run | sec ^ip route ip route 2.2.2.2 255.255.255.255 GigabitEthernet0/1 10.1.0.2 ip route 3.3.3.3 255.255.255.255 GigabitEthernet0/2 10.2.0.2
R2
R2#show run int Gi0/0 | sec int interface GigabitEthernet0/0 description ** to R1 ** ip address 10.1.0.2 255.255.255.252 duplex auto speed auto media-type rj45 R2#show run int Gi0/1 | sec int interface GigabitEthernet0/1 description ** to R4 ** ip address 10.3.0.2 255.255.255.252 duplex auto speed auto media-type rj45 R2#show run int Lo10 | sec int interface Loopback10 ip address 2.2.2.2 255.255.255.255 R2#show run | sec ^router router bgp 65010 bgp router-id 2.2.2.2 bgp log-neighbor-changes neighbor 1.1.1.1 remote-as 65001 neighbor 1.1.1.1 ebgp-multihop 255 neighbor 1.1.1.1 update-source Loopback10 neighbor 4.4.4.4 remote-as 65002 neighbor 4.4.4.4 ebgp-multihop 255 neighbor 4.4.4.4 update-source Loopback10 R2#show run | sec ^ip route ip route 1.1.1.1 255.255.255.255 GigabitEthernet0/0 10.1.0.1 ip route 4.4.4.4 255.255.255.255 GigabitEthernet0/1 10.3.0.1
R3
R3#show run int Gi0/0 | sec int interface GigabitEthernet0/0 description ** to R1 ** ip address 10.2.0.2 255.255.255.252 duplex auto speed auto media-type rj45 R3#show run int Gi0/1 | sec int interface GigabitEthernet0/1 description ** to R4 ** ip address 10.4.0.2 255.255.255.252 duplex auto speed auto media-type rj45 R3#show run int Lo10 | sec int interface Loopback10 ip address 3.3.3.3 255.255.255.255 R3#show run | sec ^router router bgp 65020 bgp router-id 3.3.3.3 bgp log-neighbor-changes neighbor 1.1.1.1 remote-as 65001 neighbor 1.1.1.1 ebgp-multihop 255 neighbor 1.1.1.1 update-source Loopback10 neighbor 4.4.4.4 remote-as 65002 neighbor 4.4.4.4 ebgp-multihop 255 neighbor 4.4.4.4 update-source Loopback10 R3#show run | sec ^ip route ip route 1.1.1.1 255.255.255.255 GigabitEthernet0/0 10.2.0.1 ip route 4.4.4.4 255.255.255.255 GigabitEthernet0/1 10.4.0.1
R4
R4#show run int Gi0/0 | sec int interface GigabitEthernet0/0 description ** to Server ** ip address 192.168.2.1 255.255.255.0 duplex auto speed auto media-type rj45 R4#show run int Gi0/1 | sec int interface GigabitEthernet0/1 description ** to R2 ** ip address 10.3.0.1 255.255.255.252 duplex auto speed auto media-type rj45 R4#show run int Gi0/2 | sec int interface GigabitEthernet0/2 description ** to R3 ** ip address 10.4.0.1 255.255.255.252 duplex auto speed auto media-type rj45 R4#show run int Lo10 | sec int interface Loopback10 ip address 4.4.4.4 255.255.255.255 R4#show run | sec ^router router bgp 65002 bgp router-id 4.4.4.4 bgp log-neighbor-changes network 192.168.2.0 neighbor 2.2.2.2 remote-as 65010 neighbor 2.2.2.2 ebgp-multihop 255 neighbor 2.2.2.2 update-source Loopback10 neighbor 3.3.3.3 remote-as 65020 neighbor 3.3.3.3 ebgp-multihop 255 neighbor 3.3.3.3 update-source Loopback10 R4#show run | sec ^ip route ip route 2.2.2.2 255.255.255.255 GigabitEthernet0/1 10.3.0.2 ip route 3.3.3.3 255.255.255.255 GigabitEthernet0/2 10.4.0.2
R1#show ip bgp neighbors 3.3.3.3 policy Neighbor: 3.3.3.3, Address-Family: IPv4 Unicast Locally configured policies: « Conditional advertisement is a locally configured BGP policy advertise-map RM-ADVERTISE non-exist-map RM-NON-EXIST R1#show ip bgp neighbors 3.3.3.3 | section Condition Condition-map RM-NON-EXIST, Advertise-map RM-ADVERTISE, status: Withdraw « Currrently, 192.168.1.0/24 is not advertised to R3 R1#show ip route bgp | beg Ga Gateway of last resort is not set B 192.168.2.0/24 [20/0] via 2.2.2.2, 00:17:33 R4#show ip bgp | beg Ne Network Next Hop Metric LocPrf Weight Path *> 192.168.1.0 2.2.2.2 0 65010 65001 i « R4 in AS 65002 only receives route to AS 65002 from R2 *> 192.168.2.0 0.0.0.0 0 32768 i Host#trace 192.168.2.2 probe 1 Type escape sequence to abort. Tracing the route to 192.168.2.2 VRF info: (vrf in name/id, vrf out name/id) 1 192.168.1.1 2 msec 2 10.1.0.2 2 msec « From the Host to the Server the path through R2 is chosen 3 10.3.0.1 2 msec 4 192.168.2.2 3 msec Server#trace 192.168.1.2 probe 1 Type escape sequence to abort. Tracing the route to 192.168.1.2 VRF info: (vrf in name/id, vrf out name/id) 1 192.168.2.1 2 msec 2 10.3.0.2 2 msec « From the Server to the Host the path through R2 is chosen 3 10.1.0.1 2 msec 4 192.168.1.2 3 msec
As visible in the above router outputs, the conditional advertisement on R2 influences inbound routing, from the Server to the Host. As a result, a symmetric traffic flow is achieved between the Host and Server, with R2 being used as the transit router in both directions.
The following output is shown when R1 no longer receives the prefix 192.168.2.0 /24 to from R2. In such a scenario, the prefix 192.168.1.0 /24 is advertised from R1 to R3, and as a result R4 starts using R3 to reach AS 65001.
R1#show ip bgp neighbors 3.3.3.3 | section Condition Condition-map RM-NON-EXIST, Advertise-map RM-ADVERTISE, status: Advertise R4#show ip bgp | beg Ne Network Next Hop Metric LocPrf Weight Path *> 192.168.1.0 3.3.3.3 0 65020 65001 i *> 192.168.2.0 0.0.0.0 0 32768 i
BGP advertise-map with default route
In the following scenario, R2 and R3 only advertise a single default route to R1. Meanwhile, R1 prefers the default route received from R2 in order to reach the Server. This is accomplished with the local preference attrubite configured on R1. So this configuration influences outbound traffic.
However, R1 can also influence inbound traffic destined to R1 by configuring BGP conditional advertisement. An advertise-map on R1 instructs the router to only advertise the prefix 192.168.1.0 /24 to R3, if the default route is not received from R2. In other words, until R2 advertises its default route to R1, R1 will not advertise 192.168.1.0 /24 to R3. This means that traffic coming from the Server will symmetrically mirror the path chosen by R1, and predictably either choose R2 or R3 to reach the Host.
Configuration:
R1
R1#show run int Gi0/0 | sec int interface GigabitEthernet0/0 description ** to Host ** ip address 192.168.1.1 255.255.255.0 duplex auto speed auto media-type rj45 R1#show run int Gi0/1 | sec int interface GigabitEthernet0/1 description ** to R2 ** ip address 10.1.0.1 255.255.255.252 duplex auto speed auto media-type rj45 R1#show run int Gi0/2 | sec int interface GigabitEthernet0/2 description ** to R3 ** ip address 10.2.0.1 255.255.255.252 duplex auto speed auto media-type rj45 R1#show run int Lo10 | sec int interface Loopback10 ip address 1.1.1.1 255.255.255.255 R1#show run | sec ^router router bgp 65001 bgp router-id 1.1.1.1 bgp log-neighbor-changes network 192.168.1.0 neighbor 2.2.2.2 remote-as 65010 neighbor 2.2.2.2 ebgp-multihop 255 neighbor 2.2.2.2 update-source Loopback10 neighbor 2.2.2.2 route-map RM-LOC-PREF in neighbor 3.3.3.3 remote-as 65020 neighbor 3.3.3.3 ebgp-multihop 255 neighbor 3.3.3.3 update-source Loopback10 neighbor 3.3.3.3 advertise-map RM-ADVERTISE non-exist-map RM-NON-EXIST R1#show run | sec ^route-map route-map RM-NON-EXIST permit 10 match ip address prefix-list PL-NON-EXIST match ip route-source prefix-list PL-ROUTE-SOURCE route-map RM-LOC-PREF permit 10 match ip address prefix-list PL-LOC-PREF set local-preference 200 route-map RM-ADVERTISE permit 10 match ip address prefix-list PL-ADVERTISE R1#show run | sec ^ip prefix ip prefix-list PL-ADVERTISE seq 5 permit 192.168.1.0/24 ip prefix-list PL-LOC-PREF seq 5 permit 0.0.0.0/0 le 32 ip prefix-list PL-NON-EXIST seq 5 permit 0.0.0.0/0 ip prefix-list PL-ROUTE-SOURCE seq 5 permit 2.2.2.2/32 R1#show run | sec ^ip route ip route 2.2.2.2 255.255.255.255 GigabitEthernet0/1 10.1.0.2 ip route 3.3.3.3 255.255.255.255 GigabitEthernet0/2 10.2.0.2
R2
R2#show run int Gi0/0 | sec int interface GigabitEthernet0/0 description ** to R1 ** ip address 10.1.0.2 255.255.255.252 duplex auto speed auto media-type rj45 R2#show run int Gi0/1 | sec int interface GigabitEthernet0/1 description ** to R4 ** ip address 10.3.0.2 255.255.255.252 duplex auto speed auto media-type rj45 R2#show run int Lo10 | sec int interface Loopback10 ip address 2.2.2.2 255.255.255.255 R2#show run | sec ^router router bgp 65010 bgp router-id 2.2.2.2 bgp log-neighbor-changes neighbor 1.1.1.1 remote-as 65001 neighbor 1.1.1.1 ebgp-multihop 255 neighbor 1.1.1.1 update-source Loopback10 neighbor 1.1.1.1 default-originate neighbor 1.1.1.1 route-map RM-BGP-ADV out neighbor 4.4.4.4 remote-as 65002 neighbor 4.4.4.4 ebgp-multihop 255 neighbor 4.4.4.4 update-source Loopback10 R2#show run | sec ^route-map route-map RM-BGP-ADV permit 5 match ip address prefix-list PL-DEFAULT route-map RM-BGP-ADV deny 10 R2#show run | sec ^ip prefix ip prefix-list PL-DEFAULT seq 5 permit 0.0.0.0/0 R2#show run | sec ^ip route ip route 1.1.1.1 255.255.255.255 GigabitEthernet0/0 10.1.0.1 ip route 4.4.4.4 255.255.255.255 GigabitEthernet0/1 10.3.0.1
R3
R3#show run int Gi0/0 | sec int interface GigabitEthernet0/0 description ** to R1 ** ip address 10.2.0.2 255.255.255.252 duplex auto speed auto media-type rj45 R3#show run int Gi0/1 | sec int interface GigabitEthernet0/1 description ** to R4 ** ip address 10.4.0.2 255.255.255.252 duplex auto speed auto media-type rj45 R3#show run int Lo10 | sec int interface Loopback10 ip address 3.3.3.3 255.255.255.255 R3#show run | sec ^router router bgp 65020 bgp router-id 3.3.3.3 bgp log-neighbor-changes neighbor 1.1.1.1 remote-as 65001 neighbor 1.1.1.1 ebgp-multihop 255 neighbor 1.1.1.1 update-source Loopback10 neighbor 1.1.1.1 default-originate neighbor 1.1.1.1 route-map RM-BGP-ADV out neighbor 4.4.4.4 remote-as 65002 neighbor 4.4.4.4 ebgp-multihop 255 neighbor 4.4.4.4 update-source Loopback10 R3#show run | sec ^route-map route-map RM-BGP-ADV permit 5 match ip address prefix-list PL-DEFAULT route-map RM-BGP-ADV deny 10 R3#show run | sec ^ip prefix ip prefix-list PL-DEFAULT seq 5 permit 0.0.0.0/0 R3#show run | sec ^ip route ip route 1.1.1.1 255.255.255.255 GigabitEthernet0/0 10.2.0.1 ip route 4.4.4.4 255.255.255.255 GigabitEthernet0/1 10.4.0.1
R4
R4#show run int Gi0/0 | sec int interface GigabitEthernet0/0 description ** to Server ** ip address 192.168.2.1 255.255.255.0 duplex auto speed auto media-type rj45 R4#show run int Gi0/1 | sec int interface GigabitEthernet0/1 description ** to R2 ** ip address 10.3.0.1 255.255.255.252 duplex auto speed auto media-type rj45 R4#show run int Gi0/2 | sec int interface GigabitEthernet0/2 description ** to R3 ** ip address 10.4.0.1 255.255.255.252 duplex auto speed auto media-type rj45 R4#show run int Lo10 | sec int interface Loopback10 ip address 4.4.4.4 255.255.255.255 R4#show run | sec ^router router bgp 65002 bgp router-id 4.4.4.4 bgp log-neighbor-changes network 192.168.2.0 neighbor 2.2.2.2 remote-as 65010 neighbor 2.2.2.2 ebgp-multihop 255 neighbor 2.2.2.2 update-source Loopback10 neighbor 3.3.3.3 remote-as 65020 neighbor 3.3.3.3 ebgp-multihop 255 neighbor 3.3.3.3 update-source Loopback10 R4#show run | sec ^ip route ip route 2.2.2.2 255.255.255.255 GigabitEthernet0/1 10.3.0.2 ip route 3.3.3.3 255.255.255.255 GigabitEthernet0/2 10.4.0.2
R1#show ip bgp neighbors 3.3.3.3 | section Condition Condition-map RM-NON-EXIST, Advertise-map RM-ADVERTISE, status: Withdraw « R1 receives the default route from R2 R1#show ip bgp | beg Ne Network Next Hop Metric LocPrf Weight Path *> 0.0.0.0 2.2.2.2 200 0 65010 i * 3.3.3.3 0 65020 i *> 192.168.1.0 0.0.0.0 0 32768 i Host#trace 192.168.2.2 probe 1 Type escape sequence to abort. Tracing the route to 192.168.2.2 VRF info: (vrf in name/id, vrf out name/id) 1 192.168.1.1 2 msec 2 10.1.0.2 2 msec 3 10.3.0.1 3 msec 4 192.168.2.2 3 msec Server#trace 192.168.1.2 probe 1 Type escape sequence to abort. Tracing the route to 192.168.1.2 VRF info: (vrf in name/id, vrf out name/id) 1 192.168.2.1 2 msec 2 10.3.0.2 2 msec 3 10.1.0.1 3 msec 4 192.168.1.2 3 msec
As visible in the above outputs, until R2 advertises the default route to R1, the symmetric traffic flow will be through R2.