看过不是文档 关于自动通告默认路由 结果一做很多不行!
本测试使用的是NP BSCI的实验拓扑,拓扑参数可以到我BLOG上找!FR是全互联的!已下实验都经过测试
默认路由试验_CCIE
试验环境: dynamips 0.26RC4
IOS 2691
 Route p1r1 p1r2
 
1ip default-gateway
当路由器上的ip routing无效时,使用它指定默认路由
2ip default-networkip 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-networkip 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 default-network:
 
CISCO路由器的IP ROUTING 可用的时候你可以使用Default-network命令 当你配置 ip default-network 你要考虑路由上到达网络的最后求助网关 为每个网络配置ip defaultnetwork 如果路由能到达此网络,这个路由将会标记候选路由!
 
P1R4#show ip route
Codes: C - connected, S - static, 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
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route
 
Gateway of last resort is not set
 
     10.0.0.0/24 is subnetted, 1 subnets
C       10.1.2.0 is directly connected, FastEthernet0/0
P1R4#
 
P1R4(config)# ip route 172.31.0.0 255.255.255.0 10.1.2.2
P1R4(config)#ip default-network 172.31.0.0  
 
 
P1R4#show ip
*Mar  1 01:08:06.595: %SYS-5-CONFIG_I: Configured from console by console
P1R4#show ip route
Codes: C - connected, S - static, 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
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route
 
Gateway of last resort is 10.1.2.2 to network 172.31.0.0
 
 *   172.31.0.0/24 is subnetted, 1 subnets
S*      172.31.0.0 [1/0] via 10.1.2.2
     10.0.0.0/24 is subnetted, 1 subnets
C       10.1.2.0 is directly connected, FastEthernet0/0
P1R4#
 
这个命令是独立于路由协议的!
默认网关已经变成 10.1.2.2了!
 
 
Ip default-network这个命令是 classful
 
P1R4(config)#ip route 168.32.1.0 255.255.255.0 10.1.3.3   
P1R4(config)#ip def
P1R4(config)#ip default-n
P1R4(config)#ip default-network 168.32.1.0
P1R4(config)#end
P1R4#show ip route
Codes: C - connected, S - static, 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
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route
 
Gateway of last resort is 10.1.2.2 to network 172.31.0.0
 
     168.32.0.0/16 is variably subnetted, 2 subnets, 2 masks
S       168.32.0.0/16 [1/0] via 168.32.1.0
S       168.32.1.0/24 [1/0] via 10.1.3.3
 *   172.31.0.0/24 is subnetted, 1 subnets
S*      172.31.0.0 [1/0] via 10.1.2.2
     10.0.0.0/24 is subnetted, 2 subnets
C       10.1.3.0 is directly connected, Serial1/0
C       10.1.2.0 is directly connected, FastEthernet0/0
P1R4#
*Mar  1 01:34:55.419: %SYS-5-CONFIG_I: Configured from console by console
P1R4#Explain:
 
ip default-network命令是有类别的,意味着如果路由器有一个路由到此命令表示的子网,它才会被作为默认的求助网关。
这时两个网络未被标记作为默认网络。必须使用主网再发出ip default-network命令.
 
再看:
P1R4(config)#ip default-n
P1R4(config)#ip default-network 168.32.0.0
P1R4(config)#end
P1R4#show ip r
*Mar  1 01:35:59.095: %SYS-5-CONFIG_I: Configured from console by console
P1R4#show ip route
Codes: C - connected, S - static, 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
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route
 
Gateway of last resort is 168.32.1.0 to network 168.32.0.0
 
 *   168.32.0.0/16 is variably subnetted, 2 subnets, 2 masks
S*      168.32.0.0/16 [1/0] via 168.32.1.0
S       168.32.1.0/24 [1/0] via 10.1.3.3
 *   172.31.0.0/24 is subnetted, 1 subnets
S*      172.31.0.0 [1/0] via 10.1.2.2
     10.0.0.0/24 is subnetted, 2 subnets
C       10.1.3.0 is directly connected, Serial1/0
C       10.1.2.0 is directly connected, FastEthernet0/0
P1R4#
 
可以看到 命令是classful 默认路由又添加了一个!
注意下
Gateway of last resort is 168.32.1.0 看看是不是和上面的有变动了!
呵呵 请看看前面的说明!
 
使用不同的路由协议:
使用ip default-network命令选择的最后求助网关根据路由协议不同而不同。为了能传播路由,IGRPEIGRP ip default-network命令指定的网络必须为IGRPEIGRP所知。这意味着网络在路由表里必须是一个IGRP-EIGRP派生的网络,或者必须再分布用于的静态路由生成路由对网络到IGRP EIGRP

RIP
做通告路由到0.0.0.0 。例如,注意最后求助网关在如下路由器使用IP 路由和ip default-network 命令的组合是获知 。如果在此路由器启用RIPRIP做通告路由到0.0.0.0 (虽然不对令牌环网络由于纵向隔离)
----------------------------------------------------------------------
RIP
  
P1R1配置
P1R1(config)#ip route 0.0.0.0 0.0.0.0 172.31.1.2 创建一条静态路由
也可以 ip route 0.0.0.0 0.0.0.0 s1/0
这样的话 P1R1路由表出现的
Gateway of last resort is 0.0.0.0 to network 0.0.0.0
P1R1(config)#router rip  
P1R1(config-router)#default-information originate 通过RIP协议通告默认路由
P1R1路由表
P1R1#show ip route
Codes: C - connected, S - static, 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
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route
 
Gateway of last resort is 172.31.1.2 to network 0.0.0.0
 
     172.31.0.0/16 is variably subnetted, 2 subnets, 2 masks
C       172.31.1.0/24 is directly connected, Serial1/0
R       172.31.0.0/16 [120/1] via 10.1.0.2, 00:00:08, Serial1/1
     10.0.0.0/24 is subnetted, 3 subnets
R       10.1.2.0 [120/1] via 10.1.0.2, 00:00:08, Serial1/1
C       10.1.1.0 is directly connected, FastEthernet0/0
C       10.1.0.0 is directly connected, Serial1/1
S*   0.0.0.0/0 [1/0] via 172.31.1.2
 P1R2的路由表  
P1R2#
*Mar  1 00:03:06.415: %SYS-5-CONFIG_I: Configured from console by console
P1R2#show ip route
Codes: C - connected, S - static, 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
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route
 
Gateway of last resort is 10.1.0.1 to network 0.0.0.0
     172.31.0.0/24 is subnetted, 1 subnets
C       172.31.1.0 is directly connected, Serial1/0
     10.0.0.0/24 is subnetted, 3 subnets
C       10.1.2.0 is directly connected, FastEthernet0/0
R       10.1.1.0 [120/1] via 10.1.0.1, 00:00:13, Serial1/1
C       10.1.0.0 is directly connected, Serial1/1
R*   0.0.0.0/0 [120/1] via 10.1.0.1, 00:00:03, Serial1/1
P1R2#
 
已经传递了!
------------------------------------------------------
Ospf  
P1   R1:
P1R1(config)#ip route 0.0.0.0 0.0.0.0 s1/0   
P1R1(config-router)#default-information originate
 
P1r1 route table
 
P1R1#
*Mar  1 00:22:52.363: %SYS-5-CONFIG_I: Configured from console by console
P1R1#show ip route
Codes: C - connected, S - static, 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
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route
 
Gateway of last resort is 0.0.0.0 to network 0.0.0.0
 
     172.31.0.0/24 is subnetted, 1 subnets
C       172.31.1.0 is directly connected, Serial1/0
     10.0.0.0/24 is subnetted, 3 subnets
O       10.1.2.0 [110/65] via 10.1.0.2, 00:02:14, Serial1/1
C       10.1.1.0 is directly connected, FastEthernet0/0
C       10.1.0.0 is directly connected, Serial1/1
S*   0.0.0.0/0 is directly connected, Serial1/0
P1R1#
  
P1R2 route table
 
P1R2#show ip route
Codes: C - connected, S - static, 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
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route
 
Gateway of last resort is 10.1.0.1 to network 0.0.0.0
 
     172.31.0.0/24 is subnetted, 1 subnets
O       172.31.1.0 [110/128] via 10.1.0.1, 00:00:05, Serial1/1
     10.0.0.0/24 is subnetted, 3 subnets
C       10.1.2.0 is directly connected, FastEthernet0/0
O       10.1.1.0 [110/65] via 10.1.0.1, 00:00:05, Serial1/1
C       10.1.0.0 is directly connected, Serial1/1
O*E2 0.0.0.0/0 [110/1] via 10.1.0.1, 00:00:05, Serial1/1
P1R2#
现在其中一台ROUTE中通告一个默认路由
通过Default-information origiate传播到外地的路由表中!
 
 
 
P1R4
P1R4#show ip route
Codes: C - connected, S - static, 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
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route
 
Gateway of last resort is 10.1.2.2 to network 0.0.0.0
 
     172.31.0.0/24 is subnetted, 1 subnets
O       172.31.1.0 [110/129] via 10.1.2.2, 00:06:30, FastEthernet0/0
     10.0.0.0/24 is subnetted, 3 subnets
C       10.1.2.0 is directly connected, FastEthernet0/0
O       10.1.1.0 [110/66] via 10.1.2.2, 00:06:30, FastEthernet0/0
O       10.1.0.0 [110/65] via 10.1.2.2, 00:06:30, FastEthernet0/0
O*E2 0.0.0.0/0 [110/1] via 10.1.2.2, 00:06:30, FastEthernet0/0
P1R4#
 
Default metric 1 而不是BSCI自学指南P212上说的 10  书的作者已经试验验证了!
 
--------------------------------------------------------------------------------
 
EIGRP
 
Eigrp在默认的情况下不重发 0.0.0.0 0.0.0.0 默认路由 但是如果在NETWORK中添加network 0.0.0.0命令 由于ip route 0.0.0.0 0.0.0.0 interface 命令所产生的结果(不是ip route 0.0.0.0 0.0.0.0 add ip default-network).他将重分发一条默认路由。实验见:
 
 
方法一:
 
P1R1(config-router)#ip route 0.0.0.0 0.0.0.0 s1/0
P1R1(config)#
*Mar  1 00:00:44.851: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial1/0, changed state to down
P1R1(config)#router eigrp 100
P1R1(config-router)#network 0.0.0.0
 
P1R1 路由表
P1R1#show ip route
Codes: C - connected, S - static, 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
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route
 
Gateway of last resort is 0.0.0.0 to network 0.0.0.0
 
     172.31.0.0/16 is variably subnetted, 2 subnets, 2 masks
C       172.31.1.0/24 is directly connected, Serial1/0
D       172.31.0.0/16 is a summary, 00:05:04, Null0
     10.0.0.0/8 is variably subnetted, 4 subnets, 2 masks
D       10.1.2.0/24 [90/2172416] via 10.1.0.2, 00:05:07, Serial1/1
C       10.1.1.0/24 is directly connected, FastEthernet0/0
D       10.0.0.0/8 is a summary, 00:05:04, Null0
C       10.1.0.0/24 is directly connected, Serial1/1
S*   0.0.0.0/0 is directly connected, Serial1/0
P1R1#
*Mar  1 00:06:28.071: %SYS-5-CONFIG_I: Configured from console by console
P1R1#
 
P1R2
P1R2#show ip route
Codes: C - connected, S - static, 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
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route
 
Gateway of last resort is 10.1.0.1 to network 0.0.0.0
 
D    172.31.0.0/16 [90/2681856] via 10.1.0.1, 00:00:02, Serial1/1
     10.0.0.0/24 is subnetted, 3 subnets
C       10.1.2.0 is directly connected, FastEthernet0/0
D       10.1.1.0 [90/2172416] via 10.1.0.1, 00:00:05, Serial1/1
C       10.1.0.0 is directly connected, Serial1/1
D*   0.0.0.0/0 [90/2681856] via 10.1.0.1, 00:00:02, Serial1/1
P1R2#
 
已经传递过来了!
 
-------------------------------------------------------------------
EIGRP
方法二:
P1R1  
router eigrp 100
 redistribute static
 network 10.0.0.0
 auto-summary
!         
ip http server
ip classless
ip route 0.0.0.0 0.0.0.0 172.31.1.3( 接口或者地址都可以)
P1R1 route table
P1R1#show ip route
Codes: C - connected, S - static, 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
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route
 
Gateway of last resort is 172.31.1.3 to network 0.0.0.0
 
     172.31.0.0/24 is subnetted, 1 subnets
C       172.31.1.0 is directly connected, Serial1/0
     10.0.0.0/24 is subnetted, 3 subnets
D       10.1.2.0 [90/2172416] via 10.1.0.2, 00:02:34, Serial1/1
C       10.1.1.0 is directly connected, FastEthernet0/0
C       10.1.0.0 is directly connected, Serial1/1
S*   0.0.0.0/0 [1/0] via 172.31.1.3
P1R1#
接下来看看 P1R2的!
P1R2#show ip route
Codes: C - connected, S - static, 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
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route
 
Gateway of last resort is 10.1.0.1 to network 0.0.0.0
 
     10.0.0.0/24 is subnetted, 3 subnets
C       10.1.2.0 is directly connected, FastEthernet0/0
D       10.1.1.0 [90/2172416] via 10.1.0.1, 00:00:33, Serial1/1
C       10.1.0.0 is directly connected, Serial1/1
D*EX 0.0.0.0/0 [170/2681856] via 10.1.0.1, 00:00:03, Serial1/1
P1R2#
通过 Redistribute static 也是可以的 但是 作为外部的EIGRP路由通告出去!
------------------------------------------------------------------------
 
默认路由的注意事项
注意: 在早期的RIP版本中 使用 IP ROUTE 0.0.0.0 0.0.0.0 创建的默认路由会自动的在rip路由器中被宣告 但是 CISCO SOFTWATE RELEASE 12.0T以后的版本中 RIP不会宣告默认路由 就算是此设置为默认的网络被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是另一 个方式设置最后求助网关在路由器。照同 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,但必须再分布静态路由到EIGRPRIP OSPF 正常运行如所描述当使用 ip default-network命令时。记住上面附注仍 然适用。
 
 
如果 配置多个网络作为候选默认路由使用 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路由器。路由协议传播默认路由信息的方式为每个协议变化。
 原文地址 [url]http://hi.baidu.com/ciscotech/blog/item/1393678bc4b1e212c9fc7a40.html[/url]