【实验要求】
在 AS1 中配置 BGP MED 值,
确保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.
【MED 配置方法】
下一步配置MED值让流量走R1
配置方法:
R4:
route-map MED permit 10
set metric 100
!
router bgp 1
neighbor 155.1.146.1 route-map MED out
R5:
route-map MED permit 10
set metric 200
!
router bgp 1
neighbor 155.1.0.3 route-map MED out
【配置后验证】
R3#show ip bgp 下面验证了配置是正确的,BGP选择metric(MED)更小的路由。
BGP table version is 5, 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
*>i155.1.5.0/24 155.1.13.1
100 100 0 1 i
* 155.1.0.5
200 0 1 i
*> 155.1.37.0/24 0.0.0.0 0 32768
i
本文转自zcm8483 51CTO博客,原文链接:http://blog.51cto.com/haolun/992842