| 分类: ~~~ BGP ~~~ |
Routes with a higher weight are preferred when multiple routes exist to the same destination. Look at the above example:
- RTA has learned about network 175.10.0.0 from autonomous system 400 (AS400) and will propagate the update to RTC.
- RTB has also learned about network 175.10.0.0 from AS400 and will propagate it to RTC.
- RTC has now two ways for reaching 175.10.0.0 and has to decide which way to go.
If on RTC we can set the weight of the updates coming from RTA to be higher than the weight of updates coming from RTB, then we will force RTC to use RTA as a next hop to reach 175.10.0.0. This is achieved by using multiple methods:
- Using the neighbor command:
neighbor {ip-address|peer-group} weight weight. - Using route-maps.
RTC#
router bgp 300 neighbor 1.1.1.1 remote-as 100 neighbor 1.1.1.1 weight 200 !-- route to 175.10.0.0 from RTA has 200 weight neighbor 2.2.2.2 remote-as 200 neighbor 2.2.2.2 weight 100 !-- route to 175.10.0.0 from RTB will have 100 weight
Routes with higher weight are preferred when multiple routes exist to the same destination. RTA is preferred as the next hop.
The same outcome as above can be achieved by using route maps.
RTC#
router bgp 300 neighbor 1.1.1.1 remote-as 100 neighbor 1.1.1.1 route-map setweightin in neighbor 2.2.2.2 remote-as 200 neighbor 2.2.2.2 route-map setweightin in ... ip as-path access-list 5 permit ^100$ ...route-map setweightin permit 10 match as-path 5 set weight 200 !-- anything that applies to access-list 5, such as packets from AS100, have weight 200route-map setweightin permit 20
set weight 100
!-- anything else would have weight 100

加载中…