BGP ORIGIN 属性控制选路

 

拓扑结构

实验拓扑如图所示。

 

 

.实验步骤

本实验是在路由器 R4 上配置“4.4.4.0/24”的起源代码属性为 EGP,并通过 EBGP 邻居

14.14.14.1”传入 AS 100 内,然后观察路由器 R1R2 R3 对路由器 R4 上通告的

4.4.4.0/24”路由的选路。

1)步骤 1:配置路由器 R1

R1(config)#router eigrp 1

R1(config-router)#network 1.1.1.0 255.255.255.0

R1(config-router)#network 12.12.12.0 255.255.255.0

R1(config-router)#no auto-summary R1(config)#router bgp 100

R1(config-router)#no synchronization

R1(config-router)#no auto-summary

R1(config-router)#bgp router-id 1.1.1.1

R1(config-router)#neighbor 2.2.2.2 remote-as 100

R1(config-router)#neighbor 2.2.2.2 update-source Loopback0

R1(config-router)#neighbor 2.2.2.2 next-hop-self

R1(config-router)#neighbor 3.3.3.3 remote-as 100

R1(config-router)#neighbor 3.3.3.3 update-source Loopback0

R1(config-router)#neighbor 3.3.3.3 next-hop-self

R1(config-router)#neighbor 14.14.14.4 remote-as 200

2)步骤 2:配置路由器 R2

R2(config)#router eigrp 1

R2(config-router)#network 2.2.2.0 255.255.255.0

R2(config-router)#network 12.12.12.0 255.255.255.0

R2(config-router)#network 23.23.23.0 255.255.255.0

R2(config-router)#no auto-summary

R2(config)#router bgp 100

R2(config-router)#no synchronization

R2(config-router)#no auto-summary

R2(config-router)#bgp router-id 2.2.2.2

R2(config-router)#neighbor 1.1.1.1 remote-as 100

R2(config-router)#neighbor 1.1.1.1 update-source Loopback0

R2(config-router)#neighbor 3.3.3.3 remote-as 100

R2(config-router)#neighbor 3.3.3.3 update-source Loopback0

3)步骤 3:配置路由器 R3

R3(config)#router eigrp 1

R3(config-router)#network 3.3.3.0 255.255.255.0

R3(config-router)#network 23.23.23.0 255.255.255.0

R3(config-router)#no auto-summary

R3(config)#router bgp 100

R3(config-router)#no synchronization

R3(config-router)#no auto-summary

R3(config-router)#bgp router-id 3.3.3.3

R3(config-router)#neighbor 1.1.1.1 remote-as 100

R3(config-router)#neighbor 1.1.1.1 update-source Loopback0

R3(config-router)#neighbor 1.1.1.1 next-hop-self

R3(config-router)#neighbor 2.2.2.2 remote-as 100

R3(config-router)#neighbor 2.2.2.2 update-source Loopback0

R3(config-router)#neighbor 2.2.2.2 next-hop-self

R3(config-router)#neighbor 34.34.34.4 remote-as 200

4)步骤 4:配置路由器 R4

R4(config-router)#ip prefix-list 1 permit 4.4.4.0/24

R4(config)#route-map egp permit 10 R4(config-route-map)#match ip address prefix-list 1

R4(config-route-map)#set origin egp 900    //设置起源代码

R4(config)#router bgp 200

R4(config-router)#no synchronization

R4(config-router)#no auto-summary

R4(config-router)#bgp router-id 4.4.4.4

R4(config-router)#network 4.4.4.0 mask 255.255.255.0

R4(config-router)#neighbor 14.14.14.1 remote-as 100

R4(config-router)#neighbor 14.14.14.1 route-map egp out

//在出方向为去往邻居 14.14.14.1 的路由设置策略

R4(config-router)#neighbor 34.34.34.3 remote-as 100

4.实验调试

在路由器 R1R2 R3 上查看 BGP 表:

R1#show ip bgp

BGP table version is 6, local router ID is 1.1.1.1

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

*>i4.4.4.0/24       3.3.3.3                  0    100      0 200 i

*                   14.14.14.4               0             0 200 e

R2#show ip bgp

BGP table version is 5, local router ID is 2.2.2.2

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

*>i4.4.4.0/24       3.3.3.3                  0    100      0 200 i

R3#show ip bgp

BGP table version is 4, local router ID is 3.3.3.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

*> 4.4.4.0/24       34.34.34.4               0             0 200 i

以上输出表明路由器 R1学到两条关于“4.4.4.0/24”的路由,但是由于起源代码“i

优先于“e ,所以从路由器 R3 学到的路由被优化,而从邻居路由器 R4 学到的路由不能被优

化(路由代码只为“* ,没有“> ,不能继续通告给路由器 R2 R3,所以路由器 R2 R3

只有一条关于“4.4.4.0/24”的路由。