ISP_BGP 试验.docx_第1页
ISP_BGP 试验.docx_第2页
ISP_BGP 试验.docx_第3页
ISP_BGP 试验.docx_第4页
ISP_BGP 试验.docx_第5页
免费预览已结束,剩余49页可下载查看

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

ISP_BGP 试验ISP BGP 试验试验文档下载 /data/20824541-BGP选路规则发生选路的前提: 没有同步问题,下一条且可达!1-1 MEDMED生成:1:本地network方式生成的BGP条目,会带上IGP的metric。会传给所有邻居。2:如果从IBGP邻居学习到一条BGP条目的metric为0或者其他值,缺省不会传给给EBGP邻居,显示为空3:如果从EBGP邻居学习到的BGP条目的metric值传递给其他IBGP邻居,但不传给EBGP。4 : 汇总方式生成的BGP条目,metric值为空5 : 重分布方式生成的BGP条目,metric值为IGP的cost、metric、hop,汇总也会清除。6:缺省情况下,空的metric当0看待注意要点: A只有在通过两条路径得到第一个AS(对等体)是同一个AS时才进行MED比较;任何子自治域的联盟系统都会被忽略。也就是说,只有在AS序列号中第一个AS号码一致时,才进行MED比较;任何联盟AS序列号(AS_CONFED_SEQUENCE)都会被忽略。B如果路由器上配置了 bgp always-compare-med,在全部的路径进行MED比较。但是这需要全体AS都同时启用这个功能,否则有可能发生路由环路。C如果路由器上配置了bgp bestpath med confed,将对所有只包括AS_CONFED_SEQUENCE的路径进行MED比较(即路径是起源于本地联盟)。D如果接收到的路径没有分配MED值,则将此路径分配为0,除非路由器上配置了bgp bestpath med missing-as-worst,将被看作MED值为4,294,967,295的路由将在注入到BGP路由选择表之前被改为4,294,967,294。在通过前五条选路原则不能选出最优BGP条目的情况下,优选最低MED的BGP路由。MED值的用途:在两个AS之间有多个BGP连接的情况下,MED值用于影响从相邻AS到本AS的路由选择,即用于影响邻居AS到本AS的流量从哪个接口进来,这是通过向相邻AS的EBGP邻居发送具有不同MED值的路由条目来实现的,但是需要注意选路过程的实现是相邻AS的路由器自身根据13条选路原则独立完成,MED值的的比较是前面的五条选路原则都不能选出最优的情况下才起作用。只能在相邻的AS传递,一般在OUT方向做,影响入站的流量.默认情况下R2 应该优选EBGPR3 out方向做metricR1#sh ip bgpBGP table version is 9, local router ID is Status codes: s suppressed, d damped, h history, * valid, best, i - internal,r RIB-failure, S StaleOrigin codes: i - IGP, e - EGP, ? - incompleteNetwork Next Hop Metric LocPrf Weight Path*i/24 500 100 0 200 I 优选metric值小的* 1000 0 200 i 分别在R1R2在in方向让AS path增加这时,我们再来看下R2的BGP表:R2#sh ip bgpBGP table version is 3, local router ID is Status codes: s suppressed, d damped, h history, * valid, best, i - internal,r RIB-failure, S StaleOrigin codes: i - IGP, e - EGP, ? - incompleteNetwork Next Hop Metric LocPrf Weight Path* i/24 500 100 0 10 200 i* 1000 0 20 200 i从这边可以看出, 只要AS Path不一样,则metric 比较就失效了,优选了EBGP来的路由:R2(config-router)#bgp always-compare-med 强制开启metric比较,建议AS内的所有设备都开启R2#sh ip bgpBGP table version is 2, local router ID is Status codes: s suppressed, d damped, h history, * valid, best, i - internal,r RIB-failure, S StaleOrigin codes: i - IGP, e - EGP, ? - incompleteNetwork Next Hop Metric LocPrf Weight Path*i/24 500 100 0 10 200 I 又开始比较 metric* 1000 0 20 200 i我们在R2 上通告一条路由:R2(config)#router bgp 100R2(config-router)# net mask R3#sh ip bgpBGP table version is 3, local router ID is Status codes: s suppressed, d damped, h history, * valid, best, i - internal,r RIB-failure, S StaleOrigin codes: i - IGP, e - EGP, ? - incompleteNetwork Next Hop Metric LocPrf Weight Path* /24 0 32768 i* /24 0 100 i* 0 0 100 iR3(config-router)#bgp bestpath med missing-as-worst 默认收到没有分配metric的路由,让metric值改为4294967295R3#sh ip bgpBGP table version is 3, local router ID is Status codes: s suppressed, d damped, h history, * valid, best, i - internal,r RIB-failure, S StaleOrigin codes: i - IGP, e - EGP, ? - incompleteNetwork Next Hop Metric LocPrf Weight Path* /24 0 32768 i* /24 4294967295 0 100 i* 0 0 100 i1-2 优选从更近的BGP邻居学习到的路由R1#sh run | se bgprouter bgp 100no synchronizationbgp log-neighbor-changesneighbor remote-as 100neighbor update-source Loopback0neighbor next-hop-selfneighbor remote-as 200neighbor ebgp-multihop 255neighbor update-source Loopback0no auto-summaryR2#sh run | se bgprouter bgp 100no synchronizationbgp log-neighbor-changesnetwork mask neighbor remote-as 100neighbor update-source Loopback0neighbor next-hop-selfneighbor remote-as 200neighbor ebgp-multihop 255neighbor update-source Loopback0no auto-summaryR3#sh run | se bgprouter bgp 200no synchronizationbgp log-neighbor-changesneighbor test peer-groupneighbor test remote-as 100neighbor test ebgp-multihop 255neighbor test update-source Loopback0neighbor peer-group testneighbor peer-group testno auto-summaryR3#sh ip route ospf 查看到两邻居的距离/32 is subnetted, 1 subnetsO 110/2 via , 00:18:24, FastEthernet0//32 is subnetted, 1 subnetsO 110/2 via , 00:18:34, FastEthernet0/0R3#sh ip bgp BGP routing table entry for /24, version 3Paths: (2 available, best #2, table Default-IP-Routing-Table)Advertised to update-groups:2100 (metric 2) from ()Origin IGP, metric 0, localpref 100, valid, external100 (metric 2) from ()Origin IGP, localpref 100, valid, external, best 这里的规则是EBGP谁老谁优先选出来的我们现在把去往R1 的metric改大R1(config)#int lo 0R1(config-if)#ip ospf cost 110R3#sh ip bgp BGP routing table entry for /24, version 7Paths: (2 available, best #2, table Default-IP-Routing-Table)Flag: 0x820Advertised to update-groups:2100 (metric 111) from ()Origin IGP, localpref 100, valid, external100 (metric 2) from ()Origin IGP, metric 0, localpref 100, valid, external, best结论: 从此实验也可以得出一个结果。这条选路对EBGP邻居也是生效的,只是我们在用EBGP邻居关系之间很少跑动态路由协议罢了,没有动态路由协议,也就没有了度量值。 当然,对IBGP邻居肯定也是生效的1-3 优选 EBGP 最老路由一般情况下,先建立EBGP邻居,意味着先学习到BGP路由条目。但是,在一个路由器有多个EBGP邻居的情况下,对某一条路由而言, 并不一定先从先建立的EBGP邻居学习到。 在使能bgp bestpath compare-routerid命令后,跳过本条选路原则,拥有最小的router-ID的路由的将会被选为最优一般来说这条选路原则就可以选出最优了EBGP路由条目的走向.R3#sh ip bgpR3#sh ip bgpBGP table version is 2, local router ID is Status codes: s suppressed, d damped, h history, * valid, best, i - internal,r RIB-failure, S StaleOrigin codes: i - IGP, e - EGP, ? - incompleteNetwork Next Hop Metric LocPrf Weight Path* /24 0 100 i* 0 0 100 I 看summary的时间 优先从R2R3#sh ip bgp suR3#sh ip bgp summaryBGP router identifier , local AS number 200BGP table version is 2, main routing table version 21 network entries using 132 bytes of memory2 path entries using 104 bytes of memory3/1 BGP path/bestpath attribute entries using 504 bytes of memory1 BGP AS-PATH entries using 24 bytes of memory0 BGP route-map cache entries using 0 bytes of memory0 BGP filter-list cache entries using 0 bytes of memoryBitfield cache entries: current 1 (at peak 1) using 32 bytes of memoryBGP using 796 total bytes of memoryBGP activity 1/0 prefixes, 2/0 paths, scan interval 60 secsNeighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd 4 100 14 14 2 0 0 00:11:34 4 100 14 14 2 0 0 00:11:26 1R3(config-router)#nei remote 100 shutdownR3(config-router)#no nei remote 100 shutdownR3#sh ip bgpBGP table version is 3, local router ID is Status codes: s suppressed, d damped, h history, * valid, best, i - internal,r RIB-failure, S StaleOrigin codes: i - IGP, e - EGP, ? - incompleteNetwork Next Hop Metric LocPrf Weight Path* /24 0 0 100 i* 0 100 i1-4BGP选路综合训练基本配置请关注我的百度网盘:/s/1o65Q90uR1 上面宣告/24R5#sh ip bgpBGP table version is 2, local router ID is Status codes: s suppressed, d damped, h history, * valid, best, i - internal,r RIB-failure, S StaleOrigin codes: i - IGP, e - EGP, ? - incompleteNetwork Next Hop Metric LocPrf Weight Path* i/32 0 100 0 100 i*i 0 100 0 100 iR5#sh ip bgp BGP routing table entry for /32, version 2Paths: (2 available, best #2, table Default-IP-Routing-Table)Flag: 0x820Not advertised to any peer100 (metric 3) from ()Origin IGP, metric 0, localpref 100, valid, internalOriginator: , Cluster list: 100 (metric 3) from ()Origin IGP, metric 0, localpref 100, valid, internal, bestOriginator: , Cluster list: 分析过程:1)weight值均为0;2)localpref均为100;3)不是本地生成的路由;4)AS-PATH一样长;5)起源代码都是i;6)MED值都是0;7)第7条选路原则不符合,跳过;8)建立BGP邻居的IGP开销都是一样的。9)第9条选路原则不符合,跳过;10)第10条选路原则不符合,跳过;11)有RR的环境下,此时比较的originator-ID,均为 ; 12)cluster list长度都是1;13)选择建立邻居用的最小IP地址为优,一个,一个 (优选小的)如果我们把R3的环回口地址改大,3,重新建立起IBGP关系R3#sh ip int bInterface IP-Address OK? Method Status ProtocolFastEthernet0/0 YES manual up upFastEthernet0/1 YES manual up upLoopback0 3 YES manual up upR5#sh ip bgpBGP table version is 12, local router ID is Status codes: s suppressed, d damped, h history, * valid, best, i - internal,r RIB-failure, S StaleOrigin codes: i - IGP, e - EGP, ? - incompleteNetwork Next Hop Metric LocPrf Weight Path* i/32 0 100 0 100 i*i 0 100 0 100 iR5#sh ip bgp BGP routing table entry for /32, version 12Paths: (2 available, best #1, table Default-IP-Routing-Table)Flag: 0x800Not advertised to any peer100(下一条跳地址) (metric 3度量值) from (BGP router-id) ( RR ID)Origin IGP, metric 0, localpref 100, valid, internal, bestOriginator: , Cluster list: 100 (metric 3) from 3 ()Origin IGP, metric 0, localpref 100, valid, internalOriginator: , Cluster list: 2-BGP高级部分2-1路由发射器RR 的反射规则如下: (1)如果路由是从非客户的IBGP 邻居学来的,则RR 只将它反射给客户; (2)如果路由是从客户学来的,RR 会将它反射给所有的非客户和客户(除了发起该路 由的客户); (3)如果路由是从EBGP 邻居学来的,RR 会将它反射给所有的非客户和客户。按试验要求建立好IBGP/EBGP邻居关系如果在R1宣告,这条路由,只能能传到R3R3#sh ip bgp neighbors BGP neighbor is , remote AS 200, internal linkBGP version 4, remote router ID BGP state = Established, up for 00:02:06Last read 00:00:13, last write 00:00:14, hold time is 180, keepalive interval is 60 seconds.Route-Reflector Client 证明R3是R2的RRR3#sh ip bgp BGP routing table entry for /32, version 4Paths: (1 available, best #1, table default)Advertised to update-groups:2100, (Received from a RR-client) 重客户端收到的路由条目 (metric 1) from ()Origin IGP, metric 0, localpref 100, valid, internal, best如果配置R3为RR,R2,R4为他的client,此路由将会传递到R4,也不会传到R5,如要配置R5也为R3的client,就需要新增加一条BGP的连接。如果在一个大型的网络当中,有可能一个RR的负担就太重了,这时就可以用到层次化的RR。 如R4是R3的client,但同时也是一个RR,R5为R4的client。R3(config-router)#nei route-reflector-clientR3(config-router)#nei route-reflector-clientR4(config-router)#nei route-reflector-clientR4(config-router)#nei route-reflector-clientR5#sh ip bgp BGP routing table entry for /32, version 2Paths: (1 available, best #1, table default)Not advertised to any peer100 (下一条跳) (metric 3度量值) from (bgp router-id) ( RR ID)Origin IGP, metric 0, localpref 100, valid, internal, bestOriginator: , Cluster list: , 2-2BGP联邦理论简介:IBGP邻居并不把路由信息从一个IBGP邻居传播给另一个IBGP邻居。如果全互联,这将产生一个规模问题与费用问题。BGP联邦克服了IBGP引起的规模问题。把AS划分为多个子自治系统。但在联邦内部,仍然需要IBGP的full-mesh,或者在联邦内部使用RR。联邦之间的BGP连接就像一个EBGP对等体,但是它们交换路由信息的时候,就如在使用IBGP,同时保留了下一跳、度量、本地优先级等属性具体配置信息我就不show了,可以到百度盘中去下载,直接看效果我们在R1 上宣告, R2修改默认的LP值R1#sh run | se bgprouter bgp 100no synchronizationbgp router-id bgp log-neighbor-changesnetwork mask 55neighbor remote-as 200no auto-summaryR2(config)#router bgp 65001R2(config-router)#bgp default local-preference 200下一跳 (由于本试验中都敲了next-hop-self 所以下一跳会有所改变)、度量、本地优先级等属性,不会像一个真正的EBGP邻居关系一样被改变,所以用以上命令改一下local-preference值R3#sh ip bgp BGP routing table entry for /32, version 3Paths: (1 available, best #1, table default)Advertised to update-groups:2(65001) 100 (metric 30720) from ()Origin IGP, metric 0, localpref 200, valid, confed-external, bestR5#sh ip bgp BGP routing table entry for /32, version 3Paths: (1 available, best #1, table default)Advertised to update-groups:2(65002 65001) 100 (metric 158720) from ()Origin IGP, metric 0, localpref 200, valid, confed-external, bestR5#sh ip bgpBGP table version is 3, local router ID is Status codes: s suppressed, d damped, h history, * valid, best, i - internal,r RIB-failure, S StaleOrigin codes: i - IGP, e - EGP, ? - incompleteNetwork Next Hop Metric LocPrf Weight Path* /32 0 200 0 (65002 65001) 100 i从以上输出可以发现,一些属性值被保存了下来,也就是说,联邦之间并不是一个真正的EBGP邻居关系,对属性值的处理是和IBGP邻居关系是一样的。然后将成员AS 加入到AS-PATH 中,并且用括号扩起来,但是并不将它们公布到联邦的范围以外。AS-PATH 中联邦的AS 号用于避免出现路由环路。而一个联邦小AS内部的防环,依然是用IBGP的防环机制。R6#sh ip bgpBGP table version is 2, local router ID is Status codes: s suppressed, d damped, h history, * valid, best, i - internal,r RIB-failure, S StaleOrigin codes: i - IGP, e - EGP, ? - incompleteNetwork Next Hop Metric LocPrf Weight Path* /32 0 200 100 i/以上的as-path输出表明此条路由经历了二个AS,100和200.也就是说,联邦内部的子AS号,在传给一个真正的EBGP邻居的时候,是会被自动去掉的。联邦内的子AS号相对于外面的EBGP邻居是透明的。2-3BGP团体属性Community1.Community 主要用来控制路由的传播范围2.社团属性,也叫共同体属性,是可选传递属性 ,“可选”:意味着并不是所有的路由器都能识别这个社团属性。3.社团属性类似于tag标记,它允许路由器能够使用一个指示符来标记路由,并且允许其它路由器根据这个标记做出相应的决定,可以简化策略的执行。它是cisco的一个专有属性,现在在RFC1997中已被标准化。4.一条路由可以设置多个社团属性,也就是说允许同时打上多个标记,还可以利用社团属性实现一些扩展的功能。比如在MPLS-VPN中的RT属性。5.情况下社团属性不会传递给邻居,必须有以下命令才行 neighbor send-community 社团属性只会传给指定的邻居,并只在此邻居上起效。 比如上例:就只传给这一邻居,并只在它上面起效,默认不会再向后传6.Community值可以自己定义,另外有几个已经定义好的团体属性:NO_ADVERTISE: 携带该值的路由不能公布给EBGP和 IBGP邻居NO_EXPORT: 携带该值的路由不能公布给任何真正的EBGP对等体 (联邦内AS的EBGP可以传递)LOCAL_AS:携带该值的路由不能公告给任何EBGP对等体 (本小AS内部(联邦)传递)Internet: 可以传递所有IBGP/EBGP邻居延续用上面的试验R1(config)#route-map com permitR1(config-route-map)#mat ip add p 1R1(config-route-map)#set community local-ASR1(config-route-map)#exitR1(config)#router bgp 100R1(config-router)#neighbor route-map com outR1(config-router)#nei send-community这条命令千万别忘了,重要R1#clear ip bgp * soft outR2#sh ip bgp BGP routing table entry for /32, version 4Paths: (1 available, best #1, table default, not advertised outside local AS)Advertised to update-groups:3100 from ()Origin IGP, metric 0, localpref 200, valid, external, bestCommunity: local-AS以上输出表明携带团体“local-AS”属性的条目“/32”只传递给路由器R7,因为路由器R7 和R2 都在AS 65001 内,并没有传递给路由器R3,由此可见“local-AS”团体属性只能在本小AS 内传递。R1(config)#route-map com permit 10R1(config-route-map)#set community ? community numberaa:nn community number in aa:nn formatadditive Add to the existing communityinternet Internet (well-known community)local-AS Do not send outside local AS (well-known community)no-advertise Do not advertise to any peer (well-known community)no-export Do not export to next AS (well-known community)none No community attributeR1(config-route-map)#set community no-advertiseR2#sh ip bgp BGP routing table entry for /32, version 6Paths: (1 available, best #1, table default, not advertised to any peer)Not advertised to any peer100 from ()Origin IGP, metric 0, localpref 200, valid, external, bestCommunity: no-advertise但R3与R7 并没有收到/24的路由由此可见携带“no-advertise”团体属性的条目被收到后,将不通告给任何BGP 对等体。R1(config-route-map)#set community no-exportR1(config-route-map)#endR1#clear ip bgp * soft out同时我们在R2/R3/R4上作邻居 send community 让属性值传递到R5 上最后可以发现R2/3/4/5/7都可以学习到的路由,其R6却学习不到R4#sh ip bgp BGP routing table entry for /32, version 8Paths: (1 available, best #1, table default, not advertised to EBGP peer)Advertised to update-groups:3(65001) 100 (metric 33280) from ()Origin IGP, metric 0, localpref 200, valid, confed-internal, bestCommunity: no-exportR5#sh ip bgpBGP table version is 8, local router ID is Status codes: s suppressed, d damped, h history, * valid, best, i - internal,r RIB-failure, S StaleOrigin codes: i - IGP, e - EGP, ? - incompleteNetwork Next Hop Metric LocPrf Weight Path* /32 0 200 0 (65002 65001) 100 iR5#sh ip bgp BGP routing table entry for /32, version 8Paths: (1 available, best #1, table default, not advertised to EBGP peer)Not advertised to any peer(65002 65001) 100 (metric 35840) from ()Origin IGP, metric 0, localpref 200, valid, confed-external, bestCommunity: no-export由此可见“no-export”团体属性能在联邦的大AS 内传递,如果没有联邦,只能在本AS 内传递。R5的配置如下:R5#sh run | se bgprouter bgp 65003no synchronizationbgp router-id bgp log-neighbor-changesbgp confederation identifier 200bgp confederation peers 65002neighbor remote-as 65002neighbor remote-as 300no auto-summary2-4过滤私有AS号R3#sh ip bgpBGP table version is 2, local router ID is Status codes: s suppressed, d damped, h history, * valid, best, i - internal,r RIB-failure, S StaleOrigin codes: i - IGP, e - EGP, ? - incompleteNetwork Next Hop Metric LocPrf Weight Path* /32 0 100 65001 I 如何隐藏掉私有As号R1(config-router)#nei remove-private-asR1(config-router)#do clear ip bgp * soft outR3#sh ip bgpBGP table version is 3, local router ID is Status codes: s suppressed, d damped, h history, * valid, best, i - internal,r RIB-failure, S StaleOrigin codes: i - IGP, e - EGP, ? - incompleteNetwork Next Hop Metric LocPrf Weight Path* /32 0 100 I 2-5BGP后门路由按照试验图配置起来,记得在R3上配个到的默认路由需求:R2去往R1的环回口首选高速以太链路。从R3的EBGP学到的低速链路作备份其实后门路由就是抑制EBGP AD(20)R2#sh ip routeGateway of last resort is not set/32 is subnetted, 1 subnetsB 20/0 via , 00:01:54 优选EBGP为20的路由/32 is subnetted, 1 subnetsC is directly connected, Loopback0/24 is subnetted, 1 subnetsC is direc

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论