Thursday, July 12, 2012

BGP Advertise-map

BGP Advertise-map

In this example we have two routers:R1 and R2.

R1 advertises default route with as-path prepending and metric value of 10 if it does not have 3.3.3.3/32 prefix in its BGP table.Here is the configuration:

interface Loopback0
 ip address 10.1.2.1 255.255.255.0 secondary
 ip address 10.1.3.1 255.255.255.0 secondary
 ip address 10.1.1.1 255.255.255.0
!
interface FastEthernet0/0
 ip address 1.1.1.1 255.255.255.0
 !
router bgp 1
 no synchronization
 bgp log-neighbor-changes
 network 0.0.0.0
 network 3.3.3.3 mask 255.255.255.255
 network 10.0.0.0
 network 10.1.1.0 mask 255.255.255.0
 network 10.1.2.0 mask 255.255.255.0
 network 10.1.3.0 mask 255.255.255.0
 neighbor 1.1.1.2 remote-as 2
 neighbor 1.1.1.2 advertise-map AD non-exist-map NONEXIST
 no auto-summary
!
ip forward-protocol nd
ip route 0.0.0.0 0.0.0.0 Null0
ip route 3.3.3.3 255.255.255.255 Null0
!       
ip prefix-list default seq 5 permit 0.0.0.0/0
!
ip prefix-list exist seq 5 permit 3.3.3.3/32
!
route-map AD permit 10
 match ip address prefix-list default
 set metric 10
 set as-path prepend 1 1 1
!
route-map NONEXIST permit 10
 match ip address prefix-list exist



Verifying:

With this configuration R2 has not the default route, it has only these routes:

R2#sh ip bgp
BGP table version is 21, local router ID is 1.1.1.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
*> 3.3.3.3/32       1.1.1.1                  0             0 1 i
*> 10.1.1.0/24      1.1.1.1                  0             0 1 i
*> 10.1.2.0/24      1.1.1.1                  0             0 1 i
*> 10.1.3.0/24      1.1.1.1                  0             0 1 i

Lets remove the 3.3.3.3/32 route and turn on "debug ip bgp" on R1:

R1#debug ip bgp  
BGP debugging is on for address family: IPv4 Unicast
R1#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#no ip route 3.3.3.3 255.255.255.255 null0
R1(config)#
*Mar  1 02:08:38.747: BGP(0): route 3.3.3.3/32 down
*Mar  1 02:08:38.751: BGP(0): no valid path for 3.3.3.3/32
*Mar  1 02:08:38.751: BGP(0): nettable_walker 3.3.3.3/32 no best path
*Mar  1 02:08:38.755: BGP(0): 1.1.1.2 send unreachable 3.3.3.3/32
*Mar  1 02:08:38.755: BGP(0): 1.1.1.2 send UPDATE 3.3.3.3/32 -- unreachable
R1(config)#
*Mar  1 02:08:48.399: BPG(0): Condition exist changes to Advertise
*Mar  1 02:08:48.399: BPG(0): Condition exist changes to Advertise
*Mar  1 02:08:48.403: BGP(0): net 0.0.0.0/0 matches ADV MAP AD bump version to 26
*Mar  1 02:08:48.859: BGP(0): nettable_walker 0.0.0.0/0 route sourced locally
R1(config)#
*Mar  1 02:09:09.227: BGP(0): 1.1.1.2 0.0.0.0/0 matches advertise map AD, state: Advertise
*Mar  1 02:09:09.227: BGP(0): 1.1.1.2 send UPDATE (format) 0.0.0.0/0, next 1.1.1.1, metric 10, path Local

R2`s BGP table:

R2#show ip bgp
BGP table version is 23, local router ID is 1.1.1.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
*> 0.0.0.0          1.1.1.1                 10             0 1 1 1 1 i
*> 10.1.1.0/24      1.1.1.1                  0             0 1 i
*> 10.1.2.0/24      1.1.1.1                  0             0 1 i
*> 10.1.3.0/24      1.1.1.1                  0             0 1 i