在本地对进入的NLRI做权重设置,从而对过滤特定的路由进行优选。严格来说,权重值并不能算是路径属性,因为它并处传递,所能影响的仅仅限于本地路由器。
实验拓扑如下:
完成实验拓扑的基础实验,R1的配置如下:
hostname R1
!
interface Loopback0ip address 10.1.0.1 255.255.255.0
!
interface Loopback1ip address 10.1.1.1 255.255.255.0
!
interface Ethernet0/0ip address 100.80.13.1 255.255.255.248no sh
!
interface Ethernet0/1ip address 100.64.12.1 255.255.255.252no sh
!
router bgp 1bgp router-id 1.1.1.1network 10.1.0.0 mask 255.255.255.0network 10.1.1.0 mask 255.255.255.0aggregate-address 10.1.0.0 255.255.252.0 summary-onlyneighbor 100.64.12.2 remote-as 2neighbor 100.80.13.3 remote-as 3
!
end
R2的配置如下:
hostname R2
!
interface Loopback2ip address 10.1.2.2 255.255.255.0
!
interface Loopback3ip address 10.1.3.2 255.255.255.0
!
interface Ethernet0/0ip address 100.64.12.2 255.255.255.252no sh
!
interface Ethernet0/1ip address 100.96.23.2 255.255.255.248no sh
!
router bgp 2bgp router-id 2.2.2.2network 10.1.2.0 mask 255.255.255.0network 10.1.3.0 mask 255.255.255.0aggregate-address 10.1.0.0 255.255.252.0 summary-onlyneighbor 100.64.12.1 remote-as 1neighbor 100.96.23.3 remote-as 3
!
end
R3的配置如下:
hostname R3
!
interface Loopback0ip address 192.168.2.2 255.255.255.255
!
interface Ethernet0/0ip address 100.80.13.3 255.255.255.248no sh
!
interface Ethernet0/1ip address 100.96.23.3 255.255.255.248no sh
!
router bgp 3bgp router-id 3.3.3.3bgp log-neighbor-changesnetwork 192.168.2.2 mask 255.255.255.255neighbor 100.80.13.1 remote-as 1neighbor 100.96.23.2 remote-as 2
!
end
配置后查看R3的BGP表如下:
在条件相同的情况下,BGP会选择最靠近本地的Next Hop,通常即选择IP地址较大的路径。如果没有其他配置干预,BGP可能会选择IP地址较大的路径,或者选择不同的路由器配置中的Next Hop地址100.96.23.2
。
R1和R2的BGP表如下:(仅作参考,本实验查看R1和R2的意义不大;关键看R3的变化与控制)
R3增加的配置如下:
ip prefix-list WE seq 5 permit 10.1.0.0/22
!
route-map WE permit 10match ip address prefix-list WEset weight 10
!
route-map WE permit 20
!
router bgp 3neighbor 100.80.13.1 route-map WE in
!
end
clear ip bgp * soft in
增加条件控制后,刷新BGP表后的BGP表如下:
查看R3的BGP路由属性如下:
再查看R3的BGP路由表如下:
权重属性的参数调整选路适用于单宿主网络在网关路由器上的配置。
另外:本地优先级也属于公认自选属性。