ip-default-network、ip-route、ip-default-gateway的区别_第1页
ip-default-network、ip-route、ip-default-gateway的区别_第2页
ip-default-network、ip-route、ip-default-gateway的区别_第3页
ip-default-network、ip-route、ip-default-gateway的区别_第4页
ip-default-network、ip-route、ip-default-gateway的区别_第5页
已阅读5页,还剩7页未读 继续免费阅读

付费下载

下载本文档

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

文档简介

1、ip default-network、ip route、ip default-gateway的区别在cisco的16448文档中详细地讲解了这三条命令的使用条件和区别。一、使用条件ip default-gateway在禁用了ip routing的情况下使用,该路由器被当做默认网关。ip default-network和ip route 则可以在启用路由选择协议下使用。二、区别ip default-network 与 ip route 的最大区别在于前者可以被路由选择协议宣告出去。但是由于ip default-network这条命令

2、是有类的,如果宣告的网络不是主类网,将不会被标记成*号。ip default-network产生的默认路由是可以被EIGRP和RIP宣告的,但不被OSPF宣告,至于OSPF怎么产生默认路由,上一边有介绍。值得注意的是,RIP宣告ip default-network的路由条目是,使用,可以debug ip rip看到。ip route 也可以被EIRGP传播,但是这条静态路由必须重分发到EIGRP协议中;在12.0T以后的IOS版本中,RIP将不宣告默认路由,除非是通过RIP学习到得,或者重分发到RIP中。同样,在OSPF中也不能传播该命令产生的默认

3、路由,(default-information originate命令)三、负载均衡  如果用ip default-network配置了去往同一目的的多条默认路由,路由表会选择管理距离最小,如果管理距离都一样则选择最先配置的那条。  同时使用ip default-network和ip route 双方设定默认路由时,如果ip default-network设定的网络是直连(静态、且已知)的,那么它就成为默认路由;如果ip default-network指定的网络是由交换路由信息得来的,则ip route 0.

4、0.0.0指定的表项成为默认路由。  最后,如果使用多条ip route 指令,则流量会自动在多条链路上负载均衡。推荐精选ip default-gateway,ip default-network和ip route 默认路由的区别关于这几条命令的区别,网上已经有很多讨论了,也的确是很容易混淆的。下面是整理的一些总结,都一一举例做了比较,应该会有一个全新的认识,以后实际中遇到了也不混淆犯错了。 指定默认路由(last resort gateway)的指令供有3种,可以分成两类:1、ip default-gateway当路由器上的ip routin

5、g无效时,使用它指定默认路由,用于RXBoot模式(no ip routing)下安装IOS等。或者关闭ip routing 让路由器当主机用,此时需要启用ip default-gateway配置默认网关。2、ip default-network和ip route 两者都用于ip routing有效的路由器上,区别主要在于路由协议是否传播这条路由信息。比如:IGRP无法识别,因此传播默认路由时必须用ip default-network。当用ip default-network指令设定多条默认路由时,administrative distance最短的

6、成为最终的默认路由;如果有复数条路由distance值相等,那么在路由表(show ip route)中靠上的成为默认路由。同时使用ip default-network和ip route 双方设定默认路由时,如果ip default-network设定的网络是直连(静态、且已知)的,那么它就成为默认路由;如果ip default-network指定的网络是由交换路由信息得来的,则ip route 指定的表项成为默认路由。最后,如果使用多条ip route 指令,则流量会自动在多条链路上负载均衡。 例子:关

7、闭ip routing 举例:mycisco(config)#no ip routingmycisco(config)#ip default-gateway mycisco(config)#endmycisco#ping Type escape sequence to abort.Sending 5, 100-byte ICMP Echoes to 5, timeout is 2 seconds:!Success rate is 100 percent (5/5), round-trip min/avg/max = 60/60/60 msmycis

8、co#show ip routeDefault gateway is 推荐精选Host Gateway Last Use Total Uses InterfaceICMP redirect cache is emptymycisco#ip route例子:ip route mycisco#ping Type escape sequence to abort.Sending 5, 100-byte ICMP Echoes to 5, timeout is 2 seconds:!Success ra

9、te is 100 percent (5/5), round-trip min/avg/max = 56/56/60 msmycisco#show ip routeCodes: C connected, S static, I IGRP, R RIP, M mobile, B BGPD EIGRP, EX EIGRP external, O OSPF, IA OSPF inter areaE1 OSPF external type 1, E2 OSPF external type 2, E EGPi IS-IS, L1 IS-IS level-1, L2 IS-IS level-2, * ca

10、ndidate defaultU per-user static routeGateway of last resort is to network C /8 is directly connected, Loopback0C /24 is directly connected, Ethernet0S* /0 1/0 via mycisco#ip default-network 必须是在所到网络已经存在路由的情况下,否则执行无效.mycisco(config)#ip route 61.

11、0.0.0 mycisco#show ip routeCodes: C connected, S static, I IGRP, R RIP, M mobile, B BGPD EIGRP, EX EIGRP external, O OSPF, IA OSPF inter areaE1 OSPF external type 1, E2 OSPF external type 2, E EGPi IS-IS, L1 IS-IS level-1, L2 IS-IS level-2, * candidate defaultU per-user static r

12、outeGateway of last resort is not setC /8 is directly connected, Loopback0S /8 1/0 via C /24 is directly connected, Ethernet0 接着我们执行:mycisco(config)#ip default-network 再看路由表:mycisco#show ip routeCodes: C connected, S static, I IGRP, R RIP, M mobile, B 推荐精

13、选 BGPD EIGRP, EX EIGRP external, O OSPF, IA OSPF inter areaE1 OSPF external type 1, E2 OSPF external type 2, E EGPi IS-IS, L1 IS-IS level-1, L2 IS-IS level-2, * candidate defaultU per-user static routeGateway of last resort is to network C /8 is directly connected, Loopbac

14、k0S* /8 1/0 via C /24 is directly connected, Ethernet0推荐精选ip default-gatewayip default-gateway command differs from the other two commands in that it should only be used when ip routing is disabled on the Cisco router.For instance, if the router is a host in the IP worl

15、d, you can use this command to define a default gateway for it. You might also use this command when your low end Cisco router is in boot mode in order to TFTP a Cisco IOS® Software image to the router. In boot mode, the router does not have ip routing enabled.ip default-networkUnlike the ip

16、 default-gateway command, you can use ip default-network when ip routing is enabled on the Cisco router. When you configure ip default-network the router considers routes to that network for installation as the gateway of last resort on the router.For every network configured with ip default-network

17、, if a router has a route to that network, that route is flagged as a candidate default route. Look at the following routing table taken from a Cisco router:2513#show ip routeCodes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP       D - EIGRP, EX - EIGRP exte

18、rnal, O - OSPF, IA - OSPF inter area       E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP       i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, * - candidate defaultGateway of last resort is not set      255.255.

19、255.0 is subnetted, 1 subnetsC       is directly connected, Ethernet0S    1/0 via       is subnetted, 1 subnetsC       is directly connected, TokenRing0Note

20、 the static route to via and that the gateway of last resort is not set. If you configure ip default-network , the routing table changes to the following:2513#show ip routeCodes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP     &#

21、160; D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area       E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP       i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, * - candidate defaultGateway of last resort is to netw

22、ork       is subnetted, 1 subnetsC       is directly connected, Ethernet0S       1/0 via S*    1/0 via 推荐精选   

23、0;  is subnetted, 1 subnetsC       is directly connected, TokenRing02513#show ip protocols2513#You can see the gateway of last resort has now been set as . This result is independent of any routing protocol, as shown by the s

24、how ip protocols command at the bottom of the output.You can add another candidate default route simply by configuring another instance of ip default-network:2513#config terminalEnter configuration commands, one per line.  End with CNTL/Z.2513(config)#ip route 131

25、.108.99.22513(config)#ip default-network 2513(config)#Z2513#show ip routeCodes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area       E1 - OSPF external type 1, E

26、2 - OSPF external type 2, E - EGP       i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, * - candidate defaultGateway of last resort is to network       is subnetted, 1 subnetsC    is dire

27、ctly connected, Ethernet0S    1/0 via S*    1/0 via       is variably subnetted, 2 subnets, 2 masksS    1/0 via S    255.255.2

28、55.0 1/0 via       is subnetted, 1 subnetsC    is directly connected, TokenRing0Notice that after entering the above command, the network was not flagged as a default network. The following section explains why.Flagging

29、a Default NetworkNote: The ip default-network command is classful, which means if the router has a route to the subnet indicated by this command, it installs the route to the major net. At this point neither network has been flagged as the default network. The ip default-network command must be issu

30、ed again, using the major net, in order to flag the candidate default route.2513#config terminal推荐精选Enter configuration commands, one per line. End with CNTL/Z. 2513(config)#ip default-network 2513(config)#Z2513#show ip routeCodes: C - connected, S - static, I - IGRP, R - RIP, M - mobile,

31、B - BGP       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area       E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP       i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, * - candidate defaultGateway of last r

32、esort is to network          is subnetted, 1 subnetsC       is directly connected, Ethernet0S       1/0 via S*     

33、0; 1/0 via          is variably subnetted, 2 subnets, 2 masksS*       1/0 via S       1/0 via        &

34、#160; is subnetted, 1 subnetsC       is directly connected, TokenRing0If the original static route had been to the major network, the extra step of configuring the default network twice would not have been necessary.There are still no IP prot

35、ocols running here. Without any dynamic protocols running, you can configure your router to choose from a number of candidate default routes based on whether the routing table has routes to networks other than /0. This command allows you to configure robustness into the selection of a gateway

36、 of last resort. Rather than configuring static routes to specific next-hops, you can have the router choose a default route to a particular network by checking in the routing table.If you lose the route to a particular network, the router selects the second candidate default, as specified above. Yo

37、u can remove the lost route by removing the static route in the configuration as follows:2513#config terminalEnter configuration commands, one per line.  End with CNTL/Z.2513(config)#no ip route 2513(config)#Z2513#%SYS-5-CONFIG_I: Configured from consol

38、e by consoleAfter removing the static route to the original default network, the routing table looks like this:2513#show ip route推荐精选Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area 

39、      E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP       i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, * - candidate defaultGateway of last resort is to network       is subnett

40、ed, 1 subnetsC       is directly connected, Ethernet0S       1/0 via *    is variably subnetted, 2 subnets, 2 masksS*       1/0 via S 

41、;      1/0 via       is subnetted, 1 subnetsC       is directly connected, TokenRing02513#Using Different Routing ProtocolsGateways of last resort selected using the ip

42、default-network command are propagated differently depending on which routing protocol is propagating the default route. For IGRP and EIGRP to propagate the route, the network specified by the ip default-network command must be known to IGRP or EIGRP. This means the network must be an IGRP- or EIGRP

43、-derived network in the routing table, or the static route used to generate the route to the network must be redistributed into IGRP or EIGRP.RIP advertises a route to . For example, note that the gateway of last resort on the router below was learned using the combination of the ip route and

44、 ip default-network commands. If you enable RIP on this router, RIP advertises a route to (although not to the Token Ring network because of split-horizon):2513(config)#router rip2513(config-router)#network 2513(config-router)#network 2513(config-router)#Z2513#2513#2513#

45、%SYS-5-CONFIG_I: Configured from console by console2513#debug ip ripRIP protocol debugging is on2513#RIP: sending update to 55 via Ethernet0 ()     default , metric 1     network , metric 1RIP: sending update to 255.2

46、55.255.255 via TokenRing0 ()推荐精选network , metric 12513#Note: In IOS release 12.0T and later, RIP does not advertise the default router if the route is not learned via RIP. Therefore, it may be necessary to redistribute the route into RIP, or use the default-information originat

47、e command.OSPF, like RIP, advertises a route for . However, with OSPF, the router originating the default route must be configured with the default-information originate command. For more detailed information, see How Does OSPF Generate Default Routes?.ip route Creating

48、 a static route to network is another way to set the gateway of last resort on a router. As with the ip default-network command, using the static route to is not dependent on any routing protocols. However, ip routing must be enabled on the router.Note: IGRP does not understa

49、nd a route to , therefore it cannot propagate default routes created using the ip route command. Use the ip default-network command to have IGRP propagate a default route.EIGRP propagates a route to network , but the static route must be redistributed into EIGRP. RIP an

50、d OSPF behave as described when using the ip default-network command. Keep in mind that the note above still applies.Look at an example of configuring a gateway of last resort using the ip route command:router-3#conf terminal   Enter configuration commands, one per line. En

51、d with CNTL/Z.   router-3(config)#ip route    router-3(config)#Z   router-3#      router-3#show ip route   Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP   D - EIGRP, EX - EIGRP

52、 external, O - OSPF, IA - OSPF inter area    N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2   E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP   i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, * - candidate default   U - per-user static route, o - ODRGateway of last resort is to network /24 is s

温馨提示

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

评论

0/150

提交评论