Thursday 7 February 2013

BGP Conditional Route Injection



Prefer path to reach 123.123.123.123/32 is R6>R5>R2>R3 without manipulating bgp attributes of path selection.

Configuration

R1

interface Loopback0
 ip address 1.1.1.1 255.255.255.255
!
interface FastEthernet0/0
 ip address 192.168.13.1 255.255.255.0
 duplex auto
 speed auto
!
interface FastEthernet0/1
 ip address 192.168.14.1 255.255.255.0
 duplex auto
 speed auto
!
router ospf 1
 log-adjacency-changes
 network 1.1.1.1 0.0.0.0 area 0
 network 192.168.13.1 0.0.0.0 area 0
!
router bgp 123
 no synchronization
 bgp log-neighbor-changes
 neighbor IBGP peer-group
 neighbor IBGP remote-as 123
 neighbor IBGP update-source Loopback0
 neighbor IBGP next-hop-self
 neighbor 2.2.2.2 peer-group IBGP
 neighbor 3.3.3.3 peer-group IBGP
 neighbor 192.168.14.4 remote-as 4
 no auto-summary

R2

interface Loopback0
 ip address 2.2.2.2 255.255.255.255
!
interface FastEthernet0/0
 ip address 192.168.23.2 255.255.255.0
 duplex auto
 speed auto
!
interface FastEthernet0/1
 ip address 192.168.25.2 255.255.255.0
 duplex auto
 speed auto
!
router ospf 1
 log-adjacency-changes
 network 2.2.2.2 0.0.0.0 area 0
 network 192.168.23.2 0.0.0.0 area 0
!
router bgp 123
 no synchronization
 bgp log-neighbor-changes
 bgp inject-map INJECT exist-map EXIST
 neighbor IBGP peer-group
 neighbor IBGP remote-as 123
 neighbor IBGP update-source Loopback0
 neighbor IBGP next-hop-self
 neighbor 1.1.1.1 peer-group IBGP
 neighbor 3.3.3.3 peer-group IBGP
 neighbor 192.168.25.5 remote-as 5
 no auto-summary
!
ip prefix-list EXIST seq 5 permit 123.123.0.0/16
!
ip prefix-list INJECT seq 5 permit 123.123.123.0/24
!
ip prefix-list SOURCE seq 5 permit 3.3.3.3/32
!
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

R3

interface Loopback0
 ip address 3.3.3.3 255.255.255.255
!
interface Loopback1
 ip address 123.123.123.123 255.255.255.255
!
interface FastEthernet0/0
 ip address 192.168.13.3 255.255.255.0
 duplex auto
 speed auto
!
interface FastEthernet0/1
 ip address 192.168.23.3 255.255.255.0
 duplex auto
 speed auto
!
router ospf 1
 log-adjacency-changes
 network 3.3.3.3 0.0.0.0 area 0
 network 192.168.13.3 0.0.0.0 area 0
 network 192.168.23.3 0.0.0.0 area 0
!
router bgp 123
 no synchronization
 bgp log-neighbor-changes
 network 123.123.0.0 mask 255.255.0.0
 neighbor IBGP peer-group
 neighbor IBGP remote-as 123
 neighbor IBGP update-source Loopback0
 neighbor 1.1.1.1 peer-group IBGP
 neighbor 2.2.2.2 peer-group IBGP
 no auto-summary
!
ip forward-protocol nd
ip route 123.123.0.0 255.255.0.0 Null0

R4

interface FastEthernet0/0
 ip address 192.168.14.4 255.255.255.0
 duplex auto
 speed auto
!
interface FastEthernet0/1
 ip address 192.168.46.4 255.255.255.0
 duplex auto
 speed auto
!
router bgp 4
 no synchronization
 bgp log-neighbor-changes
 neighbor 192.168.14.1 remote-as 123
 neighbor 192.168.46.6 remote-as 6
 no auto-summary

R5

interface FastEthernet0/0
 ip address 192.168.25.5 255.255.255.0
 duplex auto
 speed auto
!
interface FastEthernet0/1
 ip address 192.168.56.5 255.255.255.0
 duplex auto
 speed auto
!
router bgp 5
 no synchronization
 bgp log-neighbor-changes
 neighbor 192.168.25.2 remote-as 123
 neighbor 192.168.56.6 remote-as 6
 no auto-summary

R6

interface Loopback0
 ip address 6.6.6.6 255.255.255.255
!
interface FastEthernet0/0
 ip address 192.168.46.6 255.255.255.0
 duplex auto
 speed auto
!
interface FastEthernet0/1
 ip address 192.168.56.6 255.255.255.0
 duplex auto
 speed auto
!
router bgp 6
 no synchronization
 bgp log-neighbor-changes
 network 6.6.6.6 mask 255.255.255.255
 neighbor 192.168.46.4 remote-as 4
 neighbor 192.168.46.4 route-map OUT out
 neighbor 192.168.56.5 remote-as 5
 neighbor 192.168.56.5 route-map OUT out
 no auto-summary
!
ip as-path access-list 1 permit ^$
!
route-map OUT permit 10
 match as-path 1

Verification

R6#show ip bgp
   Network          Next Hop            Metric LocPrf Weight Path
*> 6.6.6.6/32       0.0.0.0                  0         32768 i
*> 123.123.0.0/16   192.168.46.4                           0 4 123 i
*                   192.168.56.5                           0 5 123 i
*> 123.123.123.0/24 192.168.56.5                           0 5 123 ?
R6#traceroute 123.123.123.123 source loopback 0
Type escape sequence to abort.
Tracing the route to 123.123.123.123
  1 192.168.56.5 16 msec 48 msec 20 msec
  2 192.168.25.2 44 msec 44 msec 28 msec
  3 192.168.23.3 68 msec *  100 msec
GNS File : http://www.4shared.com/rar/sQJLhAdW/bgp_conditional_route_injectio.html

No comments:

Post a Comment