Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1538643
  • 博文数量: 416
  • 博客积分: 10061
  • 博客等级: 上将
  • 技术积分: 3287
  • 用 户 组: 普通用户
  • 注册时间: 2006-12-05 11:12
个人简介

技术在于专研

文章分类

全部博文(416)

文章存档

2021年(3)

2015年(34)

2013年(2)

2012年(1)

2011年(2)

2010年(5)

2007年(344)

2006年(25)

分类: 系统运维

2006-12-07 15:32:03

 

500度:

的关于默认路由的文档

 

one:CISCO 文档

前言
此技术说明解释如何使 用以下IP命令配置最后一招默认路由或者网关,: ip default-gateway、 ip default-network 和ip route 0.0.0.0 0.0.0.0。

在您开始之 前
惯例
欲 知关于文件惯例的更多信息,请参阅 Cisco技 术提示惯例。

前提
此文档没有特殊的先决 条件。

使 用的组件
本文不限于特 定软件和硬件版本。

本文提供的信 息在特定实验室环境里从设备被创建了。用于本文的所有设 备开始了以一个缺省(默认)配置。如果在一个真实网络工 作,保证您使用它以前了解所有命令的潜在影响。

ip default-gateway
ip default-gateway命 令与其他二个命令有所不同因为应该只使用当 IP路由 在Cisco路由器时禁用。

例如,如果路由器是一台主机在IP 环境,您能使用此命令定义默认网关为它。 当您的低端 Cisco路由器在启动模式为了TFTP 是Cisco IOS软件镜象到路由器时 ,您® 也许也使用此命令。在启动模式,路由 器没有 被启用的 IP路由 。

ip default-network
不同于 ip default-gateway命令,当IP路由 在 Cisco路由器时, 被启用您能使用ip default-network 。当您配 置 ip default-network时 路由器在路由器考虑路由到该网络为安装作为最后一 招网关。

为用 ip default-network 配置每个 网络,如果路由器有一个路由到该网络,该路 由被标记作为候选默认路由。查看从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 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
注释静态路由到198.10.1.0 通过161.44.192.2 并且没有设置最后一招网关。如果配置 ip default-network 198.10.1.0,路由表更改到以下:

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路由器。路由协议传播默认路由信息的方 式为每个协议变化。
TWO:net130 :ip default-network和ip route 0.0.0.0 0.0.0.0默认路由的区别

在自己的2501上研究这三种默认路由的区别.

指定默认路由(last resort gateway)的指令供有3种,可以分成两类:
1、ip default-gateway
当路由器上的ip routing无效时,使用它指定默认路由,用于RXBoot模式(no ip routing)下安装IOS等。或者关闭ip routing 让路由器当主机用,此时需要配置默认网关

2、ip default-network和ip route 0.0.0.0 0.0.0.0
两者都用于ip routing有效的路由器上,区别主要在于路由协议是否传播这条路由信息。比如:IGRP无法识别0.0.0.0,因此传播默认路由时必须用ip default-network。

当用ip default-network指令设定多条默认路由时,administrative distance最短的成为最终的默认路由;如果有复数条路由distance值相等,那么在路由表(show ip route)中靠上的成为默认路由。
同时使用ip default-network和ip route 0.0.0.0 0.0.0.0双方设定默认路由时,如果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 routing 举例:
mycisco(config)#no ip routing
mycisco(config)#ip default-gateway 192.168.0.1
mycisco(config)#end
mycisco#ping

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echoes to 61.152.167.75, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 60/60/60 ms
mycisco#show ip route
Default gateway is 192.168.0.1

Host               Gateway           Last Use    Total Uses  Interface
ICMP redirect cache is empty
mycisco#

ip route例子:
ip route 0.0.0.0 0.0.0.0 192.168.0.1

mycisco#ping

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echoes to 61.152.167.75, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 56/56/60 ms
mycisco#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
       U - per-user static route

Gateway of last resort is 192.168.0.1 to network 0.0.0.0

C    1.0.0.0/8 is directly connected, Loopback0
C    192.168.0.0/24 is directly connected, Ethernet0
S*   0.0.0.0/0 [1/0] via 192.168.0.1
mycisco#

ip default-network 必须是在所到网络已经存在路由的情况下,否则执行无效.
mycisco(config)#ip route 61.0.0.0 255.0.0.0 192.168.0.1
mycisco#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
       U - per-user static route

Gateway of last resort is not set

C    1.0.0.0/8 is directly connected, Loopback0
S    61.0.0.0/8 [1/0] via 192.168.0.1
C    192.168.0.0/24 is directly connected, Ethernet0

接着我们执行:
mycisco(config)#ip default-network 61.0.0.0

再看路由表:
mycisco#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
       U - per-user static route

Gateway of last resort is 192.168.0.1 to network 61.0.0.0

C    1.0.0.0/8 is directly connected, Loopback0
S*   61.0.0.0/8 [1/0] via 192.168.0.1
C    192.168.0.0/24 is directly connected, Ethernet0




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
阅读(1348) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~