1.作業準備:
如圖所示先建立R1~R5的BGP鄰居關係(R6R7會在隨後的題目中添加),R2R3底層運行RIPV2,屬於AS23,使用環回口10.10.X.X/24建立IBGP鄰居關係;R1R4R5運行EIGRP,屬於AS145,使用環回口10.10.X.X/24建立IBGP鄰居關係,在R3R4之間利用直連接口1.1.34.X/24建立EBGP鄰居關係,在R1R2之間利用直連接口1.1.12.X/24建立EBGP鄰居關係,所有的BGProuter-ID都是X.X.X.X
配置:
R1:
Interfaceloopback0
Ipaddress10.10.1.1255.255.255.0
Interfaces1/0
Ipaddress1.1.12.1255.255.255.0
Noshutdown
Interfacef0/0
Ipaddress1.1.145.1255.255.255.0
Noshutdown
Routereigrp90
Noauto-summary
Network10.10.1.10.0.0.0
Network1.1.145.10.0.0.0
Routerbgp145
Bgprouter-id1.1.1.1
Neighbor1.1.12.2remote-as23
Neighbor10.10.4.4remote-as145
Neighbor10.10.4.4update-sourceloopback0
Neighbor10.10.4.4next-hop-self
Neighbor10.10.5.5remote-as145
Neighbor10.10.5.5update-sourceloopback0
Neighbor10.10.5.5next-hop-self
-----------------------------------------------------------------
R2:
Interfaceloopback0
Ipaddress10.10.2.2255.255.255.0
Interfaces1/0
Ipaddress1.1.12.2255.255.255.0
Noshutdown
Interfaces1/1
Ipaddress1.1.23.2255.255.255.0
Noshutdown
Routerrip
Version2
Noauto-summary
Network1.0.0.0
Network10.0.0.0
Routerbgp23
Bgprouter-id2.2.2.2
Neighbor1.1.12.1remote-as145
Neighbor10.10.3.3remote-as23
Neighbor10.10.3.3update-sourceloopback0
--------------------------------------------------------------------
R3:
Interfaceloopback0
Ipaddress10.10.3.3255.255.255.0
Interfaces1/0
Ipaddress1.1.34.3255.255.255.0
Noshutdown
Interfaces1/1
Ipaddress1.1.23.3255.255.255.0
Noshutdown
Routerrip
Version2
Noauto-summary
Network1.0.0.0
Network10.0.0.0
Routerbgp23
Bgprouter-id3.3.3.3
Neighbor1.1.34.4remote-as145
Neighbor10.10.2.2remote-as23
Neighbor10.10.2.2update-sourceloopback0
---------------------------------------------------------------------
R4:
Interfaceloopback0
Ipaddress10.10.4.4255.255.255.0
Interfaces1/0
Ipaddress1.1.34.4255.255.255.0
Noshutdown
Interfacef0/0
Ipaddress1.1.145.4255.255.255.0
Noshutdown
Routereigrp90
Noauto-summary
Network1.1.145.40.0.0.0
Network10.10.4.40.0.0.0
Routerbgp145
Bgprouter-id4.4.4.4
Neighbor1.1.34.3remote-as23
Neighbor10.10.1.1remote-as145
Neighbor10.10.1.1update-sourceloopback0
Neighbor10.10.1.1next-hop-self
Neighbor10.10.5.5remote-as145
Neighbor10.10.5.5update-sourceloopback0
Neighbor10.10.5.5next-hop-self
---------------------------------------------------------------------------------------------------------------
R5:
Interfaceloopback0
Ipaddress10.10.5.5255.255.255.0
Interfacef0/0
Ipaddress1.1.145.5255.255.255.0
Noshutdown
Routereigrp90
Noauto-summary
Network1.1.145.50.0.0.0
Network10.10.5.50.0.0.0
Routerbgp145
Bgprouter-id5.5.5.5
Neighbor10.10.1.1remote-as145
Neighbor10.10.1.1update-sourceloopback0
Neighbor10.10.1.1next-hop-self
Neighbor10.10.4.4remote-as145
Neighbor10.10.4.4update-sourceloopback0
Neighbor10.10.4.4next-hop-self
--------------------------------------------------------------------------------------------------------------
2.在R2上將1.1.23.0/24宣告進BGP,要求在R5的BGP表中看到關於1.1.23.0/24的2條條目,並且來自R1的這條路由能出現在R5的路由表中
配置:
R2:
Routerbgp23
Network1.1.23.0mask255.255.255.0
現象:
R5:showiproute
1.0.0.0/24issubnetted,2subnets
B1.1.23.0[200/0]via10.10.1.1,00:00:12
C1.1.145.0isdirectlyconnected,FastEthernet0/0
10.0.0.0/24issubnetted,3subnets
D10.10.1.0[90/156160]via1.1.145.1,00:05:27,FastEthernet0/0
D10.10.4.0[90/156160]via1.1.145.4,00:05:30,FastEthernet0/0
C10.10.5.0isdirectlyconnected,Loopback0
----------------------------------------------------------
3.在R1上將和R4的鄰居關係管理性關閉,修改R1的BGProuter-ID爲4.4.4.4,觀察R5上的BGP表項,要求使R5上BGP顯示爲下面所示:次序必須一致(完成以後還原R1BGPRID爲1.1.1.1)
*i1.1.23.0/2410.10.4.40100023i
*>i10.10.1.10100023i
配置:
R1:
Routerbgp145
Neighbor10.10.4.4shutdown
Bgprouter-id4.4.4.4
R5:
Clearipbgp10.10.4.4
現象:
R5:showipbgp
NetworkNextHopMetricLocPrfWeightPath
*i1.1.23.0/2410.10.4.40100023i
*>i10.10.1.10100023i
R5:showipbgp1.1.23.0
GProutingtableentryfor1.1.23.0/24,version6
Paths:(2available,best#2,tableDefault-IP-Routing-Table)
Notadvertisedtoanypeer
23
10.10.4.4(metric156160)from10.10.4.4(4.4.4.4)
OriginIGP,metric0,localpref100,valid,internal
23
10.10.1.1(metric156160)from10.10.1.1(4.4.4.4)
OriginIGP,metric0,localpref100,valid,internal,best
結論:路由器可以接收來自兩個route-id一樣的路由器的路由,BGP表中位置在越上面,表示這條路由是最新收到的
4.在R2上做設置,使得R1上收到這條路由時增加300500這兩個AS-PATH,使用前綴列表,route-map的名稱爲R2-R1-OUT
配置:
R2:
Ipprefix-list23permit1.1.23.0/24
Route-mapR2-R1-OUT
Matchipaddressprefix-list23
Setas-pathprepend300500
Route-mapR
Routerbgp23-R-OUTpermit20
Neighbor1.1.12.1route-mapR2-R1-OUTout
現象:
R1:showipbgp
NetworkNextHopMetricLocPrfWeightPath
*1.1.23.0/241.1.12.20023300500i
*>i10.10.4.40100023i
需求:還原R2配置,在R1上實現同樣需求,route-map的名稱爲R2-R1-IN;仔細分析這兩種方式最終在R1上的顯示有何不同,爲什麼?(完成以後還原配置,刪除route-map和前綴列表)
配置:
R1:
Ipprefix-list23permit1.1.23.0/24
Route-mapR2-R1-IN
Matchipaddressprefix-list23
Setas-pathprepend300500
Route-mapR2-R1-INpermit20
Routerbgp145
Neighbor1.1.12.2route-mapR2-R1-INin
現象:
R1:showipbgp
NetworkNextHopMetricLocPrfWeightPath
*1.1.23.0/241.1.12.20030050023i
*>i10.10.4.40100023i
結論:在BGP表中的Path項中,位置越是靠左的,表示AS號越是最新添加的,如果在出方向上調用添加AS配置的話,那麼順序將是先添加route-map中增加的AS,然後在傳出AS23時再添加AS號23,所以結果是23300500,如果是在入方向調用添加AS配置的話,那麼順序將是先收到來自AS23的路由,然後再添加route-map中增加的AS,所以結果是30050023
5.添加300500這樣的AS號是一種不好的方式,請更改使用更合適的方式實現延長AS-PATH的目的。如果在R2上使用了prepend145145145來加長AS-PATH長度的話,那麼R1上將收不到這條路由,爲什麼?通過在R1上配置,使R1能收到這條路由(完成以後還原配置,刪除route-map和前綴列表)
配置:
R1:
Routerbgp145
Neighbor1.1.12.2allowas-in3
R2:
Ipprefix-list23permit1.1.23.0/24
Route-mapR2-R1-OUT
Matchipaddressprefix-list23
Setas-pathprepend145145145
Route-mapR2-R1-OUTpermit20
Routerbgp23
Neighbor1.1.12.1route-mapR2-R1-OUTout
現象:
R1:showipbgp
NetworkNextHopMetricLocPrfWeightPath
*1.1.23.0/241.1.12.20023145145145i
*>i10.10.4.40100023i
結論:如果在出方向上增加了路由將要到達的AS號的話,這條路由在還沒到達下個AS時就已經帶有了下個AS的號了,那麼根據EBGP路由防環原則,下個AS將不會收帶有本AS號的路由,所以,無論是在出方向或是入方向添加AS號,都應該對已經出現在本路由的路由添加自己的AS號
6.添加路由器R6,屬於AS600,通過直連1.1.26.X/24和R2建立eBGP鄰居關係,將環回口6.6.6.6/24宣告進BGP;在R2上使用前綴列表匹配6.6.6.0/24,使用R2-R1-OUTroute-map,setas-pathprependlast-as2,使得R1上看到的AS-PATH長度變長
配置:
R2:
Ipprefix-list6permit6.6.6.0/24
Route-mapR2-R1-OUT
Matchipaddressprefix-list6
Setas-pathprependlast-as2
Route-mapR2-R1-OUTpermit20
Interfaces1/2
Ipaddress1.1.26.2255.255.255.0
Noshutdown
Routerbgp23
Neighbor1.1.26.6remote-as600
Neighbor1.1.12.1route-mapR2-R1-OUTout
---------------------------------------------------------------------------------------------
R6:
Interfaceloopback0
Ipaddress6.6.6.6255.255.255.0
Interfaces1/2
Ipaddress1.1.26.6255.255.255.0
Noshutdown
Routerbgp600
Bgprouter-id6.6.6.6
Neighbor1.1.26.2remote-as23
Network6.6.6.0mask255.255.255.0
現象:
R1:showipbgp
NetworkNextHopMetricLocPrfWeightPath
*>1.1.23.0/241.1.12.20023i
*i10.10.4.40100023i
*>i6.6.6.0/2410.10.4.40100023600i
*1.1.12.2023600600600I
需求:將R2上的策略刪除,將其放在R1上實現同樣的需求,仔細觀察兩者的區別,理解last-as語句的意思
配置:
R1:
Ipprefix-list6permit6.6.6.0/24
Route-mapR2-R1-IN
Matchipaddressprefix-list6
Setas-pathprependlast-as2
Route-mapR2-R1-INpermit20
Routerbgp145
Neighbor1.1.12.2route-mapR2-R1-INin
現象:
R1:showipbgp
NetworkNextHopMetricLocPrfWeightPath
*>1.1.23.0/241.1.12.20023i
*i10.10.4.40100023i
*>i6.6.6.0/2410.10.4.40100023600i
*1.1.12.20232323600i
結論:無論是出方向還是入方向,增加的AS號都是上個AS的號,默認的添加次數是3次
7.在R1上僅將6.6.6.0/24這一條路由重分佈進EIGRP,在R5或者R4上觀察EIGRP拓撲表,觀察這條從BGP重分佈進來的路由有什麼特徵?總結:當把BGP路由重分佈進IGP時會有什麼默認行爲
配置:
R1:
Route-mapRED
Matchipaddressprefix-list6
Routereigrp90
Redistributebgp145metric1000001025511500route-mapRED
現象:
R5:showiproute6.6.6.0
Routingentryfor6.6.6.0/24
Knownvia"eigrp90",distance170,metric30720
Tag23,typeexternal
Redistributingviaeigrp90
Lastupdatefrom1.1.145.1onFastEthernet0/0,00:00:28ago
RoutingDescriptorBlocks:
*1.1.145.1,from1.1.145.1,00:00:28ago,viaFastEthernet0/0
Routemetricis30720,trafficsharecountis1
Totaldelayis200microseconds,minimumbandwidthis100000Kbit
Reliability255/255,minimumMTU1500bytes
Loading1/255,Hops1
結論:向IGP中重分佈BGP路由時,默認會帶有上個AS號的Tag值
8.在R4上管理性關閉和R1R5的BGP鄰居關係;這時應該在R4上可以看到DEX6.6.6.0/24安裝在路由表中;shiproute6.6.6.0/24注意這條路由有什麼特徵?在R2上管理性關閉和R3的鄰居關係,讓R3不能從R2收到路由;同時在R4上將6.6.6.0/24重分佈進BGP,使用一條命令使這條路由可以在R4通告給R3時帶上AS-PATH屬性23,不允許出現prepend關鍵詞;總結:結合第7題,分析這樣操作的意義(還原設置,R1上去掉BGP向EIGRP的重分佈,R4上去掉EIGRP向BGP的重分佈,打開所有的鄰居管理性關閉,)注意這時R3能不能收到這條路由
配置:
R2:
Routerbgp23
Neighbor10.10.3.3shutdown
R4:
Ipprefix-list6permit6.6.6.0/24
Route-mapD-B
Matchipaddressprefix-list6
Setas-pathtag
Routerbgp145
Neighbor10.10.1.1shutdown
Neighbor10.10.5.5shutdown
Redistributeeigrp90route-mapD-B
現象:
R4:showipbgpneighbor1.1.34.3advertised-routes
NetworkNextHopMetricLocPrfWeightPath
*>6.6.6.0/241.1.145.1307203276823?
結論:在R4向R3發送的6.6.6.0的BGP路由時已經帶上了AS號23,所以根據EBGP防環原則,R3將不會收這條路由,setas-pathtag這條命令的作用是將IGP中路由的TAG值增加到ASPath中,這樣可以防止從原始AS中重分佈出去的路由,通過不運行BGP的IGP區域過渡,再次重分佈進原始AS中,從一定程度上防止了路由環路
9.在R2上將10.10.3.0/24這條R路由宣告進BGP,在R2上觀察此路由和R2直連的那條1.1.23.0/24有什麼不同(下一跳和metric)
配置:
R2:
Routerbgp23
Network10.10.3.0mask255.255.255.0
現象:
R2:showipbgp10.10.3.0
BGProutingtableentryfor10.10.3.0/24,version4
Paths:(1available,best#1,tableDefault-IP-Routing-Table)
Advertisedtononpeer-grouppeers:
1.1.12.11.1.26.610.10.3.3
Local
1.1.23.3from0.0.0.0(2.2.2.2)
OriginIGP,metric1,localpref100,weight32768,valid,sourced,local,best
R2:showipbgp1.1.23.0
BGProutingtableentryfor1.1.23.0/24,version2
Paths:(1available,best#1,tableDefault-IP-Routing-Table)
Advertisedtononpeer-grouppeers:
1.1.12.11.1.26.610.10.3.3
Local
0.0.0.0from0.0.0.0(2.2.2.2)
OriginIGP,metric0,localpref100,weight32768,valid,sourced,local,best
結論:如果BGP中宣告直連路由,那麼下一跳是0.0.0.0,metric0,如果BGP中宣告IGP路由,那麼下一跳將是IGP中到達這條路由的下一跳,和IGP中到達這條路由的METRIC值
10.在R1上現在能看到1.1.23.0/24這條路由,BGP優選了來自R2的,在R1上設置,利用origin屬性,使R1收到來自R2的這條路由的origin屬性變爲e,這時R1如何選誰爲最優
配置:
R1:
Route-mapORI
Matchipaddressprefix-list23
Setoriginegp800
Routerbgp145
Neighbor1.1.12.2route-mapORI
現象:
R1:showiproute
NetworkNextHopMetricLocPrfWeightPath
*>i1.1.23.0/2410.10.4.40100023i
*1.1.12.20023e
*i6.6.6.0/2410.10.4.40100023600i
*>1.1.12.2023600i
*>10.10.3.0/241.1.12.21023i
需求:再將從R4收來的這條路由origin屬性設置爲?,此時R1如何選擇?(完成後還原所有origincode)
配置:
R1:
Route-mapORI
Matchipaddressprefix-list23
Setoriginincomplete
現象:
R1:showipbgp
NetworkNextHopMetricLocPrfWeightPath
*>i1.1.23.0/2410.10.4.40100023i
*1.1.12.20023?
*i6.6.6.0/2410.10.4.40100023600i
*>1.1.12.2023600i
*>10.10.3.0/241.1.12.21023i
結論:起源屬性i優於e和?,setoriginegp後面的數字可以是任意數字
11.在R1上將所有發出的IBGP路由和收到的EBGP路由的默認local-preference值改爲400;在R4上使用R4-R5-OUTroute-map匹配1.1.23.0/24這條路由將local-preference值改爲500,使用nei10.10.5.5R4-R5-OUTroute-mapout來完成需求,此時有沒有成功?爲什麼?在R4上操作如何才能實現需求,使R5優選R4作爲自己的下一跳去往AS23?(完成後,還原所有local-preference值)
配置:
R1:
Routerbgp145
Bgpdefaultlocal-preference400
R4:
Route-mapR4-R5-OUT
Matchipaddressprefix-list23
Setlocal-preference500
Route-mapR4-R5-OUTpermit20
Routerbgp145
Neighbor10.10.5.5route-mapR4-R5-OUTout
現象:
R5:showipbgp
NetworkNextHopMetricLocPrfWeightPath
*>i1.1.23.0/2410.10.1.10400023i
*>i6.6.6.0/2410.10.1.10400023600i
*>i10.10.3.0/2410.10.1.11400023i
結論:沒有成功,因爲,在R4上,去往1.1.23.0的下一跳是R1,所以R4收的是R1傳來的關於1.1.23.0的IBGP路由,根據IBGP水平分割原則,R4將不會把這條路由發給R5,所以R5上只能收到來自R1的關於1.1.23.0的路由
需求:在R4上操作如何才能實現需求,使R5優選R4作爲自己的下一跳去往AS23?(完成後,還原所有local-preference值)
配置:
R4:
Route-mapR3-R4-IN
Matchipaddressprefix-list23
Setlocal-preference500
Route-mapR3-R4-INpermit20
Routerbgp145
Neighbor1.1.34.3route-mapR3-R4-INin
現象:
R5:showipbgp
NetworkNextHopMetricLocPrfWeightPath
*>i1.1.23.0/2410.10.4.40500023i
*>i6.6.6.0/2410.10.1.10400023600i
*>i10.10.3.0/2410.10.1.11400023i
結論:在入方向設置local-preference將同時影響自己和自己的下游路由器
12.在R3和R2上做設置,利用MED使R5去往1.1.23.0/24網段通過R3走
配置:
R2:
Ipprefix-list23permit1.1.23.0/24
Route-mapMED
Matchipaddressprefix-list23
Setmetric200
Route-mapMEDpermit20
Routerbgp23
Neighbor1.1.12.1route-mapMEDout
R3:
Ipprefix-list23permit1.1.23.0/24
Route-mapMED
Matchipaddressprefix-list23
Setmetric100
Route-mapMEDpermit20
Routerbgp23
Neighbor1.1.34.4route-mapMEDout
現象:
R5:showipbgp
NetworkNextHopMetricLocPrfWeightPath
*>i1.1.23.0/2410.10.4.4100100023i
*i6.6.6.0/2410.10.4.40100023600i
*>i10.10.1.10100023600i
*>i10.10.3.0/2410.10.1.11100023i
結論:MED的作用是,告訴其他AS的路由器,通過哪個路由來訪問本AS,MED越小,路徑越優
13.如圖所示添加R7,R7屬於BGPAS700,和R5建立直連口eBGP鄰居,觀察1.1.23.0/24這條路由有沒有MED值?爲什麼?
配置:
R5:
Interfaces1/0
Ipaddress1.1.57.5255.255.255.0
Noshutdown
Routerbgp145
Neighbor1.1.57.7remote-as700
R7:
Interfaces1/0
Ipaddress1.1.57.7255.255.255.0
Noshutdown
Routerbgp700
Bgprouter-id7.7.7.7
Neighbor1.1.57.5remote-as145
現象:
R7:showipbgp1.1.23.0
BGProutingtableentryfor1.1.23.0/24,version3
Paths:(1available,best#1,tableDefault-IP-Routing-Table)
Notadvertisedtoanypeer
14523
1.1.57.5from1.1.57.5(5.5.5.5)
OriginIGP,localpref100,valid,external,best
結論:MED值只在一個AS內生效,不會傳到下個AS
需求:如果要求缺失了MED值的這些路由全部設置爲最大MED值的話,應該在R7上做什麼設置?
配置:
R7:
Routerbgp700
Bgpbestpathmedmissing-as-worse
現象:
R7:showipbgp
NetworkNextHopMetricLocPrfWeightPath
*>1.1.23.0/241.1.57.54294967295014523i
*>6.6.6.0/241.1.57.54294967295014523600i
*>10.10.3.0/241.1.57.54294967295014523I
結論:真實情況下,如果傳入下個AS時沒有MED值,MED在下一個AS中會設置成4294967294,並且在bgp表中是可以優化的,如果MED值是4294967295,路由將無法優化,但在模擬器下,傳入下個AS時,MED被設置成4294967295,並且路由還是能夠優化的