【实验要求】
 

在 AS2 中修改 BGP Origin, 确保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.

R3#show ip bgp 155.1.5.0 查看详细路由时发现两个的Origin 都是IGP
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:
1
1
155.1.13.1 from 155.1.13.1 (155.1.146.1)
Origin IGP, metric 0, localpref 100, valid, internal
1
155.1.0.5 from 155.1.0.5 (155.1.5.5)
Origin IGP, metric 0, localpref 100, valid, external, best

 
【MED 配置方法】
下一步配置MED值让流量走R1
配置方法:只要在R3上配置 neighbor 到155.1.0.5 的Origin修改为 EGP 或 incomplete,配置EGP需要指定AS号,我们以incomplete的方式配置
R3:
route-map ORIGIN permit 10
set Origin incomplete
!
router bgp 2
neighbor 155.1.0.5 route-map ORIGIN in

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

我们看到 Origin 被修改为 imcomplete,同时路由选择也发生了变化,


 
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
*>i155.1.5.0/24 155.1.13.1 0 100 0 1 i
* 155.1.0.5 0 0 1 ?
*> 155.1.37.0/24 0.0.0.0 0 32768 i