打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
ip route 0.0.0.0 0.0.0.0和ip defult-network区别
哪位能说说ip route 0.0.0.0 0.0.0.0和ip default-network命令的区别吗?

我所知道的ip route 命令会向路由表里加一条静态路由,ip default-network命令不会

ip route 命令按接口和地址指定缺省路由ip default-network命令按网络指定

谁能说说还有什么区别?以及在什么情况下使用哪条吗?还有他们在再发布时的区别!

FW:发信人: canway()

整理人: sanjose(2000-09-26 10:54:44), 站内信件

Q:

听了各位解释,有些明白,可是路由器没有路由还叫路由器吗,那样两个命令

功能似乎是一样的,都是把不知道到的包发给下一个站点,可是我在做一个项目

时,

设置ip default-gateway就不行。用ip route 0.0.0.0 0.0.0.0 xxxxxxxx

就通了。 是不是这样,对于ip default-gateway来说,只有对这个网段才有效,

而从其他

网段路由过来的其他网段的信息到了用ip default-gateway的网段就不能利用这

个 命令传送,而是要用ip route 0.0.0.0 0.0.0.0.了。也就是ip route 0.0.0

.0

0.0.0.0才能完成路由功能,不知道理解的对吗

Answer:

1。 ip default-gateway用与路由器不作路由时使用,这时路由器就只是一台主

机好象Win95PC一样需要配一个网关才能与外界通信。

如果 “no ip routing"则路由器就不作路由。这时你可以配bridge-group,把路

由表及里器当switch使。

2。 ip route 0.0.0.0 0.0.0.0 用于履行路由功能。如果ip routin

g是enable的则ip default-gateway不起作用.

FW:区别在于,ip route本机生效,ip default-network可以影响整个路由协议域

http://www.cisco.com/en/US/customer...shtml#ipnetwork

FW: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. Let's look at each of these commands in more detail.

Before You Begin

Conventions

For more information on document conventions, see the Cisco Technical Tips Conventions.

Prerequisites

There are no specific prerequisites for this document.

Components Used

This document is not restricted to specific software and hardware versions.

The information presented in this document was created from devices in a specific lab environment. All of the devices used in this document started with a cleared (default) configuration. If you are working in a live network, ensure that you understand the potential impact of any command before using it.

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.

For instance, if the router is a host in the IP world, 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 doesn't have ip routing enabled.

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.

For every network configured with ip default-network, if a router has a route to that network, that route is flagged as a candidate default route. Let's look at the following routing table taken from a Cisco router:

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 isn't set. If we 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#

We 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.

We 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

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, we wouldn't have needed the extra step of configuring the default network twice.

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 we 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 higher, RIP doesn't 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 isn't dependent on any routing protocols. However, ip routing must be enabled on the router.

Note: IGRP doesn't understand a route to 0.0.0.0, therefore it can't 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.

Let's 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.

FW:0.0.0.0只能标记一条静态缺省路由,ip default-network更灵活,可以标记几条静态缺省路由,路由器可以从中选择开销最小的一个。

0.0.0.0可以在RIP、EIGRP、OSPF中配置,在IGRP中只能用ip default-network,因为IGRP不能识别网络0.0.0.0/0(ip default-network不能在EIGRP、OSPF中使用)。如果在RIP中同时配置0.0.0.0和ip default-network,路由器会把0.0.0.0/0作为ip缺省路由进行传播。

在IOS12.1之前的版本中,0.0.0.0在RIP自动被传播给其他路由器。在IOS12.1中,RIP不自动传播静态缺省路由。要传播的话要使用“networ 0.0.0.0”命令,也可以使用

“default-information originate"或"redistribute static"命令。

要想在OSPF中传播静态缺省路由(无论什么版本),也要用"default-information originate"命令。

“ip default-network”命令是有类别的,如果路由器有一条到用该命令所指示的子网路由,那么它将安装一条到其主类网络的静态路由,然后将这条路由标记为一条候选缺省路由。

eigrp 传播默认路由,不需要加 default-information originate,那个命令是给ospf用的,因为它默认不传播default-route

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
为什么有些 OSPF 路由在数据库里但不在路由表里?
路由重分发工作原理
默认路由配置
《转载》缺省路由发布总结
OSPF Area Types and LSAs
专用Cisco路由器的替代品 Zebra二
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服