计网:实验二 路由器动态路由的配置方法

发布时间 2023-06-02 18:48:57作者: 旺旺大菠萝

 一、实验目的: 

1.理解动态路由的工作原理;

2. 学习并掌握动态路由协议RIP的配置;

3.学习并掌握动态路由协议OSPF的配置;

4.进一步学习路由器的配置命令。

二、实验原理:

RIP:Routing Information Protocol,路由信息协议,是应用较早、使用较普遍的IGP内部网关协议,适用于小型同类网络,是典型的距离矢量协议。

RIP协议跳数作为衡量路径开销的,RIP协议里规定最大跳数为15。

RIP协议有两个版本RIPv1和RIPv2。

RIPv1属于有类路由协议,不支持VLSM(变长子网掩码),RIPv1是以广播的形式进行路由信息的更新的;更新周期为30秒。

RIPv2属于无类路由协议,支持VLSM(变长子网掩码),RIPv2是以组播的形式进行路由信息的更新的,组播地址是224.0.0.9。RIPv2还支持基于端口的认证,提高网络的安全性。

OSPF协议用链路状态来评估路由,可用于规模很大的网络。

OSPF可通过区域划分网络,对于规模较小的网络一般只设置一个区域0,对于规模较大的网络,可划分多个区域,其中区域0是必不可少的,它用于连接其它各区域。

OSPF协议采用组播方式进行OSPF包交换,组播地址为224.0.0.5(全部OSPF路由器)和224.0.06(指定路由器)。

OSPF协议的管理距离是110,低于RIP协议的120,所以如果设备同时运行OSPF协议和RIP协议,则OSPF协议产生的路由优先级高。

三、实验设备:

计算机、二层交换机、路由器

四、实验拓扑图

 

五、实验过程:

  1 1)三层交换机的基本配置
  2 
  3 Switch(config)#vlan 10
  4 Switch(config-vlan)
  5 Switch(config-vlan)#
  6 Switch(config-vlan)#end
  7 Switch#configure terminal
  8 Enter configuration commands, one per line. End with CNTL/Z.
  9 Switch(config)#interface FastEthernet0/1
 10 Switch(config-if)#
 11 %SYS-5-CONFIG_I: Configured from console by console
 12  
 13 Switch(config-if)#exit
 14 Switch(config)#iterface FastEthernet0/1
 15 
 16 Switch(config-if)#
 17 Switch(config-if)#
 18 Switch(config-if)#switchport access vlan 10
 19 Switch(config-if)#exit
 20 Switch(config)#vlan 50
 21 Switch#configure terminal
 22 Enter configuration commands, one per line. End with CNTL/Z.
 23 Switch(config)#interface FastEthernet0/1
 24 Switch(config-if)#
 25 %SYS-5-CONFIG_I: Configured from console by console
 26  
 27 Switch(config-if)#exit
 28 Switch(config)#interface FastEthernet0/2
 29 Switch(config-if)#switchport access vlan 50
 30 Switch(config-if)#exit
 31 Switch(config)#interface vlan 10
 32 Switch(config-if)#
 33 %LINK-5-CHANGED: Interface Vlan10, changed state to up
 34  
 35 Switch(config-if)#ip address 192.168.81.2 255.255.255.0
 36 Switch(config-if)#exit
 37 Switch(config)#interface vlan 50
 38 Switch(config-if)#
 39 %LINK-5-CHANGED: Interface Vlan50, changed state to up
 40  
 41 %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan50, changed state to up
 42  
 43 Switch(config-if)#ip address 192.168.85.1  255.255.255.0
 44 Switch(config-if)#no shutdown
 45 
 46  
 47 
 48 验证测试:
 49 
 50 
 51 Switch#show ip interface
 52 FastEthernet0/1 is down, line protocol is down
 53 Internet protocol processing disabled
 54 FastEthernet0/2 is up, line protocol is up
 55 Internet protocol processing disabled
 56 FastEthernet0/3 is down, line protocol is down
 57 Internet protocol processing disabled
 58 FastEthernet0/4 is down, line protocol is dow
 59 Internet protocol processing disabled
 60 FastEthernet0/5 is down, line protocol is down
 61 Internet protocol processing disabled
 62 FastEthernet0/6 is down, line protocol is down
 63 Internet protocol processing disabled
 64 FastEthernet0/7 is down, line protocol is down
 65 Internet protocol processing disabled
 66 FastEthernet0/8 is down, line protocol is dow
 67 Internet protocol processing disabled
 68 FastEthernet0/9 is down, line protocol is down
 69 Internet protocol processing disabled
 70 FastEthernet0/10 is down, line protocol is down
 71 Internet protocol processing disabled
 72 FastEthernet0/11 is down, line protocol is down
 73 Internet protocol processing disabled
 74 --More--
 75 2) 路由器基本配置
 76 
 77 在路由器A上配置端口IP
 78 
 79 Router>enable
 80 Router#
 81 Router#configure terminal
 82 Enter configuration commands, one per line. End with CNTL/Z.
 83 Router(config)#interface FastEthernet0/0
 84 Router(config-if)#ip address 192.168.81.1 255.255.255.0
 85 Router(config-if)#no shutdown
 86  
 87 Router(config-if)#
 88 %LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
 89  
 90 %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
 91  
 92 Router(config-if)#interface serial 0/3/0
 93 Router(config-if)#ip address 172.16.2.1 255.255.255.0
 94 Router(config-if)#Clock rate 64000
 95 Router(config-if)#no shutdown
 96  
 97 在路由器B上配置端口IP
 98 Router(config)#interface Serial0/3/0
 99 Router(config-if)#ip address 192.168.82.2 255.255.255.0
100 Router(config-if)#
101 Router(config-if)#exit
102 Router(config)#interface FastEthernet0/0
103 Router(config-if)#ip address 192.168.83.1 255.255.255.0
104 Router(config-if)#ip address 192.168.83.1 255.255.255.0
105 Router(config-if)#
106 Router(config-if)#exit
107 
108 验证测试:验证路由器接口的配置和状态
109 
110 Router#show ip interface brief
111 Interface IP-Address OK? Method Status Protoco
112 FastEthernet0/0 192.168.81.1 YES manual up up
113 FastEthernet0/1 unassigned YES unset administratively down down
114 Serial0/3/0 172.16.2.1 YES manual up up
115 Serial0/3/1 unassigned YES unset administratively down down
116 Vlan1 unassigned YES unset administratively down down
117  
118  
119 Router#show ip interface brief
120 Interface IP-Address OK? Method Status Protocol
121 FastEthernet0/0 192.168.83.1 YES manual up up
122 FastEthernet0/1 unassigned YES manual administratively down down
123 Serial0/3/0 192.168.82.2 YES manual up up
124 Serial0/3/1 unassigned YES manual administratively down down
125 
126 Vlan1 unassigned YES unset administratively down down
127 
128 
129 2、配置RIPv2路由协议
130 
131 1)三层交换机配置RIP协议
132 
133 Switch>enable
134 Switch#config
135 Configuring from terminal, memory, or network [terminal]?
136 Enter configuration commands, one per line. End with CNTL/Z.
137 Switch(config)#router rip
138 IP routing not enabled
139 Switch(config)#ip routing
140 Switch(config)#router rip
141 Switch(config-router)#network 192.168.81.0
142 Switch(config-router)#network 172.16.5.0
143 Switch(config-router)#version 2
144 Switch(config-router)#
145  
146 
147 2)RA配置RIP v2协议
148 Router(config)#router rip
149 Router(config-router)#network 192.168.81.0
150 Router(config-router)#network 192.168.82.0
151 Router(config-router)#version 2
152 Router(config-router)#no auto-summary
153 Router(config-router)#
154 
155 3)RB配置RIP v2协议
156 Router(config)#router rip
157 Router(config-router)#network 192.168.82.0
158 Router(config-router)#network 192.168.83.0
159 Router(config-router)#version 2
160 Router(config-router)#no auto-summary
161 
162 3、验证三台路由设备的路由表,查看是否自动学习了其他网段的路由信息。
163 
164 Switch#show ip route
165 Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
166 D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
167 N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
168 E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
169 i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
170 * - candidate default, U - per-user static route, o - ODR
171 P - periodic downloaded static route
172 Gateway of last resort is not set
173 
174  172.16.0.0/24 is subnetted, 4 subnets
175 C 192.168.81.0 is directly connected, Vlan10
176 R 192.168.82.0 [120/1] via 192.168.81.1, 00:00:21, Vlan10
177 R 192.168.83.0 [120/2] via 192.168.81.1, 00:00:21, Vlan10
178 C 172.16.5.0 is directly connected, Vlan50
179 
180  
181 Router#show ip route
182 Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
183 D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
184 N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
185 E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
186 i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
187 * - candidate default, U - per-user static route, o - ODR
188 P - periodic downloaded static route
189  
190 Gateway of last resort is not set
191 
192 172.16.0.0/16 is variably subnetted, 6 subnets, 2 masks
193 C 192.168.81.0/24 is directly connected, FastEthernet0/0
194 L 192.168.81.1/32 is directly connected, FastEthernet0/0
195 C 192.168.82.0/24 is directly connected, Serial0/3/0
196 L 172.16.2.1/32 is directly connected, Serial0/3/0
197 R 192.168.83.0/24 [120/1] via 192.168.82.2, 00:00:15, Serial0/3/0
198 R 172.16.5.0/24 [120/1] via 192.168.81.2, 00:00:03, FastEthernet0/0
199  
200  
201 Router#show ip route
202 Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
203 D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
204 N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
205 E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
206 i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
207 * - candidate default, U - per-user static route, o - ODR
208 P - periodic downloaded static route
209 Gateway of last resort is not set
210 172.16.0.0/16 is variably subnetted, 6 subnets, 2 masks
211 R 192.168.81.0/24 [120/1] via 172.16.2.1, 00:00:27, Serial0/3/0
212 C 192.168.82.0/24 is directly connected, Serial0/3/0
213 L 192.168.82.2/32 is directly connected, Serial0/3/0
214 C 192.168.83.0/24 is directly connected, FastEthernet0/0
215 L 192.168.83.1/32 is directly connected, FastEthernet0/0
216 R 172.16.5.0/24 [120/2] via 172.16.2.1, 00:00:27, Serial0/3/0
217 
218 4、配置OSPF路由协议
219 三层交换机
220 Switch#config
221 Configuring from terminal, memory, or network [terminal]?
222 Enter configuration commands, one per line. End with CNTL/Z.
223 Switch(config)#router ospf 1
224 Switch(config-router)#network 172.16.5.0 0.0.0.255 area 0
225 Switch(config-router)#network 192.168.81.0 0.0.0.0 area 0
226 
227 路由器RA
228 Router#config
229 Configuring from terminal, memory, or network [terminal]?
230 Enter configuration commands, one per line. End with CNTL/Z.
231 Router(config)#router ospf 1
232 Router(config-router)#network 192.168.81.0 0.0.0.255 area 0
233 Router(config-router)#network 192.168.82.0 0.0.0.255 area 0
234 Router(config-router)#end
235 
236 路由器RB
237 Router#config
238 Configuring from terminal, memory, or network [terminal]?
239 Enter configuration commands, one per line. End with CNTL/Z.
240 Router(config)#router ospf 1
241 Router(config-router)#network 192.168.82.0 0.0.0.255 area 0
242 Router(config-router)#netwo
243 01:06:57: %OSPF-5-ADJCHG: Process 1, Nbr 172.16.2.1 on Serial0/3/0 from LOADING to FULL, Loading Done
244 % Incomplete command.
245 Router(config-router)#network 192.168.83.0 0.0.0.255 area 0
246 Router(config-router)#end