1、BGP选路原则IPA-task packet002:BGP选路原则实验二:BGP选路原则实验目标:调试和观察BGP的选路原则实验TOP:物理拓扑逻辑拓扑基本配置:R1!hostname R1!no ip domain lookup!interface Loopback0 ip address 1.1.1.1 255.255.255.0!interface Loopback10 ip address 10.10.10.10 255.255.255.0 ip ospf network point-to-point!interface Ethernet0/0 ip address 10.1.1.1
2、255.255.255.0!interface Serial1/0 ip address 12.1.1.1 255.255.255.0 serial restart-delay 0 clock rate 64000!interface Serial2/0 ip address 13.1.1.1 255.255.255.0 serial restart-delay 0!router ospf 10 router-id 1.1.1.1 log-adjacency-changes network 10.1.1.0 0.0.0.255 area 0 network 10.10.10.0 0.0.0.2
3、55 area 0 network 12.1.1.0 0.0.0.255 area 0 network 13.1.1.0 0.0.0.255 area 0!router bgp 1 no synchronization bgp router-id 1.1.1.1 bgp log-neighbor-changes network 1.1.1.0 mask 255.255.255.0 neighbor 10.1.1.4 remote-as 345 neighbor 12.1.1.2 remote-as 2 neighbor 13.1.1.3 remote-as 345 no auto-summar
4、y!ip classlessno ip http serverno ip http secure-server!line con 0 exec-timeout 0 0 logging synchronousline aux 0line vty 0 4!endR2!hostname R2!no ip domain lookup!interface Loopback0 ip address 2.2.2.2 255.255.255.0!interface Loopback10 ip address 20.20.20.20 255.255.255.0 ip ospf network point-to-
5、point!interface Ethernet0/0 no ip address shutdown!interface Serial1/0 ip address 24.1.1.2 255.255.255.0 serial restart-delay 0 clock rate 64000!interface Serial2/0 ip address 12.1.1.2 255.255.255.0 serial restart-delay 0!router ospf 10 router-id 2.2.2.2 log-adjacency-changes network 12.1.1.0 0.0.0.
6、255 area 0 network 20.20.20.0 0.0.0.255 area 0 network 24.1.1.0 0.0.0.255 area 0!router bgp 2 no synchronization bgp router-id 2.2.2.2 bgp log-neighbor-changes network 2.2.2.0 mask 255.255.255.0 neighbor 12.1.1.1 remote-as 1 neighbor 24.1.1.4 remote-as 345 no auto-summary!ip classlessno ip http serv
7、erno ip http secure-server!line con 0 exec-timeout 0 0 logging synchronousline aux 0line vty 0 4!endR3!hostname R3!no ip domain lookup!interface Loopback0 ip address 3.3.3.3 255.255.255.0!interface Loopback10 ip address 30.30.30.30 255.255.255.0 ip ospf network point-to-point!interface Ethernet0/0 n
8、o ip address shutdown!interface Serial1/0 ip address 13.1.1.3 255.255.255.0 serial restart-delay 0 clock rate 64000!interface Serial2/0 ip address 35.1.1.3 255.255.255.0 serial restart-delay 0!router ospf 10 router-id 3.3.3.3 log-adjacency-changes network 13.1.1.0 0.0.0.255 area 0 network 30.30.30.0
9、 0.0.0.255 area 0 network 35.1.1.0 0.0.0.255 area 0!router bgp 345 no synchronization bgp router-id 3.3.3.3 bgp log-neighbor-changes network 3.3.3.0 mask 255.255.255.0 neighbor 13.1.1.1 remote-as 1 neighbor 35.1.1.5 remote-as 345 neighbor 45.1.1.4 remote-as 345 no auto-summary!ip classlessno ip http
10、 serverno ip http secure-server!line con 0 exec-timeout 0 0 logging synchronousline aux 0line vty 0 4!EndR4!hostname R4!no ip domain lookup!interface Loopback0 ip address 4.4.4.4 255.255.255.0!interface Loopback10 ip address 40.40.40.40 255.255.255.0 ip ospf network point-to-point!interface Ethernet
11、0/0 ip address 10.1.1.4 255.255.255.0!interface Serial1/0 ip address 45.1.1.4 255.255.255.0 serial restart-delay 0 clock rate 64000!interface Serial2/0 ip address 24.1.1.4 255.255.255.0 serial restart-delay 0!router ospf 10 router-id 4.4.4.4 log-adjacency-changes network 10.1.1.0 0.0.0.255 area 0 ne
12、twork 24.1.1.0 0.0.0.255 area 0 network 40.40.40.0 0.0.0.255 area 0 network 45.1.1.0 0.0.0.255 area 0!router bgp 345 no synchronization bgp router-id 4.4.4.4 bgp log-neighbor-changes network 4.4.4.0 mask 255.255.255.0 neighbor 10.1.1.1 remote-as 1 neighbor 24.1.1.2 remote-as 2 neighbor 35.1.1.3 remo
13、te-as 345 neighbor 45.1.1.5 remote-as 345 no auto-summary!ip classlessno ip http serverno ip http secure-server!line con 0 exec-timeout 0 0 logging synchronousline aux 0line vty 0 4!EndR5!hostname R5!no ip domain lookup!interface Loopback0 ip address 5.5.5.5 255.255.255.0!interface Loopback10 ip add
14、ress 50.50.50.50 255.255.255.0 ip ospf network point-to-point!interface Ethernet0/0 no ip address shutdown!interface Serial1/0 ip address 35.1.1.5 255.255.255.0 serial restart-delay 0 clock rate 64000!interface Serial2/0 ip address 45.1.1.5 255.255.255.0 serial restart-delay 0!router ospf 10 router-
15、id 5.5.5.5 log-adjacency-changes network 35.1.1.0 0.0.0.255 area 0 network 45.1.1.0 0.0.0.255 area 0 network 50.50.50.0 0.0.0.255 area 0!router bgp 345 no synchronization bgp router-id 5.5.5.5 bgp log-neighbor-changes network 5.5.5.0 mask 255.255.255.0 neighbor 35.1.1.3 remote-as 345 neighbor 45.1.1
16、.4 remote-as 345 no auto-summary!ip classlessno ip http serverno ip http secure-server!line con 0 exec-timeout 0 0 logging synchronousline aux 0line vty 0 4!End(注:路由器接口默认是关闭的,所以应将对应的接口开启)如上配置,已经将R1至R5基本配置完成。BGP选路规则:BGP路由信息库(RIB)包括Adj-RIBs-In:储存未经处理的路由信息,来自对等体接收到的更新消息,所包含的路由信息是可用的Loc-RIB: 包含的路由是运行BGP
17、的路由器通过对Adj-RIBs-In中的路由使用他的本地路由策略而选择的路由Adj-RIBs-Out:包含运行BGP的路由器向其对等体公布的路由三个数据库间的处理方法如下:1、为每一条可用路由计算优先级,并对BGP update消息中包含的路由信息变更做出处理。2、将最优路由放入Loc-RIB。3、将适合的路由放入Adj-RIBs-Out(调用仅在上一步完成后)。BGP路径选择顺序1、优选有最大Weight的路由 (范围0到65,535)。A:weight是CISCO私有的参数,路由器配置了权重后在本地有效。2、优选有最大LOCAL_PREF值的路由(范围0到4,294,967,295)。3、
18、优选从本路由器始发的路由(包括本地network配置的重分布,或者在IGP表中已经有一些需要被配置路由聚合的地址,在BGP中用Aggregate命令配置的路由聚合)。4、优选有最短AS_PATH的路由。A:如果配置了Bgp bestpath as-path ignore,则这个步骤被忽略。B:一个AS路径集被当作一个AS,无论在这个集合中有多少AS;AS路径长度中没有包括。AS_CONFED_SEQUENCE。5、根据Origin属性,优选具有最低起源类型的路由(IGPEGPIncomplete)。6、优选最小MED 值的路由(范围0到4,294,967,295)。A:只有在通过两条路径得到第
19、一个AS(对等体)是同一个AS时才进行MED比较;任何子自治域的联盟系统都会被忽略。也就是说,只有在AS序列号中第一个AS号码一致时,才进行MED比较;任何联盟AS序列号(AS_CONFED_SEQUENCE)都会被忽略。B:如果路由器上配置了bgp alwayscomparemed,在全部的路径进行MED比较。但是这需要全体AS都同时启用这个功能,否则有可能发生路由环路。C:如果路由器上配置了bgp bestpath med confed,将对所有只包括AS_CONFED_SEQUENCE的路径进行MED比较(即路径是起源于本地联盟)。D:如果接收到的路径没有分配MED值,则将此路径分配为0
20、,除非路由器上配置了bestpath missingisworst,将被看作MED值为4,294,967,295的路由将在注入到BGP路由选择表之前被改为4,294,967,295。E:BGP明确的MED值9也可以影响此步骤。7、外部路由eBGP优先于联盟(confederation)外部路由优于内部路由iBGP(优选eBGP路由)。注意,路径中包括AS_CONFEND_SEQUENCE属性对联盟只有在本地有效,因此被看作是内部路径。无法区别外部联盟和内部联盟。8、优选能通过最近的IGP邻居到达的路径(优选对BGP下一跳具有最低IGP度量值的路径)。9、如果在路由器上配置了maximumpat
21、hsN,而且从同一个对等体自治域/子自治域接收到多条外部/外部联盟的路径,则最多可以将N条最近接收到的路径加入到IP路由选择表中,这可以使得eBGP在多条路径上进行负载分担,目前N所代表的最大数目是6;当没有启用此功能时,缺省数值是1。在输入了show ipbgp x.x.x.x后系统输出信息中可以看到最早接收到的路径被标记为最优路径,在将这条最优路径转发到内部对等体之前,需要执行与next_hop_self作用相同的功能。10、如果是external的路由,优选最老的路由(最先被学习到的路由)。A:此步骤可以将路由摆动的影响减到最小,因为新接收到的路径不会取代老的,即使这条新接收的路径是通过
22、下面提及到的额外路径选择标准来进行选择的。这使得只在iBGP路径下应用额外的选择步骤更有意义。B:此步骤可以被bgp bestpath compare_routerid命令语句所关闭。C:如果路由器标志是一样的,此步骤可以被屏蔽,因为这说明路由器正在从自己那里接收路由。D:如果当前没有最优路由器,此步骤可以被屏蔽。当提供某个路径的对等体路由器宏机,就会发生丢失当前最优路径的情况。11、如果在同一时间学习到多条到同一目的地的路由,优选最小BGP-router-ID的路由,注意,如果一个路径包括路由反射器属性,起始者标识将代替路由器标识在路径选择过程中起作用。12、如果路由从路由反射器上学习到,优
23、选最小Cluster-ID(BGP_ID of the route reflector)长度的路由,而且它运行客户机和其他反射器族中的RR/Clients之间做对等连接,在这种情况下,路由器必须知道BGP协议中的RR的具体配置。13、优选具有最低对等体地址接收到的路径。这个地址是在BGP对等体上配置并使用的地址,这个地址是本地对等体路由器在其上配置TCP邻居并与远端对等体建立连接时采用的地址。BGP路径选择顺序:如果路径不可达或者同步开启后,路径不同步,则该路径不参与选路1、Weight权重(越大越优先,Cisco私有属性)2、Local_Pref本地优先(越大越优先,本AS内有效)3、Nex
24、t_Hop所传递路由的本地起源优先,即下一跳是0.0.0.0(在BGP表中,当前路由器通告的路由的下一跳为0.0.0.0)4、AS_Path(越短越优先,对于out与in方向的AS_Path操作产生的效果是不同的)5、Origin起源(优先:IGPEGPIncomplete;IGP指通过在BGP中network通告出来的路由,Incomplete指在BGP 中通过重发布通告出来的路由)6、MED(越小越优先,影响另一个AS的出站选路)7、eBGPiBGP(从eBGP对等体学习的路由优先于从iBGP对等体学习的路由)8、BGP 优先选择到BGP下一跳的IGP度量最低的路径9、如果有多条来自相同相
25、邻AS的路由并通过Maximum-paths使多条路径可用,则将所有开销相同的路由加入Loc-RIB10、Age(eBGP)(Age越大越优先,多条路径具有相同的RID,这个原则不考虑)11、BGP 邻居的RID(越小越优先)12、如果多条路径始发路由器ID或路由器ID相同,那么优选Cluster-List最短的路径13、选择邻居ip地址最小的路由下面根据观察每台路由器的BGP表并根据BGP的路径选择顺序进行分析:R1我们可以通过show ip bgp命令来查看本路由器的BGP表,以下为R1的BGP表。R1#show ip bgpBGP table version is 6, local ro
26、uter ID is 1.1.1.1Status codes: s suppressed, d damped, h history, * valid, best, i - internal, r RIB-failure, S StaleOrigin codes: i - IGP, e - EGP, ? - incomplete Network Next Hop Metric LocPrf Weight Path* 1.1.1.0/24 0.0.0.0 0 32768 i* 2.2.2.0/24 10.1.1.4 0 345 2 i* 12.1.1.2 0 0 2 i* 13.1.1.3 0 3
27、45 2 i* 3.3.3.0/24 10.1.1.4 0 345 i* 12.1.1.2 0 2 345 i* 13.1.1.3 0 0 345 i* 4.4.4.0/24 10.1.1.4 0 0 345 i* 12.1.1.2 0 2 345 i* 13.1.1.3 0 345 i* 5.5.5.0/24 10.1.1.4 0 345 i* 12.1.1.2 0 2 345 i* 13.1.1.3 0 345 i分析:2.2.2.0/24:从拓扑图中可以看到R1分别从R2、R3和R4三个eBGP对等体学习到2.2.2.0网段,但最后只将从R2学习到的下一跳为12.1.1.2的路由条目作为
28、最优路径装进路由表。根据BGP的路径选择顺序:1、Weight(未设置)2、Local_Perf(未设置)3、Next_Hop(无)4、AS_Path由于从R3和R4学习到的路由条目跨越了AS 345,所以由R3和R4传来的路由条目为2跳,最终选择由R2传来下一跳为12.1.1.2的路由条目装进路由表。(注意:当BGP协议依据某条选路规则选出最优路径时,将不再考虑后面的规则。)3.3.3.0/24:R1分别从R2、R3和R4三个eBGP对等体学习到3.3.3.0网段,并将下一跳为13.1.1.3的路由条目装进路由表。根据BGP的路径选择顺序:1、Weight(未设置)2、Local_Perf(
29、未设置)3、Next_Hop(无)4、AS_Path由R2传来的路由条目为2跳,R3和R4相同,都为1跳,所以先排除R2传来的路由条目为最佳路由。5、Origin起源(无)6、MED值(未设置)7、eBGPiBGP(R3和R4同为R1的eBGP对等体)8、cost(用于iBGP)9、Maximum-paths(无)10、Age(用于eBGP,越大越优先)这里我们用show ip bgp summary查看R1与R3、R4的老化时间。可以看到R1与R3建立对等体的时间较长,所以选择由R3传来的下一跳为13.1.1.3的路由条目做为最佳路径装进路由表。R1#show ip bgp summary
30、BGP router identifier 1.1.1.1, local AS number 1BGP table version is 6, main routing table version 65 network entries using 505 bytes of memory13 path entries using 624 bytes of memory6 BGP path attribute entries using 360 bytes of memory4 BGP AS-PATH entries using 96 bytes of memory0 BGP route-map cache entries using 0 bytes of memory0 BGP filter-list cache entries using 0 bytes of memoryBGP using 1585 total b
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1