一、认识属性:
-
可选非过渡(Optional non-transitive):BGP设备可以不识别此类属性,如果BGP设备不识别此类属性,则会被忽略该属性,且不会通告给其他对等体
-
可选过渡(Optional transitive):BGP设备可以不识别此类属性,如果BGP设备不识别此类属性,但它仍然会接收这类属性,并通告给其他对等体
-
公认必须遵循(Well-known mandatory):所有BGP设备都可以识别此类属性,且必须存在于Update报文中。如果缺少这类属性,路由信息就会出错。
-
公认任意(Well-known discretionary):所有BGP设备都可以识别此类属性,但不要求必须存在于Update报文中,即就算缺少这类属性,路由信息也不会出错
-
Local_Pref属性 (公认任意)
Local_Pref属性表明路由器的BGP优先级,用于判断流量离开AS时的优选路由。当BGP的设备通过不同的IBGP对等体得到目的地址相同但下一跳不同的多条路由时,将优先选择Local_Pref属性值较高的路由。Local_Pref属性仅在IBGP对等体之间有效,不通告给其他AS。Local_Pref属性可以手动配置,如果路由没有配置Local_Pref属性,BGP选路时将该路由的Local_Pref值按缺省值100来处理。
当一台BGP路由器中存在多条去往同一目标网络的BGP路由时,BGP协议会对这些BGP路由的属性进行比较,以确定去往该目标网络的最优BGP路由,然后将该最优BGP路由与去往同一目标网络的其他协议路由进行比较,从而决定是否将该最优 BGP路由放进IP路由表中注意,路由器最终是根据P路由表进行实际报文转发的。在对BGP路由属性进行比较时BGP会遵循一定的先后次序进行比较,直到确定出一条最优路由为止。在BGP路由届性的比较过程中,首先要比较的就是路由信息首选值 Preferred Value,也简称为 PrefVal。
路由信息的首选值Preferred Value的取值范围是0~65535,取值越大,优先级越高缺省情况下,Preferred Value 取值为0;通过修改Preferred Value的值,可以很方便地实现对路经选择的控制。Preferred Value属性不会发送给任何BGP邻居,仅作为本地路由器用来选择最佳BGP路径之用。
二、实验:
(2.1)实验拓扑图:
(2.2)配置bgp:
##r1bgp配置##
bgp 100
router-id 10.0.1.1
peer 10.0.12.2 as-number 200
peer 10.0.13.3 as-number 200
#
ipv4-family unicast
undo synchronization
network 10.0.1.1 255.255.255.255
network 10.0.100.2 255.255.255.255
peer 10.0.12.2 enable
peer 10.0.13.3 enable
##r2bgp配置##
bgp 200
router-id 10.0.2.2
peer 10.0.3.3 as-number 200
peer 10.0.3.3 connect-interface LoopBack0
peer 10.0.4.4 as-number 200
peer 10.0.4.4 connect-interface LoopBack0
peer 10.0.12.1 as-number 100
#
ipv4-family unicast
undo synchronization
peer 10.0.3.3 enable
peer 10.0.3.3 next-hop-local
peer 10.0.4.4 enable
peer 10.0.4.4 next-hop-invariable
peer 10.0.12.1 enable
##r3bgp配置##
bgp 200
router-id 10.0.3.3
peer 10.0.2.2 as-number 200
peer 10.0.2.2 connect-interface LoopBack0
peer 10.0.4.4 as-number 200
peer 10.0.4.4 connect-interface LoopBack0
peer 10.0.13.1 as-number 100
#
ipv4-family unicast
undo synchronization
peer 10.0.2.2 enable
peer 10.0.2.2 next-hop-local
peer 10.0.4.4 enable
peer 10.0.4.4 next-hop-local
peer 10.0.13.1 enable
##r4bgp配置##
bgp 200
router-id 10.0.4.4
peer 10.0.2.2 as-number 200
peer 10.0.2.2 connect-interface LoopBack0
peer 10.0.3.3 as-number 200
peer 10.0.3.3 connect-interface LoopBack0
#
ipv4-family unicast
undo synchronization
network 10.0.100.4 255.255.255.255
peer 10.0.2.2 enable
peer 10.0.3.3 enable
(2.3)查看路由:
我们发现路由都往3号路由器跑,所以我们可以通过配置本地优先级来实现bgp负载分担。
(2.4.1)更改本地优先级:
##更改Local_Pref值##
[R2-bgp]default local-preference 200
(2.4.2)通过前缀列表更改本地优先级:
[R2]ip ip-prefix 1 permit 10.0.12.1 24
[R2]route-policy 1 permit node 10
Info: New Sequence of this List.
[R2-route-policy]if-match ip-prefix 1
[R2-route-policy]apply local-preference 500
[R2-route-policy]q
[R2]route-policy 1 permit node 20
Info: New Sequence of this List.
[R2-route-policy]q