在自己的2501上研究這三種默認路由的區(qū)別.
指定默認路由(last resort gateway)的指令供有3種,可以分成兩類:
1、ip default-gateway
當路由器上的ip routing無效時,使用它指定默認路由,用于RXBoot模式(no ip routing)下安裝IOS等。或者關閉ip routing 讓路由器當主機用,此時需要配置默認網(wǎng)關
2、ip default-network和ip route 0.0.0.0 0.0.0.0
兩者都用于ip routing有效的路由器上,區(qū)別主要在于路由協(xié)議是否傳播這條路由信息。比如:IGRP無法識別0.0.0.0,因此傳播默認路由時必須用ip default-network。
當用ip default-network指令設定多條默認路由時,administrative distance最短的成為最終的默認路由;假如有復數(shù)條路由distance值相等,那么在路由表(show ip route)中靠上的成為默認路由。
同時使用ip default-network和ip route 0.0.0.0 0.0.0.0雙方設定默認路由時,假如ip default-network設定的網(wǎng)絡是直連(靜態(tài)、且已知)的,那么它就成為默認路由;假如ip default-network指定的網(wǎng)絡是由交換路由信息得來的,則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 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)絡已經(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
新聞熱點
疑難解答