问题
在相对较小而且结构不变的网络中,静态路由是很好的解决方案,它配置简单而且不过多消耗设备资源(动态路由协议在运行时要消耗路由器内部资源,在与其他路由器更新信息时又会消耗网络资源)。
然而在大型网络中,网络非常多,而且很有可能因为某些因素的影响,网络拓扑会有轻微变化。这时如果仍然采用静态路由就非常不方便了。
通过RIP实现路由间通信
方案
动态路由协议配置灵活,路由器会发送自身的路由信息给其他路由器,同时也会接收其他路由器发来的路由信息建立自己的路由表。这样在路由器上就不必像静态路由那样为每个目标地址都配置路由,因为路由器可以通过协议学习这些路由。网络拓扑改变,路由信息也会自动更新,无需管理员干预。
步骤
1.按拓扑图配置路由接口IP和vlan
2.在三台路由上配置RIP路由协议
tarena-router1(config)#router rip
tarena-router1(config-router)#version2 //version 1不支持部连续的子网,它们区别在于version 1可以接收version 1和version 2发送的宣告,因为version 2默认自动进行汇总;而version 2是无类路由协议。还有就是version 1是有类路由协议:关闭路由汇总功能,有两个版本及version 1和version 2。
tarena-router1(config-router)#noauto-summary //关闭路由汇总功能
tarena-router1(config-router)#network 192.168.1.0
tarena-router1(config-router)#network 192.168.2.0
tarena-router2(config)#router rip
tarena-router2(config-router)#version 2
tarena-router2(config-router)#no auto-summary
tarena-router2(config-router)#network 192.168.3.0
tarena-router2(config-router)#network 192.168.2.0
tarena-router3(config)#router rip
tarena-router3(config-router)#version 2
tarena-router3(config-router)#no auto-summary
tarena-router3(config-router)#network 192.168.3.0
tarena-router3(config-router)#network 192.168.4.0
3.分别在三台路由器上查看路由表
tarena-router1#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
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
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, 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
C 192.168.1.0/24 is directly connected, FastEthernet0/0
C 192.168.2.0/24 is directly connected, FastEthernet0/1
R 192.168.3.0/24 [120/1] via 192.168.2.2, 00:00:26, FastEthernet0/1
R 192.168.4.0/24 [120/2] via 192.168.2.2, 00:00:26, FastEthernet0/1
tarena-router2#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
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
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, 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
R 192.168.1.0/24 [120/1] via 192.168.2.1, 00:00:04, FastEthernet0/1
C 192.168.2.0/24 is directly connected, FastEthernet0/1
C 192.168.3.0/24 is directly connected, FastEthernet0/0
R 192.168.4.0/24 [120/1] via 192.168.3.2, 00:00:09, FastEthernet0/0
tarena-router3#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
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
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, 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
R 192.168.1.0/24 [120/2] via 192.168.3.1, 00:00:20, FastEthernet0/0
R 192.168.2.0/24 [120/1] via 192.168.3.1, 00:00:20, FastEthernet0/0
C 192.168.3.0/24 is directly connected, FastEthernet0/0
C 192.168.4.0/24 is directly connected, FastEthernet0/1
4.在PC上测试到主机的通信
PC>ping 192.168.4.1
Pinging 192.168.4.1 with 32 bytes of data:
Reply from 192.168.4.1: bytes=32 time=0ms TTL=125
Reply from 192.168.4.1: bytes=32 time=0ms TTL=125
Reply from 192.168.4.1: bytes=32 time=0ms TTL=125
Reply from 192.168.4.1: bytes=32 time=0ms TTL=125
Ping statistics for 192.168.4.1:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms