计网:实验二 路由器动态路由的配置方法
一、实验目的:
1.理解静态路由和动态路由的工作原理;
2.学习并掌握静态路由的配置;
3.学习并掌握动态路由协议RIP的配置;
4.进一步学习路由器的配置命令并使用Ping命令进行测试。
二、实验原理:
静态路由:在拓扑结构简单的网络中,网管员通过手工的方式配置本路由器未知网段的路由信息,从而实现不同网段之间的连接。
三、实验设备:
计算机、二层交换机、路由器
四、实验拓扑图:
静态路由
动态路由
五、实验过程:
静态路由
1. 为R2的F1/0和F1/1端口配置IP并开启
Router#config
Configuring from terminal, memory, or network [terminal]?
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#hostname R2
R2(config)#interface fastethernet0/0
R2(config-if)#ip address 192.168.1.1 255.255.255.0
R2(config-if)#no shutdown
R2(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
R2(config-if)#exit
R2(config)#Enter configuration commands, one per line. End with CNTL/Z.
R2(config)#
R2(config)#interface FastEthernet0/1
R2(config-if)#ip address 192.168.2.1 255.255.255.0
R2(config-if)#ip address 192.168.2.1 255.255.255.0
R2(config-if)#exit
R2(config)#exit
R2#
验证测试:验证路由器R2各端口的IP配置和端口开启情况
R2#show ip interface brief
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 192.168.1.1 YES manual up up
FastEthernet0/1 192.168.2.1 YES manual administratively down down
Serial0/3/0 unassigned YES manual administratively down down
Serial0/3/1 unassigned YES unset administratively down down
Vlan1 unassigned YES unset administratively down down
设置R2的路由信息
R2#config
Configuring from terminal, memory, or network [terminal]?
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)#ip route 192.168.3.0 255.255.255.0 192.168.2.2
R2(config)#exit
验证测试:验证路由器R2路由表配置成功
R2#show ip route
Codes: L - local, 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, 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
192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.1.0/24 is directly connected, FastEthernet0/0
L 192.168.1.1/32 is directly connected, FastEthernet0/0
2、为R3的F1/0和F1/1端口配置IP并开启
Router#config
Configuring from terminal, memory, or network [terminal]?
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#hostname R3
R3(config)#Enter configuration commands, one per line. End with CNTL/Z.
R3(config)#
R3(config)#interface FastEthernet0/0
R3(config-if)#ip address 192.168.3.2 255.255.255.0
R3(config-if)#
R3(config-if)#exit
R3(config)#interface FastEthernet0/1
R3(config-if)#ip address 192.168.2.2 255.255.255.0
验证测试:验证路由器R3各端口的IP配置和端口开启情况
R3#show ip interface brief
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 192.168.3.2 YES manual up up
FastEthernet0/1 192.168.2.2 YES manual administratively down down
Serial0/3/0 unassigned YES manual administratively down down
Serial0/3/1 unassigned YES unset administratively down down
Vlan1 unassigned YES unset administratively down down
设置R3的路由信息
R3#config
Configuring from terminal, memory, or network [terminal]?
Enter configuration commands, one per line. End with CNTL/Z.
R3(config)#ip route 192.168.1.0 255.255.255.0 192.168.2.1
R3(config)#exit
验证测试:验证路由器R3路由表配置成功
R3#show ip route
Codes: L - local, 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, 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
动态路由
1)三层交换机的基本配置
Switch(config)#vlan 10
Switch(config-vlan)#
Switch(config-vlan)#
Switch(config-vlan)#end
Switch#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#interface FastEthernet0/1
Switch(config-if)#
%SYS-5-CONFIG_I: Configured from console by console
Switch(config-if)#exit
Switch(config)#interface FastEthernet0/1
Switch(config-if)#
Switch(config-if)#
Switch(config-if)#switchport access vlan 10
Switch(config-if)#exit
Switch(config)#vlan 50
Switch#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#interface FastEthernet0/1
Switch(config-if)#
%SYS-5-CONFIG_I: Configured from console by console
Switch(config-if)#exit
Switch(config)#interface FastEthernet0/2
Switch(config-if)#switchport access vlan 50
Switch(config-if)#exit
Switch(config)#interface vlan 10
Switch(config-if)#
%LINK-5-CHANGED: Interface Vlan10, changed state to up
Switch(config-if)#ip address 172.16.1.2 255.255.255.0
Switch(config-if)#exit
Switch(config)#interface vlan 50
Switch(config-if)#
%LINK-5-CHANGED: Interface Vlan50, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan50, changed state to up
Switch(config-if)#ip address 172.16.5.1 255.255.255.0
Switch(config-if)#no shutdown
验证测试:
Switch#show ip interface
FastEthernet0/1 is down, line protocol is down
Internet protocol processing disabled
FastEthernet0/2 is up, line protocol is up
Internet protocol processing disabled
FastEthernet0/3 is down, line protocol is down
Internet protocol processing disabled
FastEthernet0/4 is down, line protocol is down
Internet protocol processing disabled
FastEthernet0/5 is down, line protocol is down
Internet protocol processing disabled
FastEthernet0/6 is down, line protocol is down
Internet protocol processing disabled
FastEthernet0/7 is down, line protocol is down
Internet protocol processing disabled
FastEthernet0/8 is down, line protocol is down
Internet protocol processing disabled
FastEthernet0/9 is down, line protocol is down
Internet protocol processing disabled
FastEthernet0/10 is down, line protocol is down
Internet protocol processing disabled
FastEthernet0/11 is down, line protocol is down
Internet protocol processing disabled
--More--
2) 路由器基本配置
在路由器A上配置端口IP
Router>enable
Router#
Router#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#interface FastEthernet0/0
Router(config-if)#ip address 172.16.1.1 255.255.255.0
Router(config-if)#no shutdown
Router(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
Router(config-if)#interface serial 0/3/0
Router(config-if)#ip address 172.16.2.1 255.255.255.0
Router(config-if)#Clock rate 64000
Router(config-if)#no shutdown
在路由器B上配置端口IP
Router(config)#interface Serial0/3/0
Router(config-if)#ip address 172.16.2.2 255.255.255.0
Router(config-if)#
Router(config-if)#exit
Router(config)#interface FastEthernet0/0
Router(config-if)#ip address 172.16.3.1 255.255.255.0
Router(config-if)#ip address 172.16.3.1 255.255.255.0
Router(config-if)#
Router(config-if)#exit
验证测试:验证路由器接口的配置和状态
Router#show ip interface brief
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 172.16.1.1 YES manual up up
FastEthernet0/1 unassigned YES unset administratively down down
Serial0/3/0 172.16.2.1 YES manual up up
Serial0/3/1 unassigned YES unset administratively down down
Vlan1 unassigned YES unset administratively down down
Router#show ip interface brief
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 172.16.3.1 YES manual up up
FastEthernet0/1 unassigned YES manual administratively down down
Serial0/3/0 172.16.2.2 YES manual up up
Serial0/3/1 unassigned YES manual administratively down down
Vlan1 unassigned YES unset administratively down down
2、配置RIPv2路由协议
1)三层交换机配置RIP协议
Switch>enable
Switch#config
Configuring from terminal, memory, or network [terminal]?
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#router rip
IP routing not enabled
Switch(config)#ip routing
Switch(config)#router rip
Switch(config-router)#network 172.16.1.0
Switch(config-router)#network 172.16.5.0
Switch(config-router)#version 2
Switch(config-router)#
2)RA配置RIP v2协议
Router(config)#router rip
Router(config-router)#network 172.16.1.0
Router(config-router)#network 172.16.2.0
Router(config-router)#version 2
Router(config-router)#no auto-summary
Router(config-router)#
3)RB配置RIP v2协议
Router(config)#router rip
Router(config-router)#network 172.16.2.0
Router(config-router)#network 172.16.3.0
Router(config-router)#version 2
Router(config-router)#no auto-summary
3、验证三台路由设备的路由表,查看是否自动学习了其他网段的路由信息。
Switch#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
172.16.0.0/24 is subnetted, 4 subnets
C 172.16.1.0 is directly connected, Vlan10
R 172.16.2.0 [120/1] via 172.16.1.1, 00:00:21, Vlan10
R 172.16.3.0 [120/2] via 172.16.1.1, 00:00:21, Vlan10
C 172.16.5.0 is directly connected, Vlan50
Router#show ip route
Codes: L - local, 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, 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
172.16.0.0/16 is variably subnetted, 6 subnets, 2 masks
C 172.16.1.0/24 is directly connected, FastEthernet0/0
L 172.16.1.1/32 is directly connected, FastEthernet0/0
C 172.16.2.0/24 is directly connected, Serial0/3/0
L 172.16.2.1/32 is directly connected, Serial0/3/0
R 172.16.3.0/24 [120/1] via 172.16.2.2, 00:00:15, Serial0/3/0
R 172.16.5.0/24 [120/1] via 172.16.1.2, 00:00:03, FastEthernet0/0
Router#show ip route
Codes: L - local, 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, 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
172.16.0.0/16 is variably subnetted, 6 subnets, 2 masks
R 172.16.1.0/24 [120/1] via 172.16.2.1, 00:00:27, Serial0/3/0
C 172.16.2.0/24 is directly connected, Serial0/3/0
L 172.16.2.2/32 is directly connected, Serial0/3/0
C 172.16.3.0/24 is directly connected, FastEthernet0/0
L 172.16.3.1/32 is directly connected, FastEthernet0/0
R 172.16.5.0/24 [120/2] via 172.16.2.1, 00:00:27, Serial0/3/0
4、配置OSPF路由协议
三层交换机
Switch#config
Configuring from terminal, memory, or network [terminal]?
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#router ospf 1
Switch(config-router)#network 172.16.5.0 0.0.0.255 area 0
Switch(config-router)#network 172.16.1.0 0.0.0.0 area 0
路由器RA
Router#config
Configuring from terminal, memory, or network [terminal]?
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#router ospf 1
Router(config-router)#network 172.16.1.0 0.0.0.255 area 0
Router(config-router)#network 172.16.2.0 0.0.0.255 area 0
Router(config-router)#end
路由器RB
Router#config
Configuring from terminal, memory, or network [terminal]?
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#router ospf 1
Router(config-router)#network 172.16.2.0 0.0.0.255 area 0
Router(config-router)#netwo
01:06:57: %OSPF-5-ADJCHG: Process 1, Nbr 172.16.2.1 on Serial0/3/0 from LOADING to FULL, Loading Done
% Incomplete command.
Router(config-router)#network 172.16.3.0 0.0.0.255 area 0
Router(config-router)#end
5、测试网络的连通性