Friday, September 16, 2016

use bgp community attribute to influence route selection

1- network diagram


2- by default the router n1 and router n2 will choose choose n3 as the next hop to reach n4. so if we are the administrator of n3 and n1 and n2 are the service provider routers and they have community attribute set on their router, we can influence the incoming router by doing only the router n3

--- configuration
** service provider part
- n1
router bgp 1
 bgp router-id 10.0.0.1
 network 10.0.0.0/8
 redistribute connected
 neighbor n2 peer-group
 neighbor n2 remote-as 1
 neighbor n2 next-hop-self
 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 Peer-R3 in
!
ip community-list 1 permit 100:300
ip community-list 2 permit 100:250
!
route-map Peer-R3 permit 10
 match community 1
 set local-preference 130
!
route-map Peer-R3 permit 20
 match community 2
 set local-preference 125


-n2
router bgp 1
 bgp router-id 10.0.0.2
 network 10.0.0.0/8
 redistribute connected
 neighbor n1 peer-group
 neighbor n1 remote-as 1
 neighbor n1 next-hop-self
 neighbor n1 soft-reconfiguration inbound
 neighbor n3 peer-group
 neighbor n3 remote-as 3
 neighbor n3 soft-reconfiguration inbound
 neighbor 10.0.0.1 peer-group n1
 neighbor 10.0.2.2 peer-group n3
 neighbor 10.0.2.2 route-map Peer-R3 in
!
ip community-list 1 permit 100:300
ip community-list 2 permit 100:250
!
route-map Peer-R3 permit 10
 match community 1
 set local-preference 130
!
route-map Peer-R3 permit 20
 match community 2
 set local-preference 125



** the router on our control
-n3
router bgp 3
 bgp router-id 10.0.1.2
 network 10.0.0.0/8
 redistribute connected
 neighbor n1 peer-group
 neighbor n1 remote-as 1
 neighbor n1 route-map Peer-R1 out
 neighbor n2 peer-group
 neighbor n2 remote-as 1
 neighbor n2 soft-reconfiguration inbound
 neighbor n2 route-map Peer-R2 out
 neighbor 10.0.1.1 peer-group n1
 neighbor 10.0.2.1 peer-group n2
!
access-list 101 permit ip host 10.0.3.0 host 255.255.255.0
!
route-map Peer-R1 permit 10
 match ip address 101
 set community 100:300
!
route-map Peer-R2 permit 10
 match ip address 101
 set community 100:250



- so we just change the change the community on router-map of n3 we can influence the path selection on router n1 and n2

3- result after we configure community string

-n1 ip route show
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 [200/0] via 10.0.0.2, eth0, 00:37:02
B>* 10.0.3.0/24 [20/0] via 10.0.1.2, eth1, 00:20:50
C>* 127.0.0.0/8 is directly connected, lo


-n2 ip route show
n2# 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
B>* 10.0.1.0/24 [200/0] via 10.0.0.1, eth0, 00:37:45
C>* 10.0.2.0/24 is directly connected, eth1
B>* 10.0.3.0/24 [200/0] via 10.0.0.1, eth0, 00:10:59
C>* 127.0.0.0/8 is directly connected, lo


now n2 will choose n1 n3 to reach n4 not n3 to n4 as before

No comments:

Post a Comment