Friday, October 30, 2009

Conditional BGP Advertisement


Introduction:
This we can use to advertise the prefixes automatically when one peer goes down rather manually advertise the prefixes.
Design Notes:
In this example I’m trying to advertise 10.0.0.0/16 through AS 65001 but if the peer (203.143.0.5) goes down automatically advertise the 10.0.0.0/16 through AS 65002(203.143.0.1).
To make the configuration works we need to match against a prefix that advertise from that(203.143.0.5) peer. But to make sure that learned through that peer we can use AS-Path match or community based match. Here in this example I’m matching against 172.16.0.0/24 advertise through 65001 and match against the as path ^ 65001.
Configuration Notes:
This is the only configuration different from normal one:
neighbor 203.143.0.1 advertise-map otherblock non-exist-map[exist-map] inblock
Better notes on this:

Normal Status:

R2#show ip bgp neighbors 203.143.0.1 | inc Cond
Condition-map inblock, Advertise-map otherblock, status: Withdraw
R0#show ip route
Gateway of last resort is not set
B 172.16.0.0/16 [20/0] via 203.143.0.2, 00:08:41
203.143.0.0/30 is subnetted, 1 subnets
C 203.143.0.0 is directly connected, FastEthernet0/0
B 192.168.0.0/16 [20/0] via 203.143.0.2, 00:08:11


R2#show ip bgp neighbors 203.143.0.1 advertised-routes
BGP table version is 5, local router ID is 203.143.0.6
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
*> 172.16.0.0 203.143.0.5 0 0 65001 i
*> 192.168.0.0/16 0.0.0.0 0 32768 i
Total number of prefixes 2

When the BGP PEER Down:

R2#show ip bgp summary
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
203.143.0.1 4 65002 113 141 7 0 0 00:13:20 0
203.143.0.5 4 65001 117 121 0 0 0 00:00:52 Active
R2#show ip bgp neighbors 203.143.0.1 advertised-routes
BGP table version is 7, local router ID is 203.143.0.6
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
*> 10.0.0.0/16 0.0.0.0 0 32768 i
*> 192.168.0.0/16 0.0.0.0 0 32768 i
Total number of prefixes 2
R2#show ip bgp neighbors 203.143.0.1 | inc Cond
Condition-map inblock, Advertise-map otherblock, status: Advertise


Configuration:

R2#
hostname R2
interface FastEthernet0/0
ip address 203.143.0.2 255.255.255.252
duplex auto
speed auto

interface FastEthernet0/1
ip address 203.143.0.6 255.255.255.252
duplex auto
speed auto
!
router bgp 65003
no synchronization
bgp log-neighbor-changes
network 10.0.0.0 mask 255.255.0.0
network 192.168.0.0 mask 255.255.0.0
neighbor 203.143.0.1 remote-as 65002
neighbor 203.143.0.1 soft-reconfiguration inbound
neighbor 203.143.0.1 advertise-map otherblock non-exist-map inblock
neighbor 203.143.0.5 remote-as 65001
neighbor 203.143.0.5 soft-reconfiguration inbound
neighbor 203.143.0.5 prefix-list allow_65001 out
neighbor 203.143.0.5 route-map inbound_65001 in
no auto-summary
!
ip route 10.0.0.0 255.255.0.0 Null0
ip route 192.168.0.0 255.255.0.0 Null0
!
ip as-path access-list 1 permit ^65001
ip prefix-list allow_65001 seq 5 permit 10.0.0.0/16
ip prefix-list allow_65002 seq 5 permit 192.168.0.0/16
access-list 1 permit 10.0.0.0 0.0.255.255
access-list 2 permit 172.16.0.0 0.0.255.255
route-map otherblock permit 10
match ip address 1
!
route-map allow_65001 permit 10

route-map inbound_65001 permit 10
set community 4259905537
route-map inblock permit 10
match ip address 2
match as-path 1 ! to match the as-path
end
R2 END#

R1#show run!
!
interface FastEthernet0/0
ip address 203.143.0.5 255.255.255.252
duplex auto
speed auto
!
router bgp 65001
no synchronization
bgp log-neighbor-changes
network 172.16.0.0
neighbor 203.143.0.6 remote-as 65003
no auto-summary
!
ip forward-protocol nd
ip route 172.16.0.0 255.255.0.0 Null0
R1 END#
R0#show run
ip cef
interface FastEthernet0/0
ip address 203.143.0.1 255.255.255.252
duplex auto
speed auto

router bgp 65002
no synchronization
bgp log-neighbor-changes
neighbor 203.143.0.2 remote-as 65003
neighbor 203.143.0.2 soft-reconfiguration inbound
no auto-summary

1 comment:

thevarajah said...

its really useful mate!