Tuesday, July 8, 2008

BGP - Conditional Advertisement with non-exist-map

It took me awhile to get this going for some reason but here is the doc that helped me out:

Configuring and Verifying the BGP Conditional Advertisement Feature

Here's my example

[R1]---[R4]---[R5]

Each router is in its own AS.

R1 is advertising 10.1.0.0/16 to R4.
if this route should fail, then R4 should advertise 4.4.4.0/24 to R5.
If 10.1.0.0/16 appears in R4's BGP table, then it should stop advertising 4.4.4.0/24.

R4 is where the action is so let's have a look:

!
interface Loopback0
ip address 4.4.4.4 255.255.255.0
!

router bgp 4
no synchronization
bgp log-neighbor-changes
network 4.4.4.0 mask 255.255.255.0
neighbor 155.1.45.5 remote-as 5
neighbor 155.1.45.5 advertise-map ADV non-exist-map NON
neighbor 155.1.146.1 remote-as 1
no auto-summary
!
access-list 10 permit 10.1.0.0 0.0.255.255
access-list 40 permit 4.4.4.0 0.0.0.255
!
route-map NON permit 10
match ip address 10
!
route-map ADV permit 10
match ip address 40


10.1.0.0 is actually the loopback network on R1 so we can test easy by shutting/no shutting the interface. Right now it is up. Let's check the BGP tables on R4 and R5:

R4#show ip bgp | begin Network
Network Next Hop Metric LocPrf Weight Path
*> 4.4.4.0/24 0.0.0.0 0 32768 i
*> 10.1.0.0/16 155.1.146.1 0 0 1 i

R5#show ip bgp | begin Network
Network Next Hop Metric LocPrf Weight Path
*> 10.1.0.0/16 155.1.45.4 0 4 1 i


Now let's shut the interface on R1:

R1(config)#int lo 1
R1(config-if)#shut


Now check R4 and R5 again:

R4#show ip bgp | begin Network
Network Next Hop Metric LocPrf Weight Path
*> 4.4.4.0/24 0.0.0.0 0 32768 i

R5#debug ip bgp updates
BGP updates debugging is on for address family: IPv4 Unicast
*Mar 1 01:59:35.787: BGP(0): 155.1.45.4 rcvd UPDATE w/ attr: nexthop 155.1.45.4, origin i, metric 0, path 4
*Mar 1 01:59:35.791: BGP(0): 155.1.45.4 rcvd 4.4.4.0/24
*Mar 1 01:59:35.799: BGP(0): Revise route installing 1 of 1 routes for 4.4.4.0/24 -> 155.1.45.4(main) to main IP table

R5#show ip bgp | begin Network
Network Next Hop Metric LocPrf Weight Path
*> 4.4.4.0/24 155.1.45.4 0 0 4 i

7 comments:

  1. man... i need to know,
    WHAT is the LOGIC behind this feature ??

    if i have a subnet X in my table, do not adv Y to "R",
    if i do not have x in my table, advertise Y.

    you know what i mean, i got the feature, just need to know what i answer when someone aske me, WHY DO WE NEED THIS ??! LOL
    GREAT BLOG !

    ReplyDelete
  2. Hehe, there are lot of things where I ask myself the same thing :)

    In this case, suppose you had ISPs in different AS. You only want to advertise a route or routes to one of them. Then if your primary connection goes down (identified by the missing route in the non-exist map) you can then advertise the routes to the backup neighbor.

    In some cases this might be better than trying to use AS-prepends to influence path selection because with AS-prepends you only have so much control.

    Hope that helps. If you know any other situations, let me know!

    ReplyDelete
  3. I used a prefiex-list to block the routes in the exist map to enter BGP table, so the route in the exist map in neither BGP table not routing table, but the routes in the advertise map is still NOT sent…
    So my testing result is "not receiving routes in the exist map from any BGP peer/redistribution" , then router will advertise the routes in the ADVERTISE map...

    ReplyDelete
  4. We can take it this way that if there is a customer dual homed to two ISP's for the internet connectivity and dont want the Internet from both the SP's at the same time . Will require this feature to be implemented so that the customer regains connectivity to the internet upon the failure of the primary connection to the SP.

    ReplyDelete
  5. Take another scenario

    Say you have a system A (active) and B for (backup system in different DC) and both reachable via BGP (Private cloud), now remote nodes can use system A as long as it is reachable and while it will use system B in case system A is not responding or not reachable.

    System A BGP-GW can advertise system A subnet only and only if it has internet reachability via different uplink (this is conditional advertisement) otherwise, it will stop advertisement of system A subnet casing all remote nodes to use system B

    ReplyDelete
  6. Yes this is very helpful in Primary and Secondary ISP scenario...

    I have a doubt... what if both ISP are originating default for me? how to track then?

    ReplyDelete
  7. Zahid,

    In case your ISP is giving you default, you can match default via ACL or even Prefix-list.
    More over since we are using route-map, you can match AS-PATH list as well...

    One of the non supported feature of route-map in conditional advertisement is of next-hop.

    ReplyDelete

Note: Only a member of this blog may post a comment.