实验过程:
第一步:先在R1上ping 2.2.2.2网段R1#ping 2.2.2.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds:.....Success rate is 0 percent (0/5) (没有成功)因为在R1上没有去2.2.2.0网段的路由R1#sh ip route Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGPD - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGPi - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, * - candidate defaultU - per-user static route, o - ODRT - traffic engineered routeGateway of last resort is not set
1.0.0.0/24 is subnetted, 1 subnets
C 1.1.1.0 is directly connected, Loopback010.0.0.0/24 is subnetted, 1 subnetsC 10.1.1.0 is directly connected, Serial1/2R1#可以看到没有去R2的路由第二步:新增路由在R1上加一条默认路由R1(config)#ip route 0.0.0.0 0.0.0.0 10.1.1.2 (这里是下一条的地址或为出接口)R1#show ip routeCodes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGPD - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGPi - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, * - candidate defaultU - per-user static route, o - ODRT - traffic engineered routeGateway of last resort is 10.1.1.2 to network 0.0.0.0
1.0.0.0/24 is subnetted, 1 subnets
C 1.1.1.0 is directly connected, Loopback010.0.0.0/24 is subnetted, 1 subnetsC 10.1.1.0 is directly connected, Serial1/2*S 0.0.0.0/0 [1/0] via 10.1.1.2 (这里可以看到多了一条默认路由)**第四步:在R2上也加入一条默认路由让数据包能返回R2(config)#ip route 0.0.0.0 0.0.0.0 s2/1第五步:现在再次ping 测试一下R1#ping 2.2.2.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds:!!!!!Success rate is 100 percent (5/5), round-trip min/avg/max = 12/20/40 ms在实际环境中一般当路由器作为出口进,配置一条
ip route 0.0.0.0 0.0.0.0 x.x.x.x(x.x.x.x为运营商给的网关)或者ip route 0.0.0.0 0.0.0.0 f0/0(f0/0为去运营商的出接口)
精彩评论