Wednesday, 14 November 2012

BGP: Conditional advertisement of default-route based on track object:


BGP: Conditional advertisement of default-route based on track object:


·         Yesterday one of my friends asked me one interesting question on BGP default-route advertisement.


·         R1 has a static default route through its BGP neighbor R2

·         R1 is advertising BGP default route to R3 and R4.

·         But, R1 should withdraw this default route to R3 and R4, if it loses its connection to R2 and this has to be done by tracking the static routeJ

·         Initially, I thought I can call track-object inside a route-map, but there is no such option.

·         I googled so much on this topic and some people says we need to use EEM, but I didn’t find any exact answer for this.

·         Then I tried many ways of configuring track, static route, how to call the track in a route-map and all and finally it worked.

Solution:

·         Create a track object to track the reachability of the static route

·         Embed this track to the static default route

·         Create one prefix-list to match the default route

·         Call this prefix-list inside a route-map

·         Use this route-map while advertising default route to R3 and R4
·         Let me take a small topology to configure default route in BGP:

·         R1 – AS 100

·         R2 – AS 200

·         R3 – AS 300

·         R4 – AS 400


R1(config)#do show run | i track

track 1 ip route 0.0.0.0 0.0.0.0 reachability

ip route 0.0.0.0 0.0.0.0 10.1.12.2 track 1

R1(config)#


R1(config)#ip prefix-list TRACK permit 0.0.0.0/0

R1(config)#route-map TRACK

R1(config-route-map)#match ip address prefix-list TRACK

R1(config-route-map)#exit

R1(config)#


R1(config)#router bgp 100

R1(config-router)#neighbor 10.1.13.3 default-originate route-map TRACK

R1(config-router)#neighbor 10.1.14.4 default-originate route-map TRACK

R1(config-router)#


·         Now, let me see R3 and R4 if they got default route from R1:


R4(config-router)#do show ip bgp

BGP table version is 56, local router ID is 4.4.4.4

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          10.1.14.1                0             0 100 i

*> 1.1.1.1/32       10.1.14.1                0             0 100 i

*> 2.2.2.2/32       10.1.14.1                              0 100 200 i

*> 3.3.3.3/32       10.1.14.1                              0 100 300 i

*> 4.4.4.4/32       0.0.0.0                  0         32768 i

R4(config-router)#


R3(config-router)#do show ip bgp

BGP table version is 54, local router ID is 3.3.3.3

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          10.1.13.1                0             0 100 i

*> 1.1.1.1/32       10.1.13.1                0             0 100 i

*> 2.2.2.2/32       10.1.13.1                              0 100 200 i

*> 3.3.3.3/32       0.0.0.0                  0         32768 i

*> 4.4.4.4/32       10.1.13.1                              0 100 400 i

R3(config-router)#


Observation:

·         R3 and R4 received the default route from R1.


·         Now, Let me shut the R1’s ser1/0 interface to bring the Track1, so that R1 will withdraw default route towards R3 & R4



R1#debug ip bgp updates

BGP updates debugging is on for address family: IPv4 Unicast

R1#


R1#conf t

Enter configuration commands, one per line.  End with CNTL/Z.

R1(config)#int ser1/0

R1(config-if)#shut

R1(config-if)#

*Mar  1 03:29:00.567: BGP(0): no valid path for 2.2.2.2/32

*Mar  1 03:29:00.567: %BGP-5-ADJCHANGE: neighbor 10.1.12.2 Down Interface flap

R1(config-if)#

*Mar  1 03:29:00.571: BGP(0): nettable_walker 2.2.2.2/32 no best path

*Mar  1 03:29:01.567: BGP(0): 10.1.13.3 send unreachable 0.0.0.0/0

*Mar  1 03:29:01.567: BGP(0): 10.1.13.3 enqueued default-originate update

*Mar  1 03:29:01.567: BGP(0): 10.1.14.4 send unreachable 0.0.0.0/0

*Mar  1 03:29:01.567: BGP(0): 10.1.14.4 enqueued default-originate update

R1(config-if)#

*Mar  1 03:29:02.543: %LINK-5-CHANGED: Interface Serial1/0, changed state to administratively down

*Mar  1 03:29:03.543: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial1/0, changed state to down

R1(config-if)#

*Mar  1 03:29:06.139: %TRACKING-5-STATE: 1 ip route 0.0.0.0/0 reachability Up->Down

R1(config-if)#

*Mar  1 03:29:09.575: BGP(0): 10.1.13.3 send unreachable 2.2.2.2/32

*Mar  1 03:29:09.575: BGP(0): 10.1.13.3 send UPDATE 2.2.2.2/32 -- unreachable

*Mar  1 03:29:09.675: BGP(0): updgrp 2 - 10.1.13.3 updates replicated for neighbors: 10.1.14.4

R1(config-if)#do u all

All possible debugging has been turned off

R1(config-if)#


R4(config-router)#do show ip bgp

BGP table version is 58, local router ID is 4.4.4.4

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

*> 1.1.1.1/32       10.1.14.1                0             0 100 i

*> 3.3.3.3/32       10.1.14.1                              0 100 300 i

*> 4.4.4.4/32       0.0.0.0                  0         32768 i

R4(config-router)#


R3(config-router)#do show ip bgp

BGP table version is 56, local router ID is 3.3.3.3

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

*> 1.1.1.1/32       10.1.13.1                0             0 100 i

*> 3.3.3.3/32       0.0.0.0                  0         32768 i

*> 4.4.4.4/32       10.1.13.1                              0 100 400 i

R3(config-router)#


Observation:

·         R1 has withdrawn the default route to R3 and R3

·         Now, let me bring the R1’s ser1/0 interface up


R1(config-if)#

R1(config-if)#no shut

R1(config-if)#

*Mar  1 03:34:56.939: %LINK-3-UPDOWN: Interface Serial1/0, changed state to up

*Mar  1 03:34:57.943: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial1/0, changed state to up

R1(config-if)#

*Mar  1 03:34:57.955: BGP(0): 10.1.13.3 enqueued default-originate update

*Mar  1 03:34:57.955: BGP(0): 10.1.14.4 enqueued default-originate update

R1(config-if)#

*Mar  1 03:35:06.139: %TRACKING-5-STATE: 1 ip route 0.0.0.0/0 reachability Down->Up

R1(config-if)#


R4(config-router)#do show ip bgp

BGP table version is 60, local router ID is 4.4.4.4

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          10.1.14.1                0             0 100 i

*> 1.1.1.1/32       10.1.14.1                0             0 100 i

*> 2.2.2.2/32       10.1.14.1                              0 100 200 i

*> 3.3.3.3/32       10.1.14.1                              0 100 300 i

*> 4.4.4.4/32       0.0.0.0                  0         32768 i

R4(config-router)#


R3(config-router)#do show ip bgp

BGP table version is 58, local router ID is 3.3.3.3

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          10.1.13.1                0             0 100 i

*> 1.1.1.1/32       10.1.13.1                0             0 100 i

*> 2.2.2.2/32       10.1.13.1                              0 100 200 i

*> 3.3.3.3/32       0.0.0.0                  0         32768 i

*> 4.4.4.4/32       10.1.13.1                              0 100 400 i

R3(config-router)#


Observation:

·         R1 has advertised default route now to R3 and R4!!!

2 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Well done, I need to do something similar but I will track something learned from R2. Thanks.

    ReplyDelete