基本配置:
enableconf tno ip do loenable pass ciscoline con 0logg syncexec-t 0 0line vty 0 4pass ciscologg syncexithost BGP基本配置:-------------------------------------------------------------------------------------------------------------------------------------------------------------
R1:int f0/0ip add 12.1.1.1 255.255.255.0no shutexitint l0ip add 11.1.1.1 255.255.255.0no shutexitrouter eigrp 1no auto-summarynetwork 12.1.1.0 0.0.0.255network 11.1.1.0 0.0.0.255exitR2:int f0/0ip add 12.1.1.2 255.255.255.0no shutexitint l0ip add 22.1.1.1 255.255.255.0no shutexitrouter eigrp 1no auto-summarynetwork 12.1.1.0 0.0.0.255network 22.1.1.0 0.0.0.255exitR1:endping 22.1.1.1 source 11.1.1.1conf trouter bgp 100no synchronizationno auto-summarybgp router-id 11.1.1.1neighbor 22.1.1.1 remote-as 100neighbor 22.1.1.1 update-source l0exitR2:router bgp 100bgp router-id 22.1.1.1 neighbor 11.1.1.1 remote-as 100neighbor 11.1.1.1 update-source l0exitint f1/0ip add 23.1.1.2 255.255.255.0no shutexitrouter bgp 100neighbor 23.1.1.3 remote-as 200exitR3:int f0/0ip add 23.1.1.3 255.255.255.0no shutexitrouter bgp 200bgp router-id 33.1.1.1neighbor 23.1.1.2 remote-as 100exitR2:endshow ip bgp summaryconf t路由信息的通告:----------------------------------------------------R3:int l0ip add 33.1.1.1 255.255.255.0exitrouter bgp 200network 33.1.1.0 mask 255.255.255.0exitR1:router bgp 100redistribute eigrp 1exitR2:endshow ip bgpconf tR1:endshow ip bgpconf tR2:router bgp 100neighbor 11.1.1.1 next-hop-selfexitR1:endshow ip bgpconf t理解同步以及解决路由黑洞:
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
R1:int f0/0ip add 12.1.1.1 255.255.255.0no shutexitint l0ip add 11.1.1.1 255.255.255.0no shutexitrouter eigrp 1no auto-summarynetwork 12.1.1.0 0.0.0.255network 11.1.1.0 0.0.0.255exitR2:int f0/0ip add 12.1.1.2 255.255.255.0no shutexitint f1/0ip add 23.1.1.2 255.255.255.0no shutexitrouter eigrp 1no auto-summarynetwork 12.1.1.0 0.0.0.255network 23.1.1.0 0.0.0.255exitR3:int f0/0ip add 23.1.1.3 255.255.255.0no shutexitint l0ip add 33.1.1.1 255.255.255.0no shutexitrouter eigrp 1no auto-summarynetwork 23.1.1.0 0.0.0.255network 33.1.1.0 0.0.0.255exit------------------------------------------R1:router bgp 100bgp router-id 11.1.1.1neighbor 33.1.1.1 remote-as 100neighbor 33.1.1.1 update-source l0neighbor 33.1.1.1 next-hop-selfexitR3:router bgp 100bgp router-id 33.1.1.1neighbor 11.1.1.1 remote-as 100neighbor 11.1.1.1 update-source l0neighbor 11.1.1.1 next-hop-selfexitint f1/0ip add 34.1.1.3 255.255.255.0no shutexitrouter bgp 100neighbor 34.1.1.4 remote-as 200exitR4:int f0/0ip add 34.1.1.4 255.255.255.0no shutexitrouter bgp 200bgp router-id 44.1.1.1neighbor 34.1.1.3 remote-as 100exit-----------------------------------------------------R1:int l1ip add 100.1.1.1 255.255.255.0no shutexitrouter bgp 100network 100.1.1.0 mask 255.255.255.0exitR3:endshow ip bgpshow ip route bgpconf tR4:endshow ip bgpconf tR3:endping 100.1.1.1conf tR2:endshwo ip routeconf tR3:router bgp 100synchronizationendclear ip bgp *shwo ip bgpconf tR4:endshow ip bgpconf t-----------------------------------------R2:int l0ip add 22.1.1.1 255.255.255.0no shutexitrouter eigrp 1network 22.1.1.0 0.0.0.255exitrouter bgp 100bgp router-id 22.1.1.1neighbor 11.1.1.1 remote-as 100neighbor 11.1.1.1 update-source l0neighbor 11.1.1.1 next-hop-selfneighbor 33.1.1.1 remote-as 100neighbor 33.1.1.1 update-source l0neighbor 33.1.1.1 next-hop-selfexitR1:router bgp 100neighbor 22.1.1.1 remote-as 100neighbor 22.1.1.1 update-source l0neighbor 22.1.1.1 next-hop-selfexitR3:router bgp 100neighbor 22.1.1.1 remote-as 100neighbor 22.1.1.1 update-source l0neighbor 22.1.1.1 next-hop-selfno synchronizationexit-----------------------------------------------R3:endclear ip bgp *shwo ip bgpconf tR4:endshow ip bgpconf tR3:endping 100.1.1.1conf tR4:int l0ip add 44.1.1.1 255.255.255.0exitrouter bgp 200network 44.1.1.0 mask 255.255.255.0exitendping 100.1.1.1 source 44.1.1.1conf t用peer-group的方法建立邻居关系-----------------------------------------------R1:router bgp 100bgp router-id 11.1.1.1neighbor IBGP peer-groupneighbor IBGP remote-as 100neighbor IBGP update-source l0neighbor IBGP next-hop-selfneighbor 22.1.1.1 peer-group IBGPneighbor 33.1.1.1 peer-group IBGPexitR2:router bgp 100bgp router-id 22.1.1.1neighbor IBGP peer-groupneighbor IBGP remote-as 100neighbor IBGP update-source l0neighbor IBGP next-hop-selfneighbor 11.1.1.1 peer-group IBGPneighbor 33.1.1.1 peer-group IBGPexitR3:router bgp 100bgp router-id 33.1.1.1neighbor IBGP peer-groupneighbor IBGP remote-as 100neighbor IBGP update-source l0neighbor IBGP next-hop-selfneighbor 22.1.1.1 peer-group IBGPneighbor 11.1.1.1 peer-group IBGPexitBGP的自动汇总:
------------------------------------------------------------------------------------------------------------------------------------------------------------------
R1:int f0/0ip add 12.1.1.1 255.255.255.0no shutexitint l0ip add 11.1.1.1 255.255.255.0no shutexitrouter eigrp 1no auto-summarynetwork 12.1.1.0 0.0.0.255network 11.1.1.0 0.0.0.255exitR2:int f0/0ip add 12.1.1.2 255.255.255.0no shutexitint l0ip add 22.1.1.1 255.255.255.0no shutexitint f1/0ip add 23.1.1.2 255.255.255.0no shutexitrouter eigrp 1no auto-summarynetwork 12.1.1.0 0.0.0.255network 22.1.1.0 0.0.0.255exitR1:router bgp 100bgp router-id 11.1.1.1neighbor 22.1.1.1 remote-as 100neighbor 22.1.1.1 update-source l0neighbor 22.1.1.1 next-hop-selfexitR2:router bgp 100bgp router-id 22.1.1.1neighbor 11.1.1.1 remote-as 100neighbor 11.1.1.1 update-source l0neighbor 11.1.1.1 next-hop-selfneighbor 23.1.1.3 remote-as 200exitR3:int f0/0ip add 23.1.1.3 255.255.255.0no shutexitrouter bgp 200bgp router-id 33.1.1.1neighbor 23.1.1.2 remote-as 100exitR3:int l1ip add 100.1.1.1 255.255.255.0no shutexitint l2ip add 100.1.2.1 255.255.255.0no shutexitint l3ip add 100.1.3.1 255.255.255.0no shutexitrouter bgp 200auto-summarynetwork 100.1.1.0 mask 255.255.255.0network 100.1.2.0 mask 255.255.255.0network 100.1.3.0 mask 255.255.255.0exitR2:endshow ip bgpconf tR3:router bgp 200network 100.0.0.0exitR2:endshow ip bgpconf trouter bgp 100auto-summaryredistribute eigrp 1exitBGP的手动汇总:
-----------------------------------------------------R1:int f0/0ip add 12.1.1.1 255.255.255.0no shutexitint l0ip add 11.1.1.1 255.255.255.0no shutexitrouter eigrp 1no auto-summarynetwork 12.1.1.0 0.0.0.255network 11.1.1.0 0.0.0.255exitR2:int f0/0ip add 12.1.1.2 255.255.255.0no shutexitint l0ip add 22.1.1.1 255.255.255.0no shutexitint f1/0ip add 23.1.1.2 255.255.255.0no shutexitrouter eigrp 1no auto-summarynetwork 12.1.1.0 0.0.0.255network 22.1.1.0 0.0.0.255exitR1:router bgp 100bgp router-id 11.1.1.1neighbor 22.1.1.1 remote-as 100neighbor 22.1.1.1 update-source l0neighbor 22.1.1.1 next-hop-selfexitR2:router bgp 100bgp router-id 22.1.1.1neighbor 11.1.1.1 remote-as 100neighbor 11.1.1.1 update-source l0neighbor 11.1.1.1 next-hop-selfneighbor 23.1.1.3 remote-as 200exitR3:int f0/0ip add 23.1.1.3 255.255.255.0no shutexitrouter bgp 200bgp router-id 33.1.1.1neighbor 23.1.1.2 remote-as 100exitR3:int l1ip add 100.1.1.1 255.255.255.0no shutexitint l2ip add 100.1.2.1 255.255.255.0no shutexitint l3ip add 100.1.3.1 255.255.255.0no shutexitrouter bgp 200network 100.1.1.0 mask 255.255.255.0network 100.1.2.0 mask 255.255.255.0network 100.1.3.0 mask 255.255.255.0exitR2:endshow ip bgpconf trouter bgp 100aggregate-add 100.1.0.0 255.255.0.0exitendshow ip bgpconf tR1:endshow ip bgpconf tR2:router bgp 100aggregate-add 100.1.0.0 255.255.0.0 summary-onlyexitR1:endshow ip bgpconf t路由器选路原则:
---------------------------------------------------------------------
Well-Known Mandatory:
Origin, AS-Path, Next_HopWell-Known Discretionary: Local_Pref, Atomic_AggregateOptional Transitive: Aggregator, CommunityOptional Nontransitive: Med, Originator_Id, Cluster_ListWeight(最大) -- Local_Pref(最高) -- 本路由器 -- As_Path(最短) -- Origin(最低IGP<BGP<INCOMPLETE) -- MED(最低) -- (EBGP路由>联盟EGBP路由>IBGP路由) -- (离IGP邻居最近) -- (配置了maximum-path(IBGP),负载均衡) -- 更老的RBGP路由条目 -- BGP路由器ID(最低) -- Cluster-List(最短) -- BGP邻居地址(neighbor)优选Weight值更高的路由:
-----------------------------------------------------------------------------------------R1:int f0/0ip add 12.1.1.1 255.255.255.0no shutexitint f1/0ip add 13.1.1.1 255.255.255.0no shutexitint l0ip add 11.1.1.1 255.255.255.0no shutexitrouter eigrp 1no auto-summarynetwork 12.1.1.0 0.0.0.255network 11.1.1.0 0.0.0.255exit router bgp 100bgp router-id 11.1.1.1neighbor 22.1.1.1 remote-as 100neighbor 22.1.1.1 update-source l0neighbor 22.1.1.1 next-hop-selfneighbor 13.1.1.3 remote-as 200exitR2:int f0/0ip add 12.1.1.2 255.255.255.0no shutexitint f1/0ip add 23.1.1.2 255.255.255.0no shutexitint l0ip add 22.1.1.1 255.255.255.0no shutexitrouter eigrp 1no auto-summarynetwork 12.1.1.0 0.0.0.255network 22.1.1.0 0.0.0.255exitrouter bgp 100bgp router-id 22.1.1.1neighbor 11.1.1.1 remote-as 100neighbor 11.1.1.1 update-source l0neighbor 11.1.1.1 next-hop-selfneighbor 23.1.1.3 remote-as 200exitR3:int f1/0ip add 13.1.1.3 255.255.255.0no shutexitint f0/0ip add 23.1.1.3 255.255.255.0no shutexitint l0ip add 33.1.1.1 255.255.255.0no shutexitrouter bgp 200bgp router-id 33.1.1.1neighbor 13.1.1.1 remote-as 100neighbor 23.1.1.2 remote-as 100network 33.1.1.0 mask 255.255.255.0exit-------------------------------------------------------------R1:endshow ip bgpconf trouter bgp 100neighbor 22.1.1.1 weight 1000exitendclear ip bgp *show ip bgpconf tip prefix-list 33.1 permit 33.1.1.0/24route-map wei permit 10match ip add prefix-list 33.1set weight 200exitroute-map wei permit 9999exitrouter bgp 100neighbor 22.1.1.1 route-map wei inexitendclear ip bgp * inshow ip bgpconf tR3:int l1ip add 33.1.2.1 255.255.255.0no shutexitrouter bgp 200network 33.1.2.0 mask 255.255.255.0exitR1:endshow ip bgpconf t优选Local Preference值更高的路由:
-----------------------------------------------------R1:endshow ip bgp summaryshow ip bgpshow ip bgp 33.1.1.0conf tip prefix-list 33.1 permit 33.1.1.0/24route-map LOC permit 10match ip add prefix-list 33.1set local-preference 200exitroute-map Loc permit 9999exitrouter bgp 100neighbor 22.1.1.1 route-map LOC inexitendclear ip bgp * inshow ip bgpconf trouter bgp 100bgp default local-preference 300exitendshow ip bgpshow ip bgp 33.1.1.0conf tR2:endshow ip bgpconf t 优选从本地路由器始发的路由:---------------------------------------------------------------R1:int l100ip add 100.1.1.1 255.255.255.0exit router bgp 100network 100.1.1.0 mask 255.255.255.0exitR2:int l100ip add 100.1.1.1 255.255.255.0exitip prefix-list 100 permit 100.1.1.0/24route-map WEI permit 10match ip add prefix-list 100set weight 0exitrouter bgp 100network 100.1.1.0 mask 255.255.255.0 route-map WEIexitendshow ip bgpconf t优选有最短AS-Path的BGP路由条目
--------------------------------------------------------------R1:endshow ip bgpconf tip prefix-list 33.1 permit 33.1.1.0/24route-map AS permit 10match ip add prefix-list 33.1set as-path prepend 10 20 30exitroute-map AS permit 9999exitrouter bgp 100neighbor 13.1.1.3 route-map AS inexitendclear ip bgp * inshow ip bgpconf t选择更低Origin属性的路由
--------------------------------------------------------------R1:endshow ip bgpconf tip prefix-list 33.1 permit 33.1.1.0/24route-map ORI permit 10match ip add prefix-list 33.1set origin incompleteexitroute-map ORI permit 9999exitrouter bgp 100neighbor 13.1.1.3 route-map ORI inexitendclear ip bgp * inshow ip bgpconf t