Tuesday, March 15, 2011

BGP Conditional Advertisement

BGP Conditional Advertisement

It is often necessarily to conditionally advertise or inject some routes to upstream neighbors when implementing traffic engineering to control traffic flow for packets destined to a particular network. BGP has the capability to conditionally advertise routes.

In the sample scenario above, AS 300 would like to advertise 172.16.1.0/24 to ISP1 as long as the RT1 – ISP1 link is up; and would like to advertise the route to ISP2 from RT2 should the link fails.

Below shows the configuration on RT2 to achieve the mentioned objective:

!
router bgp 300
 no synchronization
 neighbor 11.11.11.2 remote-as 200
 neighbor 11.11.11.2 distribute-list 20 out
 neighbor 11.11.11.2 advertise-map TO-ADVERTISE non-exist-map IF-NOT-EXIST
 neighbor 12.12.12.1 remote-as 300
!
!
access-list 10 permit 172.16.1.0 0.0.0.255
access-list 20 deny 10.10.10.0 0.0.0.3
access-list 20 permit any
access-list 30 permit 10.10.10.0 0.0.0.3
!
route-map IF-NOT-EXIST permit 10
 match ip address 30
!
route-map IF-NOT-EXIST deny 20
!
route-map TO-ADVERTISE permit 10
 match ip address 10
!
The highlighted configuration above configures BGP to advertise those networks permitted by the route map TO-ADVERTISE if the networks matched by the route map IF-NOT-EXIST are not in the BGP table.

Below shows that RT2 does not advertise 172.16.1.0/24 to ISP2 when the 10.10.10.0/30 route is in its BGP table:

RT2#sh ip bgp
BGP table version is 4, local router ID is 12.12.12.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*>i10.10.10.0/30    12.12.12.1               0    100      0 i
*>i172.16.1.0/24    12.12.12.1               0    100      0 i
RT2#
RT2#sh ip bgp neighbors 11.11.11.2 advertised-routes

RT2#

Below shows that RT2 advertises 172.16.1.0/24 to ISP2 when the 10.10.10.0/30 route is removed from its BGP table as the link on RT1 is shutdown:

RT1#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
RT1(config)#int fa1/0
RT1(config-if)#shut
RT1(config-if)#end
RT1#
00:03:10: %BGP-5-ADJCHANGE: neighbor 10.10.10.2 Down Interface flap
00:03:12: %LINK-5-CHANGED: Interface FastEthernet1/0, changed state to administratively down
00:03:13: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet1/0, changed state to down
RT1#
======================================================================
RT2#sh ip bgp
BGP table version is 5, local router ID is 12.12.12.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*>i172.16.1.0/24    12.12.12.1               0    100      0 i
RT2#
RT2#sh ip bgp neighbors 11.11.11.2 advertised-routes
BGP table version is 6, local router ID is 12.12.12.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*>i172.16.1.0/24    12.12.12.1               0    100      0 i
RT2#

No comments:

Post a Comment