ip default-gateway、ip route和ip default-network的区别

 指定默认路由(last resort gateway)的指令供有3种,可以分成两类:

1ip default-gateway
当路由器上的ip routing无效时,使用它指定默认路由,用于RXBoot模式(no ip routing)下安装IOS等。或者关闭ip routing 让路由器当主机用,此时需要配置默认网关。

2
ip 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-gateway测试

Mycisco(config)#no ip routing

Mycisco(config)#ip default-gateway 10.1.2.1

Mycisco(config)#do ping 119.75.217.56

 

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 119.75.217.56, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 8/217/1040 ms

Mycisco(config)#do sh ip route

Default gateway is 10.1.2.1

 

Host               Gateway           Last Use    Total Uses  Interface

ICMP redirect cache is empty

Mycisco(config)#

 

 

//ip route测试

Mycisco(config)#ip route 0.0.0.0 0.0.0.0 10.1.2.1

Mycisco(config)#do ping 119.75.217.56

 

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 119.75.217.56, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 8/20/44 ms

 

Mycisco(config)#do sh 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.1 to network 0.0.0.0

 

     10.0.0.0/24 is subnetted, 1 subnets

C       10.1.2.0 is directly connected, FastEthernet0/0

S*   0.0.0.0/0 [1/0] via 10.1.2.1

Mycisco(config)#

 

 

//ip default-network测试 (ip default-network 必须是在所到网络已经存在路由的情况下,否则执行无效).

R2(config)#ip route 119.0.0.0 255.0.0.0 172.16.0.1

R2(config)#do sh 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

 

S    119.0.0.0/8 [1/0] via 172.16.0.1

C    172.16.0.0/16 is directly connected, FastEthernet0/0

R2(config)#ip default-network 119.0.0.0

R2(config)#do sh 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.16.0.1 to network 119.0.0.0

 

S*   119.0.0.0/8 [1/0] via 172.16.0.1

C    172.16.0.0/16 is directly connected, FastEthernet0/0

R2(config)#

你可能感兴趣的:(IP,IP,IP,route,路由,default-gateway,default-network)