BGP的选路

BGP的选路_第1张图片

通过修改BGP的选路规则达到选择需要走的路径的效果。

R2:

BGP的选路_第2张图片

此时R2去AS2下一跳是R4,R1去AS2下一跳是R3,让R2通过R1到达AS2,通过增大R2上的MED来实现,测试如下

R2:

BGP的选路_第3张图片

R3

BGP的选路_第4张图片
R3去AS1下一跳是R1,R4去AS1下一跳是R2,让R3通过R4到达AS1,通过修改起源属性来修改选路

R3:

BGP的选路_第5张图片

R2:

BGP的选路_第6张图片
R2到AS3,其中到R5下一跳为R5,到R6和R7下一跳为R6,使其到达AS3全部走R5,通过增大R2到R6的AS-PATH来实现

R2:

BGP的选路_第7张图片

R4:

BGP的选路_第8张图片
R4到AS3,其中到R5的下一跳为R5,到R6和R7的下一跳为R6,使其到AS3全部走R6,通过增大R4的优先级来实现

R4:

BGP的选路_第9张图片

R6:

BGP的选路_第10张图片
R5到AS3下一跳为R2,R6到AS3下一跳为R2,AS3内所有路由到AS1全部走R5到达,通过修改weihgt来实现

R6:

BGP的选路_第11张图片
实现配置如下:

R1:
interface Loopback0
 ip address 10.1.1.1 255.255.255.255
interface Ethernet0/0
 ip address 10.1.12.1 255.255.255.0
interface Ethernet0/1
 ip address 10.1.13.1 255.255.255.0
router eigrp 100
 network 10.0.0.0
 network 10.1.1.1 0.0.0.0
 network 10.12.1.0 0.0.0.255
router bgp 1
 bgp router-id 10.1.1.1
 bgp log-neighbor-changes
 network 10.1.1.1 mask 255.255.255.255
 neighbor 10.1.13.3 remote-as 2
 neighbor 10.2.2.2 remote-as 1
 neighbor 10.2.2.2 update-source Loopback0
 neighbor 10.2.2.2 next-hop-self

 R2:
 interface Loopback0
 ip address 10.2.2.2 255.255.255.255 
interface Ethernet0/0
 ip address 10.1.12.2 255.255.255.0
interface Ethernet0/1
 ip address 10.1.24.2 255.255.255.0
interface Ethernet0/2
 ip address 10.1.25.2 255.255.255.0    
interface Ethernet1/0
 ip address 10.1.26.2 255.255.255.0
router eigrp 100
 network 10.1.12.0 0.0.0.255
 network 10.2.2.2 0.0.0.0
router bgp 1
 bgp router-id 10.2.2.2
 bgp log-neighbor-changes
 network 10.2.2.2 mask 255.255.255.255
 neighbor 10.1.1.1 remote-as 1
 neighbor 10.1.1.1 update-source Loopback0
 neighbor 10.1.1.1 next-hop-self
 neighbor 10.1.24.4 remote-as 2
 neighbor 10.1.24.4 route-map AS2 in
 neighbor 10.1.25.5 remote-as 3
 neighbor 10.1.26.6 remote-as 3
ip prefix-list AS2 seq 5 permit 10.3.3.3/32
ip prefix-list AS2 seq 10 permit 10.4.4.4/32  
ip prefix-list AS3 seq 5 permit 10.6.6.6/32
ip prefix-list AS3 seq 10 permit 10.7.7.7/32
ip prefix-list AS3 seq 15 permit 10.8.8.8/32  
route-map AS2 permit 10
 match ip address prefix-list AS2
 set metric 1
route-map AS2 permit 20
route-map AS3 permit 10
 match ip address prefix-list AS3
 set as-path prepend 2
route-map AS3 permit 20

R3:
interface Loopback0
 ip address 10.3.3.3 255.255.255.255
interface Ethernet0/0
 ip address 10.1.34.3 255.255.255.0    
interface Ethernet0/1
 ip address 10.1.13.3 255.255.255.0
router eigrp 101
 network 10.1.34.0 0.0.0.255
 network 10.3.3.3 0.0.0.0 
router bgp 2
 bgp router-id 10.3.3.3
 bgp log-neighbor-changes
 network 10.3.3.3 mask 255.255.255.255
 neighbor 10.1.13.1 remote-as 1
 neighbor 10.1.13.1 route-map AS1 in
 neighbor 10.4.4.4 remote-as 2
 neighbor 10.4.4.4 update-source Loopback0
 neighbor 10.4.4.4 next-hop-self
ip prefix-list AS1 seq 5 permit 10.1.1.1/32
ip prefix-list AS1 seq 10 permit 10.2.2.2/32
route-map AS1 permit 10
 match ip address prefix-list AS1
 set origin incomplete
route-map AS1 permit 20

R4:
interface Loopback0
 ip address 10.4.4.4 255.255.255.255
interface Ethernet0/0
 ip address 10.1.34.4 255.255.255.0
interface Ethernet0/1
 ip address 10.1.24.4 255.255.255.0
interface Ethernet0/2
 ip address 10.1.46.4 255.255.255.0
interface Ethernet1/0
 ip address 10.1.45.4 255.255.255.0
router eigrp 101
 network 10.1.34.0 0.0.0.255
 network 10.4.4.4 0.0.0.0
router bgp 2
 bgp router-id 10.4.4.4
 bgp log-neighbor-changes
 network 10.4.4.4 mask 255.255.255.255
 neighbor 10.1.24.2 remote-as 1
 neighbor 10.1.45.5 remote-as 3
 neighbor 10.1.46.6 remote-as 3
 neighbor 10.1.46.6 route-map AS3 in
 neighbor 10.3.3.3 remote-as 2
 neighbor 10.3.3.3 update-source Loopback0
 neighbor 10.3.3.3 next-hop-self
ip prefix-list AS3 seq 5 permit 10.5.5.5/32
route-map AS3 permit 10
 match ip address prefix-list AS3
 set local-preference 200
route-map AS3 permit 20

R5:
interface Loopback0
 ip address 10.5.5.5 255.255.255.255
interface Ethernet0/0
 ip address 10.1.56.5 255.255.255.0
interface Ethernet0/1
 ip address 10.1.57.5 255.255.255.0
interface Ethernet0/2
 ip address 10.1.25.5 255.255.255.0
interface Ethernet1/0
 ip address 10.1.45.5 255.255.255.0
router eigrp 102
 network 10.1.56.0 0.0.0.255
 network 10.1.57.0 0.0.0.255
 network 10.5.5.5 0.0.0.0
router eigrp 103
 network 10.0.0.0
router bgp 3
 bgp router-id 10.5.5.5
 bgp log-neighbor-changes
 network 10.5.5.5 mask 255.255.255.255
 neighbor 10.1.25.2 remote-as 1
 neighbor 10.1.25.2 route-map AS1 in
 neighbor 10.1.45.4 remote-as 2
 neighbor 10.6.6.6 remote-as 3
 neighbor 10.6.6.6 update-source Loopback0
 neighbor 10.6.6.6 next-hop-self
 neighbor 10.7.7.7 remote-as 3
 neighbor 10.7.7.7 update-source Loopback0
 neighbor 10.7.7.7 next-hop-self
ip prefix-list AS1 seq 5 permit 10.6.6.6/32
ip prefix-list AS1 seq 10 permit 10.7.7.7/32
route-map AS1 permit 10
 match ip address prefix-list AS1
 set weight 100
route-map AS1 permit 20

R6:
interface Loopback0
 ip address 10.6.6.6 255.255.255.255
interface Ethernet0/0
 ip address 10.1.56.6 255.255.255.0
interface Ethernet0/1
 ip address 10.1.67.6 255.255.255.0
interface Ethernet0/2
 ip address 10.1.46.6 255.255.255.0
interface Ethernet1/0
 ip address 10.1.26.6 255.255.255.0
router eigrp 102
 network 10.1.56.0 0.0.0.255
 network 10.1.67.0 0.0.0.255
  network 10.6.6.6 0 0.0.0.0
router bgp 3
 bgp router-id 10.6.6.6
 bgp log-neighbor-changes
 network 10.6.6.6 mask 255.255.255.255
 neighbor 10.1.26.2 remote-as 1
 neighbor 10.1.46.4 remote-as 2
 neighbor 10.5.5.5 remote-as 3
 neighbor 10.5.5.5 update-source Loopback0
 neighbor 10.5.5.5 next-hop-self
 neighbor 10.7.7.7 remote-as 3
 neighbor 10.7.7.7 update-source Loopback0
 neighbor 10.7.7.7 next-hop-self

R7:
interface Loopback0
 ip address 10.7.7.7 255.255.255.255
interface Ethernet0/0
 ip address 10.1.67.7 255.255.255.0
interface Ethernet0/1
 ip address 10.1.57.5 255.255.255.0
router eigrp 102
 network 10.1.57.0 0.0.0.255
 network 10.1.67.0 0.0.0.255
 network 10.7.7.7 0.0.0.0
router bgp 3
 bgp router-id 10.7.7.7
 bgp log-neighbor-changes
 network 10.7.7.7 mask 255.255.255.255
 neighbor 10.5.5.5 remote-as 3
 neighbor 10.5.5.5 update-source Loopback0
 neighbor 10.6.6.6 remote-as 3
 neighbor 10.6.6.6 update-source Loopback0

你可能感兴趣的:(BGP的选路)