一、實驗目的:
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、測試網絡的連通性