【实验要求】


 
在R3上配置BGP weight 值,确保R3上由155.1.37.0/24 网络到155.1.5.0 网络的流量走R1。

 
【实验拓扑】

 

BGP最佳路径选择之--weight  _实验

【配置步骤】

  • 按照上图配置网络
  • 在 R1, R3, R4, and R5 上配置bgp邻居
  • R1 应该 peer with R3 and R4
  • R5 应该 peer with R3 and R5
  • 通告 R3’s 155.1.37.0/24 网络到 BGP
  • 通告 R5’s 155.1.5.0?24 网络到 BGP
  • 在R3上配置BGP weight 值,确保R3上由155.1.37.0/24 网络到155.1.5.0 网络的流量走R1。

【具体配置】
R1:
interface FastEthernet0/0
ip address 155.1.146.1 255.255.255.0
!
interface Serial0/0
ip address 155.1.13.1 255.255.255.0
!
router bgp 2
neighbor 155.1.13.3 remote-as 2
neighbor 155.1.13.3 next-hop-self
neighbor 155.1.146.4 remote-as 1
R3:
interface Serial0/1
ip address 155.1.13.3 255.255.255.0
clockrate 64000
!
interface Serial0/0
ip address 155.1.0.3 255.255.255.0
encapsulation frame-relay
clock rate 64000
frame-relay map ip 155.1.0.5 305 broadcast
no frame-relay inverse-arp
!
interface Loopback0
ip add 155.1.37.3 255.255.255.0
!
router bgp 2
network 155.1.37.0 mask 255.255.255.0
neighbor 155.1.0.5 remote-as 1
neighbor 155.1.13.1 remote-as 2
neighbor 155.1.13.1 next-hop-self

 
R4:
interface FastEthernet0/0
ip address 155.1.146.4 255.255.255.0
!
interface Serial0/0
ip address 155.1.45.4 255.255.255.0
!
router bgp 1
neighbor 155.1.45.5 remote-as 1
neighbor 155.1.45.5 next-hop-self
neighbor 155.1.146.1 remote-as 2

 
R5:
interface Serial0/0
ip address 155.1.0.5 255.255.255.0
encapsulation frame-relay
frame-relay map ip 155.1.0.3 503 broadcast
no frame-relay inverse-arp
!
interface Loopback0
ip address 155.1.5.5 255.255.255.0
!
interface Serial0/1
ip address 155.1.45.5 255.255.255.0
clockrate 64000
!
router bgp 1
network 155.1.5.0 mask 255.255.255.0
neighbor 155.1.0.3 remote-as 2
neighbor 155.1.45.4 remote-as 1
neighbor 155.1.45.4 next-hop-self

 
【实验验证】
R3#show ip bgp
BGP table version is 3, local router ID is 155.1.37.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

 
Network Next Hop Metric LocPrf Weight Path
*> 155.1.5.0/24 155.1.0.5 0 0 1 i
* i 155.1.13.1 0 100 0 1 i
*> 155.1.37.0/24 0.0.0.0 0 32768 i
在未配置weight时R3的bgp路由表,我们发现到达155.1.5.0 的网络下一跳为155.1.0.5,为什么呢?我们回顾一下BGP选路原则, 是不是比较到7步就比较出来了

1.权重:Prefer highest weight (local to router).
2.优先级:Prefer highest local preference (global within AS).
3.起源于本地:Prefer route originated by the local router (next hop = 0.0.0.0).
4.最短AS路径:Prefer shortest AS path.
5.最低的起源属性:Prefer lowest origin code (IGP < EGP < incomplete).
6.最低的MED:Prefer lowest MED.
7.EBGP优于IBGP:Prefer EBGP path over IBGP path.
8.最近的IGP邻居:Prefer the path through the closest IGP neighbor.
9.生存最长的路由:Prefer oldest route for EBGP paths.
10.最低的router-id:Prefer the path with the lowest neighbor BGP router ID.
11.最低的IP地址:Prefer the path with the lowest neighbor IP address.

【weight配置方法】
下一步配置weight值让流量走R1
配置方法:
R3:
router bgp 2
neighbor 155.1.13.1 weight 200
或者是通过route-map来配置
R3:
route-map WEIGHT permit 10
set weight 100
!
router bgp 2
neighbor 155.1.13.1 route-map WEIGHT in 此处为什么要选择in而不是out?
!

 
验证配置:如下所示,有限选择weight较高的路由。
R3#show ip bgp
BGP table version is 3, local router ID is 155.1.37.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

 
Network Next Hop Metric LocPrf Weight Path
* 155.1.5.0/24 155.1.0.5 0 0 1 i
*>i 155.1.13.1 0 100 200 1 i
*> 155.1.37.0/24 0.0.0.0 0 32768 i

 
R3#show ip bgp 155.1.5.0
BGP routing table entry for 155.1.5.0/24, version 2
Paths: (2 available, best #2, table Default-IP-Routing-Table)
Flag: 0x820
Advertised to update-groups:
2
1
155.1.0.5 from 155.1.0.5 (155.1.5.5)
Origin IGP, metric 0, localpref 100, valid, external
1
155.1.13.1 from 155.1.13.1 (155.1.146.1)
Origin IGP, metric 0, localpref 100, weight 200, valid, internal, best