计算机网络实验 配置RIPv2动态网络
一、要求文档
二、实验要点
想象三个房间(R1、R2、R3),每个房间内的人(PC)只能和本房间的邮差(路由器)说话:
当没有动态路由协议时:
R1 邮差不知道 R3 房间有谁,PC-A 的信件无法送达 PC-C。
启用 RIPv2 后:
邮差们定期开会交换名单(路由表),R1 和 R3 互相知道对方房间有哪些人,信件顺利传递!
这就是配置RIPv2的作用所在。
三、命令实现
1. Part 1 基础配置
注:Step 1和Step 2的过程省略
1)Step 3 - 配置路由器和交换机地址,以R1为例
在每一个路由器中分别执行以下命令:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 <!-- 进入特权模式 --> Router>enable <!-- 进入全局配置模式 --> Router#configure terminal <!-- a. 禁用DNS查询 --> <!-- 能够避免输入无效命令时服务器会自动尝试进行域名解析 --> Router(config)#no ip domain-lookup <!-- b. 配置设备名称 --> Router(config)#hostname R1 <!-- c. 将所有明文密码加密 --> R1(config)#service password-encryption <!-- d. 将class设置成特权EXEC的密码 --> R1(config)#enable secret class <!-- e1. 将cisco设置成线路配置模式的密码 --> R1(config)#line con 0 R1(config-line)#password cisco R1(config-line)#login <!-- 启用密码提示,要求在控制台使用密码进行登录 --> R1(config-line)#logging Synchronous <!-- 启用同步日志 --> R1(config-line)#exit <!-- e2. 将cisco设置成虚拟终端线路(VTY)的密码 --> R1(config)#line vty 0 4 R1(config-line)#password cisco R1(config-line)#login R1(config-line)#exit <!-- f. 设置一个MOTD警告信息 --> R1(config)#banner motd #Unauthorised access is prohibited!# <!-- g. 为线路配置模式启用同步日志 --> <!-- 在e1中已经配置完毕 --> <!-- h. 为所有接口配置地址表中的IP地址 --> R1(config)#interface g0/1 R1(config-if)#ip address 172.30.10.1 255.255.255.0 R1(config-if)#description Connection to S1 and PC-A <!-- i. 配置IP地址对应的接口的描述信息 --> R1(config-if)#no shutdown <!-- 启用端口 --> R1(config-if)# %LINK-5-CHANGED: Interface GigabitEthernet0/1, changed state to up %LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/1, changed state to up R1(config-if)#exit R1(config)# R1(config)# R1(config)#interface s0/0/0 R1(config-if)#ip address 10.1.1.1 255.255.255.252 R1(config-if)#description Connection to R2 <!-- i. 配置IP地址对应的接口的描述信息 --> R1(config-if)#clock rate 128000 <!-- j. 为DCE串行接口配置时钟速率 --> R1(config-if)#no shutdown %LINK-5-CHANGED: Interface Serial0/0/0, changed state to down R1(config-if)#end R1# %SYS-5-CONFIG_I: Configured from console by console R1#wr <!-- k. 复制run -configuration到startup-configuration --> Building configuration... [OK]
完成以上配置之后,路由器之间应该能相互ping通,PC与对应的路由器端口应该能ping通,但PC之间不行。
因为此时各个路由器的路由表中只包含了直连网络,但是在没有动态路由协议的情况下路由器之间无法交换信息,因此也就无法找到通往远程网络的路径。
动态路由协议是一种自动学习和维护路由表的网络协议,允许路由器之间交换路由信息,并根据网络拓扑变化(如链路故障、新增子网)动态调整数据转发路径,无需管理员手动配置每一条路由。
2. Part 2 RIPv2路由配置
1)Step 1 配置RIPv2路由,以R1为例
执行以下命令:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 R1>enable Password: R1#configure t Enter configuration commands, one per line. End with CNTL/Z. R1(config)#router rip <!-- 选择rip模式 --> R1(config-router)#version 2 <!-- 选择RIPv2 --> R1(config-router)#network 10.1.1.0 <!-- 配置第一个直连网络 --> R1(config-router)#network 172.30.10.0 <!-- 配置另一个直连网络 --> R1(config-router)#no auto-summary <!-- 关闭自动汇总 --> R1(config-router)#end R1# %SYS-5-CONFIG_I: Configured from console by console R1#wr Building configuration... [OK] <!-- --------------------------------------------------- --> <!-- 注: 关于直连网络的具体信息,除了直接看拓扑图之外还可以根据命令分析: 依旧以R1为例,执行show ip interface brief命令 R1#show ip interface brief Interface IP-Address OK? Method Status Protocol GigabitEthernet0/0 unassigned YES unset administratively down down GigabitEthernet0/1 172.30.10.1 YES manual up up Serial0/0/0 10.1.1.1 YES manual up up Serial0/0/1 unassigned YES unset administratively down down Vlan1 unassigned YES unset administratively down down 其中出现的打开的几个网络就是直连网络的一个子网,据此可以分析出直连网络的参数。 -->
2)Step 4 配置默认路由
在R2当中执行以下命令:
1 2 3 4 5 6 7 8 9 10 11 12 13 R2#configure t Enter configuration commands, one per line. End with CNTL/Z. R2(config)#ip route 0.0.0.0 0.0.0.0 209.165.201.2 <!-- 配置默认路由,其中最后一个地址是R2的下一跳地址 --> R2(config)#router rip R2(config-router)#default-information originate <!-- 将默认路由通告给其他运行 RIP 的路由器 --> R2(config-router)#end R2# %SYS-5-CONFIG_I: Configured from console by console R2#wr Building configuration... [OK]
这样一来所有互联网流量就可以通过R2统一转发,便于监控和管理。而其它路由器也无需手动配置默认路由,可以通过RIP自动学习。
此时PC之间也就可以ping通了。