【实验说明】
在AS2中配置BGP Local Preference 参数,
确保R3上由155.1.37.0/24 网络到155.1.5.0 网络的流量走R1
【实验拓扑】
【实验步骤】
- 按照上图配置网络
- 在 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
- 在AS2中配置Local preference 参数,确保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.
【local preference 配置方法】
下一步配置本地优先级让流量走R1
配置方法:
R3:
route-map LOCAL_PREFERENCE permit 10
set local-preference 200
!
router bgp 2
neighbor 155.1.13.1 route-map LOCAL_PREFERENCE in
【验证配置】
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
200
0
1 i
注意这里的local Preference被修改为200
*> 155.1.37.0/24 0.0.0.0 0 32768
i
R3#show ip route
155.1.0.0/24 is subnetted, 4 subnets
C 155.1.13.0 is directly connected, Serial0/1
C 155.1.0.0 is directly connected, Serial0/0
B 155.1.5.0 [200/0] via 155.1.13.1, 00:06:50
C 155.1.37.0 is directly connected, Loopback0
本文转自zcm8483 51CTO博客,原文链接:http://blog.51cto.com/haolun/992843