用 BGP ORIGIN 屬性控制選路

 

    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”的路由。

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章