Showing posts with label conditional routing. Show all posts
Showing posts with label conditional routing. Show all posts

Friday, November 28, 2008

BGP - Conditional route injection

Topology

R5----R7

R5 is advertising 10.34.19.0/26 to R7
Configure R7 to inject 10.34.19.48/28

1) MAKE PREFIX-LISTS

ip prefix-list EXIST seq 5 permit 10.34.19.0/26
ip prefix-list INJECT 5 permit 10.34.19.48/28
ip prefix-list SOURCE seq 5 permit 192.168.5.5/32



2) MAKE ROUTE-MAPS

route-map INJECT permit 10
set ip address prefix-list INJECT

route-map EXIST permit 10
match ip address prefix-list EXIST
match ip route-source prefix-list SOURCE



3) CONFIGURE BGP

route bgp 567
bgp inject-map INJECT exist-map EXIST



4) VERIFY

R5#show ip bgp nei 192.168.7.7 advertised-routes | begin Net
Network Next Hop Metric LocPrf Weight Path
*> 10.34.19.0/26 192.168.2.2 0 200 0 24 1 i

R7#show ip bgp injected-paths | begin Net
Network Next Hop Metric LocPrf Weight Path
*>i10.34.19.48/28 192.168.5.5 0 200 0 24 1 i

Things to remember:

- Must use Prefix-lists, NOT ACLs
- Injected route must a subset of am aggregate already in the table
- Use "set" command for inject-map, not "match"
- I commonly forget the "prefix-list" argument when configuring the maps
- inject-map Command is a bgp command, not per-neighbor

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