ip default-network和ip route 0.0.0.0 0.0.0.0默認(rèn)路由的區(qū)別
在自己的2501上研究這三種默認(rèn)路由的區(qū)別.
指定默認(rèn)路由(last resort gateway)的指令供有3種,可以分成兩類:
1、ip default-gateway
當(dāng)路由器上的ip routing無效時(shí),使用它指定默認(rèn)路由,用于RXBoot模式(no ip routing)下安裝IOS等?;蛘哧P(guān)閉ip routing 讓路由器當(dāng)主機(jī)用,此時(shí)需要配置默認(rèn)網(wǎng)關(guān)
2、ip default-network和ip route 0.0.0.0 0.0.0.0
兩者都用于ip routing有效的路由器上,區(qū)別主要在于路由協(xié)議是否傳播這條路由信息。比如:IGRP無法識(shí)別0.0.0.0,因此傳播默認(rèn)路由時(shí)必須用ip default-network。
當(dāng)用ip default-network指令設(shè)定多條默認(rèn)路由時(shí),administrative distance最短的成為最終的默認(rèn)路由;如果有復(fù)數(shù)條路由distance值相等,那么在路由表(show ip route)中靠上的成為默認(rèn)路由。
同時(shí)使用ip default-network和ip route 0.0.0.0 0.0.0.0雙方設(shè)定默認(rèn)路由時(shí),如果ip default-network設(shè)定的網(wǎng)絡(luò)是直連(靜態(tài)、且已知)的,那么它就成為默認(rèn)路由;如果ip default-network指定的網(wǎng)絡(luò)是由交換路由信息得來的,則ip route 0.0.0.0 0.0.0.0指定的表項(xiàng)成為默認(rèn)路由。
最后,如果使用多條ip route 0.0.0.0 0.0.0.0指令,則流量會(huì)自動(dòng)在多條鏈路上負(fù)載均衡。
官方詳細(xì)文檔點(diǎn)這里
例子:
關(guān)閉ip routing 舉例:
mycisco(config)#no ip routing
mycisco(config)#ip default-gateway 192.168.0.1
mycisco(config)#end
mycisco#ping www.flashku.com
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 www.flashku.com
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 必須是在所到網(wǎng)絡(luò)已經(jīng)存在路由的情況下,否則執(zhí)行無效.
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
接著我們執(zhí)行:
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
相關(guān)文章
網(wǎng)管必學(xué)之交換機(jī)VLAN的配置
網(wǎng)管必學(xué)之交換機(jī)VLAN的配置...2007-09-09簡(jiǎn)單就是美,網(wǎng)絡(luò)命令行的使用和范例
簡(jiǎn)單就是美,網(wǎng)絡(luò)命令行的使用和范例...2007-09-09解決采用多路由協(xié)議的網(wǎng)絡(luò)問題
解決采用多路由協(xié)議的網(wǎng)絡(luò)問題...2007-09-09總結(jié)Cisco設(shè)備做流量監(jiān)控的方法
總結(jié)Cisco設(shè)備做流量監(jiān)控的方法...2007-09-09終結(jié)倒計(jì)時(shí)為安全 Win98就別上網(wǎng)
終結(jié)倒計(jì)時(shí)為安全 Win98就別上網(wǎng)...2007-09-09