Friday, September 9, 2016

influence outbound route with bgp local-preference

- network diagram


1- by default n1 will choose n2 as the next hop to network 10.0.4.0/24 over other path n3 -> n4. so we will use local-preference to  influence outbound route that will choose the opposite route.

2- bgp configuration.

- n2
router bgp 2
 bgp router-id 10.0.4.1
 network 10.0.0.0/8
 redistribute connected
 neighbor n1 peer-group
 neighbor n1 remote-as 1
 neighbor n1 soft-reconfiguration inbound
 neighbor n5 peer-group
 neighbor n5 remote-as 5
 neighbor n5 soft-reconfiguration inbound
 neighbor 10.0.0.1 peer-group n1
 neighbor 10.0.4.2 peer-group n5
 exit


-n3
 router bgp 3
 bgp router-id 10.0.2.1
 network 10.0.0.0/8
 redistribute connected
 neighbor n1 peer-group
 neighbor n1 remote-as 1
 neighbor n1 soft-reconfiguration inbound
 neighbor n4 peer-group
 neighbor n4 remote-as 4
 neighbor n4 soft-reconfiguration inbound
 neighbor 10.0.1.1 peer-group n1
 neighbor 10.0.2.2 peer-group n4
 exit


-n4
router bgp 4
 bgp router-id 10.0.3.1
 network 10.0.0.0/8
 redistribute connected
 neighbor n3 peer-group
 neighbor n3 remote-as 3
 neighbor n3 soft-reconfiguration inbound
 neighbor n5 peer-group
 neighbor n5 remote-as 5
 neighbor n5 soft-reconfiguration inbound
 neighbor 10.0.2.1 peer-group n3
 neighbor 10.0.3.2 peer-group n5
 exit


-n5
router bgp 5
 bgp router-id 10.0.4.2
 network 10.0.0.0/8
 redistribute connected
 neighbor n2 peer-group
 neighbor n2 remote-as 2
 neighbor n2 soft-reconfiguration inbound
 neighbor n4 peer-group
 neighbor n4 remote-as 4
 neighbor n4 soft-reconfiguration inbound
 neighbor 10.0.3.1 peer-group n4
 neighbor 10.0.4.1 peer-group n2
 exit



-n1 + local-preference on  link to n3 with weight 120
router bgp 1
 bgp router-id 10.0.1.1
 network 10.0.0.0/8
 redistribute connected
 neighbor n2 peer-group
 neighbor n2 remote-as 2
 neighbor n2 soft-reconfiguration inbound
 neighbor n3 peer-group
 neighbor n3 remote-as 3
 neighbor n3 soft-reconfiguration inbound
 neighbor 10.0.0.2 peer-group n2
 neighbor 10.0.1.2 peer-group n3
 neighbor 10.0.1.2 route-map as3_in in
 exit
!
ip prefix-list MATCH_ALL seq 5 permit 0.0.0.0/0 le 32
!
route-map as3_in permit 1
 match ip address prefix-list MATCH_ALL
 set local-preference 120


4- clear bgp sessions to both n2 and n3
n1# clear bgp peer-group n3
n1# clear bgp peer-group n2

5- the effect of the configuration

- show the bgp path to n5 through n2 is only 1 hop away but to  n5 through n3 is 2 hops away
n1# show bgp paths
Address Refcnt Path
[0x56190cfe5ad0:2347207637] (3) 3 4
[0x56190cfae280:2448081105] (9)
[0x56190cfd9d00:2148581657] (2) 2 5 4
[0x56190cfe5e10:10079144] (3) 3 4 5
[0x56190cfd9480:3804810696] (7) 3
[0x56190cfd9950:339860207] (2) 2 5
[0x56190cfd9fc0:4096851189] (6) 2


- show ip route and it choose n3 over n2 as exit hop
n1# show ip route         
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, P - PIM, A - Babel,
       > - selected route, * - FIB route

C>* 10.0.0.0/24 is directly connected, eth0
C>* 10.0.1.0/24 is directly connected, eth1
B>* 10.0.2.0/24 [20/0] via 10.0.1.2, eth1, 00:15:40
B>* 10.0.3.0/24 [20/0] via 10.0.1.2, eth1, 00:15:40
B>* 10.0.4.0/24 [20/0] via 10.0.1.2, eth1, 00:15:40
C>* 127.0.0.0/8 is directly connected, lo

No comments:

Post a Comment