5
第5篇:默认路由-IP route 0.0.0.0 0.0.0.0
上一节我们学习了IP Default-Gateway,今天我们开始学习默认路由里的IP route 0.0.0.0 0.0.0.0,跟着我一起往下看吧。
IP route 0.0.0.0 0.0.0.0
为路由器配置默认网关时,IP Default-Gateway只能在关闭路由功能后起作用,在路由功能开启的情况下,通过命令IP route 0.0.0.0 0.0.0.0同样可以为路由器配置默认网关。
两者的区别在于,IP Default-Gateway只能在路由功能关闭时工作,并且一台路由器只能配置一条,而IP route 0.0.0.0 0.0.0.0可以在路由功能开启时工作,一条路由器可以配置多条IP route 0.0.0.0 0.0.0.0。
配置IP route 0.0.0.0 0.0.0.0
说明:必须开启路由功能。
说明:以上图为例,配置ip route 0.0.0.0 0.0.0.0
1.在R3上配置ip route 0.0.0.0 0.0.0.0
(1)在R3上配置ip route 0.0.0.0 0.0.0.0:
r3(config)#ip route 0.0.0.0 0.0.0.0 10.1.1.1
说明:R3的网关指向10.1.1.1(R1)。
(2)查看R3的路由情况:
r3#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.1.1 to network 0.0.0.0
20.0.0.0/24 is subnetted, 1 subnets
C 20.1.1.0 is directly connected, FastEthernet0/1
10.0.0.0/24 is subnetted, 1 subnets
C 10.1.1.0 is directly connected, FastEthernet0/0
S* 0.0.0.0/0 [1/0] via 10.1.1.1
r3#
说明:R3路由表中有一条指向10.1.1.1的默认网关。
(3)测试网络连通性:
r3#ping 192.168.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 28/80/196 ms
r3#
r3#ping 172.16.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 24/77/200 ms
r3#
说明:因为R3的网关为10.1.1.1,而172.16.1.1与192.168.1.1也在R1上,所以R3与172.16.1.1和192.168.1.1通信正常。
2.配置多条ip route 0.0.0.0 0.0.0.0
(1)在R3上配置多条ip route 0.0.0.0 0.0.0.0:
r3(config)#ip route 0.0.0.0 0.0.0.0 10.1.1.1
r3(config)#ip route 0.0.0.0 0.0.0.0 10.1.1.2
说明:命令ip route 0.0.0.0 0.0.0.0可以在单台路由器上重复配置。
(2)查看R3路由表情况:
r3#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.1.2 to network 0.0.0.0
20.0.0.0/24 is subnetted, 1 subnets
C 20.1.1.0 is directly connected, FastEthernet0/1
10.0.0.0/24 is subnetted, 1 subnets
C 10.1.1.0 is directly connected, FastEthernet0/0
S* 0.0.0.0/0 [1/0] via 10.1.1.2
[1/0] via 10.1.1.1
r3#
说明:当配置多条ip route 0.0.0.0 0.0.0.0后,路由器将同时在其间执行负载均衡,需要注意的是,负载均衡会受到CEF的影响,所以默认情况,可能不是你想要的结果。
好了,今天这15分钟也完成了,建议线下动手做下实验,下一节我们将学习默认路由的IP Default-Network
领取专属 10元无门槛券
私享最新 技术干货