Saturday, October 15, 2016

how to influnce inbound traffic using as path prepend

*** network diagram and setup information


- our router: n1
        subnet: 10.0.0.0/24
        prefer path: to n3
        prepend path: to n7




1- route router on n6
n6# 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

B>* 10.0.0.0/24 [20/0] via 10.0.3.1, eth0, 00:00:38
B>* 10.0.1.0/24 [20/0] via 10.0.3.1, eth0, 00:01:08
B>* 10.0.2.0/24 [20/0] via 10.0.3.1, eth0, 00:01:08
C>* 10.0.3.0/24 is directly connected, eth0
C>* 10.0.4.0/24 is directly connected, eth1
B>* 10.0.5.0/24 [20/0] via 10.0.4.1, eth1, 00:01:03
B>* 10.0.6.0/24 [20/0] via 10.0.4.1, eth1, 00:00:33
B>* 10.0.7.0/24 [20/0] via 10.0.4.1, eth1, 00:00:33
C>* 127.0.0.0/8 is directly connected, lo


n6# show ip bgp 10.0.0.0
BGP routing table entry for 10.0.0.0/24
Paths: (2 available, best #2, table Default-IP-Routing-Table)
  Advertised to non peer-group peers:
  10.0.4.1
  8 5 3 1
    10.0.4.1 from 10.0.4.1 (10.0.5.2)
      Origin IGP, localpref 100, valid, external
      Last update: Sat Oct 15 09:57:04 2016

  2 4 7 1
    10.0.3.1 from 10.0.3.1 (10.0.3.1)
      Origin IGP, localpref 100, valid, external, best
      Last update: Sat Oct 15 09:56:59 2016


- so router n6 choose 10.0.3.1 as the best route to reach network 10.0.0.0/24


2- configure our router n1 to prepend one as path to router 7, below is the configuration for n1

router bgp 1
 bgp router-id 10.0.7.1
 network 10.0.0.0/24
 network 10.0.7.0/24
 neighbor n3 peer-group
 neighbor n3 remote-as 3
 neighbor n3 soft-reconfiguration inbound
 neighbor n7 peer-group
 neighbor n7 remote-as 7
 neighbor n7 soft-reconfiguration inbound
 neighbor n7 route-map ROUTEMAP2n7 out
 neighbor 10.0.0.2 peer-group n7
 neighbor 10.0.7.2 peer-group n3
 exit
!
ip prefix-list MATCHALL seq 20 permit 0.0.0.0/0 le 24
ip prefix-list SUBPREPEND seq 10 permit 10.0.0.0/24
!
route-map ROUTEMAP2n7 permit 10
 match ip address prefix-list SUBPREPEND
 set as-path prepend 1
!
route-map ROUTEMAP2n7 permit 30
 match ip address prefix-list MATCHALL


3- clear bgp session to n7
n1# clear ip bgp 10.0.0.2 soft out 


4- now route how the n6 route path to our subnet 10.0.0.0/24
n6# 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

B>* 10.0.0.0/24 [20/0] via 10.0.4.1, eth1, 00:02:31
B>* 10.0.1.0/24 [20/0] via 10.0.3.1, eth0, 00:16:29
B>* 10.0.2.0/24 [20/0] via 10.0.3.1, eth0, 00:16:29
C>* 10.0.3.0/24 is directly connected, eth0
C>* 10.0.4.0/24 is directly connected, eth1
B>* 10.0.5.0/24 [20/0] via 10.0.4.1, eth1, 00:16:24
B>* 10.0.6.0/24 [20/0] via 10.0.4.1, eth1, 00:15:54
B>* 10.0.7.0/24 [20/0] via 10.0.4.1, eth1, 00:15:54
C>* 127.0.0.0/8 is directly connected, lo



n6# show ip bgp 10.0.0.0
BGP routing table entry for 10.0.0.0/24
Paths: (2 available, best #2, table Default-IP-Routing-Table)
  Advertised to non peer-group peers:
  10.0.3.1
  2 4 7 1 1
    10.0.3.1 from 10.0.3.1 (10.0.3.1)
      Origin IGP, localpref 100, valid, external
      Last update: Sat Oct 15 10:01:59 2016

  8 5 3 1
    10.0.4.1 from 10.0.4.1 (10.0.5.2)
      Origin IGP, localpref 100, valid, external, best
      Last update: Sat Oct 15 09:57:04 2016


- now n2 choose 10.0.4.1 over 10.0.3.1 to 10.0.0.0/24, because the there're 5 as path, (double 1) from 10.0.3.1, but only 4 from 10.0.4.1

No comments:

Post a Comment