技术在于专研
分类: 系统运维
2006-12-07 15:32:03
500度: 的关于默认路由的文档
one:CISCO 文档 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 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 Gateway of last resort is 161.44.192.2 to network 198.10.1.0 161.44.0.0 255.255.255.0 is subnetted, 1 subnets C 161.44.192.0 is directly connected, Ethernet0 S 161.44.0.0 255.255.0.0 [1/0] via 161.44.192.0 S* 198.10.1.0 [1/0] via 161.44.192.2 131.108.0.0 255.255.255.0 is subnetted, 1 subnets C 131.108.99.0 is directly connected, TokenRing0 2513#show ip protocols 2513# 您能发现最后一招网关现在设置作为161.44.192.2。此结果 是对立于所有路由协议,如由show ip protocols命令 显示在输出的底部。 您能通过配置 ip default-network 另一个实例简单添加另一个候 选默认路由 : 2513#config terminal Enter configuration commands, one per line. End with CNTL/Z. 2513(config)#ip route 171.70.24.0 255.255.255.0 131.108.99.2 2513(config)#ip default-network 171.70.24.0 2513(config)#^Z 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 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 Gateway of last resort is 161.44.192.2 to network 198.10.1.0 161.44.0.0 255.255.255.0 is subnetted, 1 subnets C 161.44.192.0 is directly connected, Ethernet0 S 161.44.0.0 255.255.0.0 [1/0] via 161.44.192.0 S* 198.10.1.0 [1/0] via 161.44.192.2 171.70.0.0 is variably subnetted, 2 subnets, 2 masks S 171.70.0.0 255.255.0.0 [1/0] via 171.70.24.0 S 171.70.24.0 255.255.255.0 [1/0] via 131.108.99.2 131.108.0.0 255.255.255.0 is subnetted, 1 subnets C 131.108.99.0 is directly connected, TokenRing0 注意在输入上述命令以后,网络未被 标记作为默认网络。以下部分为什么说明。 标记默认网络 注意: ip default-network命令有类别,意味着如果路由器有一个路由到此命 令表示的子网,它安装路由对主网。这时两个网络未被标记 作为默认网络。必须 使用 主网再发出ip default-network命令,为了标记候选默认路由。 2513#config terminal Enter configuration commands, one per line. End with CNTL/Z. 2513(config)#ip default-network 171.70.0.0 2513(config)#^Z 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 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 Gateway of last resort is 161.44.192.2 to network 198.10.1.0 161.44.0.0 255.255.255.0 is subnetted, 1 subnets C 161.44.192.0 is directly connected, Ethernet0 S 161.44.0.0 255.255.0.0 [1/0] via 161.44.192.0 S* 198.10.1.0 [1/0] via 161.44.192.2 171.70.0.0 is variably subnetted, 2 subnets, 2 masks S* 171.70.0.0 255.255.0.0 [1/0] via 171.70.24.0 S 171.70.24.0 255.255.255.0 [1/0] via 131.108.99.2 131.108.0.0 255.255.255.0 is subnetted, 1 subnets C 131.108.99.0 is directly connected, TokenRing0 如果原始静态路由是对主要网络,额 外步骤配置默认网络没两次将是必要的。 仍然没有IP协议这里运行。没有任何动态协议 运作,您能配置您的路由器从基于的一定数量的候选默认路由选择 路由表是否有路由对网络除0.0.0.0/0之外。此命令允许您配 置抗错性到最后一招网关的选择。 而不是配置静态路由到特 定下个跳跃,您能安排路由器选择默认路由对一个特定网络通过检 查在路由表里。 如果丢失路由对一个 特定网络,路由器选择第二个候选默认值,如上所述。 您在 配置能通过去除静态路由去除路由丢失如下: 2513#config terminal Enter configuration commands, one per line. End with CNTL/Z. 2513(config)#no ip route 198.10.1.0 255.255.255.0 161.44.192.2 2513(config)#^Z 2513# %SYS-5-CONFIG_I: Configured from console by console 在去除静态路由以后对原始默认网络,路由表如下所 示: 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 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 Gateway of last resort is 171.70.24.0 to network 171.70.0.0 161.44.0.0 255.255.255.0 is subnetted, 1 subnets C 161.44.192.0 is directly connected, Ethernet0 S 161.44.0.0 255.255.0.0 [1/0] via 161.44.192.0 * 171.70.0.0 is variably subnetted, 2 subnets, 2 masks S* 171.70.0.0 255.255.0.0 [1/0] via 171.70.24.0 S 171.70.24.0 255.255.255.0 [1/0] via 131.108.99.2 131.108.0.0 255.255.255.0 is subnetted, 1 subnets C 131.108.99.0 is directly connected, TokenRing0 2513# 使用不 同的路由协议 使用ip default-network命令选择的最后一招 网关根据哪个路由协议不同地 被传播传播默认路由。为了能传播路由的IGRP及EIGRP, ip default-network命令指定的 网络必须为IGRP或EIGRP 所 知。这意味着网络在路由表里必须是一个IGRP-或EIGRP派生 的网络,或者必须再分布用于的静态路由生成路由对网络到IGRP或 EIGRP 。 RIP做通告路由到0.0.0.0 。例如,注意最后一招网关在如下路由器使用IP 路 由和ip default-network 命令的 组合 是 获 知 。如果在此路由器启用RIP,RIP做 通告路由到0.0.0.0 (虽然不对令牌环网络由于纵向隔离): 2513(config)#router rip 2513(config-router)#network 161.44.0.0 2513(config-router)#network 131.108.0.0 2513(config-router)#^Z 2513# 2513# 2513# %SYS-5-CONFIG_I: Configured from console by console 2513#debug ip rip RIP protocol debugging is on 2513# RIP: sending update to 255.255.255.255 via Ethernet0 (161.44.192.1) default 0.0.0.0, metric 1 network 131.108.0.0, metric 1 RIP: sending update to 255.255.255.255 via TokenRing0 (131.108.99.1) network 161.44.0.0, metric 1 2513# 注意: 在IOS 版本如果路由通过RIP,不是获知12.0T和以后,RIP不做通告默认路 由器。所以,再分布路由到RIP可能是必要的,或者使用 default-information originate命令。 OSPF,类似RIP,为 0.0.0.0 0.0.0.0做通告路由。然而,与OSPF,必须用 default-information originate命令配置产生默认路由的 路由器。关于详细信息 ,请参阅 如何执行OSPF生成默认路由?. ip route 0.0.0.0 0.0.0.0 < $$+0> 创建静态路由到网络0.0.0.0 0.0.0.0是另一 个方式设置最后一招网关在路由器。照同 ip default-network命令,使 用静态路由到0.0.0.0不依靠任何路由协议。 然而, 在 路由器必须启用 IP路由。 注意: IGRP不了解路由到0.0.0.0因此不能传播使用 ip route 0.0.0.0 0.0.0.0命令被创建的 默认路由。 使用 ip default-network命令有 IGRP繁殖默认路由。 EIGRP传播一个 路由对网络0.0.0.0,但必须再分布静态路由到EIGRP。RIP和 OSPF 正常运行如所描述当使用 ip default-network命令时。记住上面附注仍 然适用。 查看配置最后一招网关示 例使用 ip route 0.0.0.0 0.0.0.0命令: router-3#conf terminal Enter configuration commands, one per line. End with CNTL/Z. router-3(config)#ip route 0.0.0.0 0.0.0.0 170.170.3.4 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 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 - ODR Gateway of last resort is 170.170.3.4 to network 0.0.0.0 170.170.0.0/24 is subnetted, 2 subnets C 170.170.2.0 is directly connected, Serial0 C 170.170.3.0 is directly connected, Ethernet0 S* 0.0.0.0/0 [1/0] via 170.170.3.4 router-3# router-3# 注意: 如果 配置多个网络作为候选默认路由使用 ip default-network命令, 有最低管理距离的网络被选择作为网络为最后一招网关。如 果所有网络有同一管理距离然后网络列表首先在路由表里 (show ip route 列出 路由表)被选择作为网络为最后一招网关。如果使用 ip default-network 和 ip route 0.0.0.0 0.0.0.0 命令配置候选默认值网络, 并且ip default-network命令使用的 网络静态知道,用ip default-network 命 令被定义的 网络采取优先次序 和为最后一招网关被选择。否则如果ip default-network命 令使用的 网络由路由协议派 生, ip route 0.0.0.0 0.0.0.0命令,将有一个更低的管 理距离,采取优先次序和为最后一招网关被选择。最后,如 果使用多个 ip route 0.0.0.0 0.0.0.0 命 令配置默认路由,数据流在多个路由负载平衡。
汇总 当IP路由 在Cisco路由器时, 禁 用 总结 ,您能使用 ip default-gateway命令。使用 ip default-network 和 ip route 0.0.0.0 0.0.0.0 命令设置最后一招网关在有 被启用的IP路由 的 Cisco路由器。路由协议传播默认路由信息的方 式为每个协议变化。
THREE:下面的解释好象就是上面第一个CISCO文档的原版!呵呵
题目: 一台Cisco3550交换机的原有配置的基础上 我加了个配置:ip default-gateway 10.182.255.1(原先没有的) 然后在全局模式下:ping 10.182.15.14 看到无法ping通的提示。 然后进到配置模式:no ip default-gateway 10.182.255.1 接着执行 ip default-network 10.182.255.1 然后在全局模式下:ping 10.182.15.14 看到能ping通的提示。 在此请教:ip default-gateway 10.182.255.1 和i p default-network 10.182.255.1 这两条指令有何区别? 解答: Introduction This Tech Note explains how to configure a default route, or gateway of last resort, using the following IP commands: ip default-gateway, ip default-network, and ip route 0.0.0.0 0.0.0.0. 1>ip default-gateway The ip 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. 大概意思是:当ip routing失效时才用ip default-gateway 2>ip default-network Unlike the ip 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. 大概意思是:当ip routing在用时应该用ip default-network 3>然后大家再来看看实例: 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 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 Gateway of last resort is not set 161.44.0.0 255.255.255.0 is subnetted, 1 subnets C 161.44.192.0 is directly connected, Ethernet0 S 198.10.1.0 [1/0] via 161.44.192.2 131.108.0.0 255.255.255.0 is subnetted, 1 subnets C 131.108.99.0 is directly connected, TokenRing0 Note the static route to 198.10.1.0 via 161.44.192.2 and that the gateway of last resort is not set. If you configure ip default-network 198.10.1.0, the routing table changes to the following: 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 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 Gateway of last resort is 161.44.192.2 to network 198.10.1.0 161.44.0.0 255.255.255.0 is subnetted, 1 subnets C 161.44.192.0 is directly connected, Ethernet0 S 161.44.0.0 255.255.0.0 [1/0] via 161.44.192.0 S* 198.10.1.0 [1/0] via 161.44.192.2 131.108.0.0 255.255.255.0 is subnetted, 1 subnets C 131.108.99.0 is directly connected, TokenRing0 2513#show ip protocols 2513# You can see the gateway of last resort has now been set as 161.44.192.2. This result is independent of any routing protocol, as shown by the show 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 terminal Enter configuration commands, one per line. End with CNTL/Z. 2513(config)#ip route 171.70.24.0 255.255.255.0 131.108.99.2 2513(config)#ip default-network 171.70.24.0 2513(config)#^Z 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 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 Gateway of last resort is 161.44.192.2 to network 198.10.1.0 161.44.0.0 255.255.255.0 is subnetted, 1 subnets C 161.44.192.0 is directly connected, Ethernet0 S 161.44.0.0 255.255.0.0 [1/0] via 161.44.192.0 S* 198.10.1.0 [1/0] via 161.44.192.2 171.70.0.0 is variably subnetted, 2 subnets, 2 masks S 171.70.0.0 255.255.0.0 [1/0] via 171.70.24.0 S 171.70.24.0 255.255.255.0 [1/0] via 131.108.99.2 131.108.0.0 255.255.255.0 is subnetted, 1 subnets C 131.108.99.0 is directly connected, TokenRing0 Notice that after entering the above command, the network was not flagged as a default network. The following section explains why. Flagging a Default Network Note: 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 issued 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 171.70.0.0 2513(config)#^Z 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 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 Gateway of last resort is 161.44.192.2 to network 198.10.1.0 161.44.0.0 255.255.255.0 is subnetted, 1 subnets C 161.44.192.0 is directly connected, Ethernet0 S 161.44.0.0 255.255.0.0 [1/0] via 161.44.192.0 S* 198.10.1.0 [1/0] via 161.44.192.2 171.70.0.0 is variably subnetted, 2 subnets, 2 masks S* 171.70.0.0 255.255.0.0 [1/0] via 171.70.24.0 S 171.70.24.0 255.255.255.0 [1/0] via 131.108.99.2 131.108.0.0 255.255.255.0 is subnetted, 1 subnets C 131.108.99.0 is directly connected, TokenRing0 If 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 protocols 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.0.0.0/0. This command allows you to configure robustness into the selection of a gateway 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. You can remove the lost route by removing the static route in the configuration as follows: 2513#config terminal Enter configuration commands, one per line. End with CNTL/Z. 2513(config)#no ip route 198.10.1.0 255.255.255.0 161.44.192.2 2513(config)#^Z 2513# %SYS-5-CONFIG_I: Configured from console by console After 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 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 Gateway of last resort is 171.70.24.0 to network 171.70.0.0 161.44.0.0 255.255.255.0 is subnetted, 1 subnets C 161.44.192.0 is directly connected, Ethernet0 S 161.44.0.0 255.255.0.0 [1/0] via 161.44.192.0 * 171.70.0.0 is variably subnetted, 2 subnets, 2 masks S* 171.70.0.0 255.255.0.0 [1/0] via 171.70.24.0 S 171.70.24.0 255.255.255.0 [1/0] via 131.108.99.2 131.108.0.0 255.255.255.0 is subnetted, 1 subnets C 131.108.99.0 is directly connected, TokenRing0 2513# Using Different Routing Protocols Gateways of last resort selected using the ip 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-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 0.0.0.0. For example, note that the gateway of last resort on the router below was learned using the combination of the ip route and ip default-network commands. If you enable RIP on this router, RIP advertises a route to 0.0.0.0 (although not to the Token Ring network because of split-horizon): 2513(config)#router rip 2513(config-router)#network 161.44.0.0 2513(config-router)#network 131.108.0.0 2513(config-router)#^Z 2513# 2513# 2513# %SYS-5-CONFIG_I: Configured from console by console 2513#debug ip rip RIP protocol debugging is on 2513# RIP: sending update to 255.255.255.255 via Ethernet0 (161.44.192.1) default 0.0.0.0, metric 1 network 131.108.0.0, metric 1 RIP: sending update to 255.255.255.255 via TokenRing0 (131.108.99.1) network 161.44.0.0, metric 1 2513# 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 originate command. OSPF, like RIP, advertises a route for 0.0.0.0 0.0.0.0. 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 0.0.0.0 0.0.0.0 Creating a static route to network 0.0.0.0 0.0.0.0 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 0.0.0.0 is not dependent on any routing protocols. However, ip routing must be enabled on the router. Note: IGRP does not understand a route to 0.0.0.0, therefore it cannot propagate default routes created using the ip route 0.0.0.0 0.0.0.0 command. Use the ip default-network command to have IGRP propagate a default route. EIGRP propagates a route to network 0.0.0.0, but the static route must be redistributed into EIGRP. RIP and 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 0.0.0.0 0.0.0.0 command: router-3#conf terminal Enter configuration commands, one per line. End with CNTL/Z. router-3(config)#ip route 0.0.0.0 0.0.0.0 170.170.3.4 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 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 - ODR Gateway of last resort is 170.170.3.4 to network 0.0.0.0 170.170.0.0/24 is subnetted, 2 subnets C 170.170.2.0 is directly connected, Serial0 C 170.170.3.0 is directly connected, Ethernet0 S* 0.0.0.0/0 [1/0] via 170.170.3.4 router-3# router-3# Note: If you configure multiple networks as candidate default routes using the ip default-network command, the network that has the lowest administrative distance is chosen as the network for the gateway of last resort. If all the networks have the same administrative distance then the network listed first in the routing table (show ip route lists the routing table) is chosen as the network for the gateway of last resort. If you use both the ip default-network and ip route 0.0.0.0 0.0.0.0 commands to configure candidate default networks, and the network used by the ip default-network command is known statically, the network defined with the ip default-network command takes precedence and is chosen for the gateway of last resort. Otherwise if the network used by the ip default-network command is derived by a routing protocol, the ip route 0.0.0.0 0.0.0.0 command, which will have a lower administrative distance, takes precedence and is chosen for the gateway of last resort. Lastly, if you use multiple ip route 0.0.0.0 0.0.0.0 commands to configure a default route, traffic is load-balanced over the multiple routes. Summary To summarize, you can use the ip default-gateway command when ip routing is disabled on a Cisco router. Use the ip default-network and ip route 0.0.0.0 0.0.0.0 commands to set the gateway of last resort on Cisco routers that have ip routing enabled. The way in which routing protocols propagate the default route information varies for each protocol |