©2003,CiscoSystems,Inc.Allrightsreserved.©2003,CiscoSystems,Inc.Allrightsreserved.2付业茂CCIE(#9556)Tel:(0755)83651433Mail:Ncutsy.fu@tyl-digital.comRoutingProtocol高度总结©2003,CiscoSystems,Inc.Allrightsreserved.3©2003,CiscoSystems,Inc.Allrightsreserved.BSCI2.0—2-4•Routingprotocolsareusedbetweenrouterstodeterminepathsandmaintainroutingtables.路由器学习路径的方式•Oncethepathisdetermined,aroutercanroutearoutedprotocol.•数据包的运输工具RoutingProtocol&RoutedProtocol©2003,CiscoSystems,Inc.Allrightsreserved.BSCI2.0—2-5•在TCP/IP协议栈中,RoutedProtocol(IP)工作在网络层,而RoutingProtocol工作在传输层或者应用层,他们之间的关系为:RoutingProtocol负责学习最佳路径,而RoutedProtocol根据最佳路径将来自上层的信息封装在IP包里传输©2003,CiscoSystems,Inc.Allrightsreserved.BSCI2.0—2-6Protocols,Ports,andReliability©2003,CiscoSystems,Inc.Allrightsreserved.BSCI2.0—2-7StaticRoute•UsesaroutethatanetworkadministratorentersintotheroutermanuallyDynamicRoute•UsesaroutethatanetworkroutingprotocoladjustsautomaticallyfortopologyortrafficchangesIdentifyingStaticandDynamicRoutes©2003,CiscoSystems,Inc.Allrightsreserved.BSCI2.0—2-8•DefinesapathtoanIPdestinationnetworkorsubnetorhostRouter(config)#iproutenetwork[mask]{address|interface}[distance][permanent]StaticRouteConfiguration•仅仅在点到点(point-to-point)链路上才可以指定本地的转发端口;•Distance指的是AD,指定Next-Hop时缺省为1,指定本地转发端口时缺省为0。•通过修改缺省的Distance可以实现浮动的静态路由起备份的作用©2003,CiscoSystems,Inc.Allrightsreserved.BSCI2.0—2-9StaticRouteExample•Thisisaunidirectionalroute.Youmusthavearouteconfiguredintheoppositedirection.©2003,CiscoSystems,Inc.Allrightsreserved.BSCI2.0—2-10FloatingStaticRoutesFloatingStaticRoutes©2003,CiscoSystems,Inc.Allrightsreserved.BSCI2.0—2-11DefaultRoutes•ThisrouteallowsthestubnetworktoreachallknownnetworksbeyondrouterA.•在StubRouter(连接StubNetwork的路由器)上通常配置缺省路由,这也是大多数企业在接入INTERNET时所采用的配置。©2003,CiscoSystems,Inc.Allrightsreserved.BSCI2.0—2-12ClassfulandClassless•路由协议从不同的角度可以进行不同的分类。•根据协议在更新时是否携带掩码分为Classless和Classful两大类。©2003,CiscoSystems,Inc.Allrightsreserved.BSCI2.0—2-13Classful路由协议•Classful路由协议在路由更新时不携带掩码•Classful路由协议只能支持定长子网掩码(FLSM)同一个大类网络下的子网信息当掩码长度一致时可以相互穿越。掩码长度不一致时子网信息不能传递。•Classful路由协议不支持非连续的子网(Discontiguoussubnet)子网信息穿过另外一个大类网络时将在网络边界做自动汇总(10.2.0.0和10.3.0.0进入路由器C时被自动汇总为10.0.0.0,这样在C上会产生路由混乱)在TCP/IP协议中,RIPv1以及IGRP属于Classful路由协议。©2003,CiscoSystems,Inc.Allrightsreserved.BSCI2.0—2-14Classless路由协议•Classless路由协议在路由更新时携带掩码•Classless路由协议能支持变长子网掩码(VLSM)•Classless路由协议可以支持非连续的子网(Discontiguoussubnet)10.2.0.0/16192.168.1.32/30192.168.1.16/2810.3.0.0/1610.2.0.0/16192.168.1.16/28192.168.1.32/3010.3.0.0/1610.2.0.0/16192.168.1.16/28192.168.1.32/3010.3.0.0/1610.2.0.0/16192.168.1.32/30192.168.1.16/2810.3.0.0/16在TCP/IP协议中,RIPv2以及EIGRPOSPFBGP属于Classless路由协议。©2003,CiscoSystems,Inc.Allrightsreserved.BSCI2.0—2-15ClassfulLookup&Longest-MatchLookup•路由器收到数据包以后,会根据数据包中目的地址到路由表中查找相应的路由条目,如果找到相匹配的路由就会按照该路由处理数据包,否则在缺省情况下会扔弃数据包(策略路由PBR在没有普通路由的情况下也可以处理数据包)©2003,CiscoSystems,Inc.Allrightsreserved.BSCI2.0—2-16InterpretingtheIPRoutingTablewithaClassfulProtocolp1r3#showiprouteoutputomittedGatewayoflastresortis0.0.0.0tonetwork0.0.0.010.0.0.0/24issubnetted,3subnets,R10.1.1.0/24[120/1]via10.1.2.2,00:00:05,Ethernet0C10.1.2.0/24isdirectlyconnected,Ethernet0R10.1.3.0/24[120/2]via10.1.2.2,00:00:05,Ethernet0R192.168.24.0/24[120/2]via10.1.2.2,00:00:16,Ethernet0R172.16.0.0/16[120/3]via10.1.2.2,00:00:16,Ethernet0R*0.0.0.0/0[120/3]via10.1.2.2,00:00:05,Ethernet0Wherewilltheroutersendtrafficboundforthefollowingdestinations?•192.168.24.3•172.16.5.1•10.1.2.7•200.100.50.0•10.2.2.2缺省情况下,目的地为10.2.2.2的数据包将会被丢弃,因为它属于A类地址,路由器有两条10的路由,缺省情况下运行CLASSFUL协议的路由器会认为它学到了该网络的所有子网,所以会把它扔掉(IPCLASSLESS可以解决此问题)©2003,CiscoSystems,Inc.Allrightsreserved.BSCI2.0—2-17TheIPClasslessCommandRouter(config)#ipclassless•Replacesthedefaultbehaviorofclassfulroutingprotocolstomatchagainstonlyknownsubnetsofamajornetwork•Changesdefaultbehaviorofclassfulroutingprotocolforunknownsubnets•OnbydefaultinCiscoIOSversion12.0andlater•Hasnoeffectonmostclasslessroutingprotocolsbecausetheyusethelongest-matchcriteriabydefault•Longest-match:routersusinglongest-matchcriteriamakeroutingdecisionsbymatchingthemostnumberofbitspossibleinthedestinationnetwork©2003,CiscoSystems,Inc.Allrightsreserved.BSCI2.0—2-18•路由汇总的好处:1减少路由表条目的数量从而节省内存及CPU资源2可以使得路由变化的影响本地化(Localize)•Classful路由协议只支持自动汇总•Classless路由协议支持手动汇总•缺省情况下,RIPv2,EIGRP以及BGP做自动汇总(noauto-summary关闭自动汇总)。•做汇总的路由器将自动产生一条目的地为汇总地址指向NULL0的路由以避免路由环路及路由黑洞。路由汇总©2003,CiscoSystems,Inc.Allrightsreserved.BSCI2.0—2-19路由汇总©2003,CiscoSystems,Inc.Allrightsreserved.BSCI2.0—2-20NULL0路由避免路由环路internet路由器D宣告路由给Internet时做172.16.12.0/22的汇总,同时由于是Internet接入路由器所以通常会有缺省路由,这样Internet路由器会有一条172.16.12.0/22的路由,假如有HACKER发送一个目的地为172.16.19.0的数据包,Internet路由器会把包转发给路由器D,D收到以后会通过最长匹配原则根据缺省路由将包又发送给Internet路由器从而形成路由的环路及黑洞。如果在路由器D上有NULL0路由则可以避免此问题(该路由是自动产生的)。©2003,CiscoSystems,Inc.Allrightsreserved.BSCI2.0—2-21不同路由协议汇总的配置•RIPv2基于端口进行汇总,IPSUMMARY–ADDRESSRIPnetworkmask•EIGFRP基于端口进行汇总,IPSUMMARY-ADDRESSEIGRP[AS-NUMBER][ADDRESS][MASK]•OSPF的汇总只能在ABR以及ASBR上基于进程进行ABR进行区域间汇总:areaarea-idrangeaddressmaskASBR进行外部路由汇总:summary-addressaddressmask•BGP汇总基于进程:aggregate-addressip-addressmask[summary-