实验名称:简单的路由交换实验
|
|
实验目的
|
熟练掌握
Vlan
的划分
,
中继链路的建立以及静态路由的配置
|
试验要求
|
1.
pc1
属于
VLAN1;pc2
属于
VLAN2; pc3
属于
VLAN3;pc4
属于
VLAN4
2.
pc1-pc5
都能够联通
3.
子网划分
192.168.1.0/24
划分
4
子网
,
每个
VLAN
一个子网
|
网络拓朴图
|
请看附件!
|
所需实验设备
|
1. 2
台交换机
2. 3
台路由器
3. 5
台
PC
4. 4
个交叉线
5. 5
个直连线
|
实验描述
|
1.
交换机
1
的配置如下所示
******
初始化交换机
******
Router>
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#host sw1
sw1(config)#lin con 0
sw1(config-line)#exec-timeout 0 0
sw1(config-line)#logging synchronous
sw1(config-line)#exit
sw1(config)#no ip domain lookup
sw1(config)#exit
******
创建
VLAN******
sw1#vlan database
sw1(vlan)#vlan 2 name v2
VLAN 2 added:
Name: v2
sw1(vlan)#vlan 3
VLAN 3 added:
Name: VLAN0003
sw1(vlan)#vlan 4
VLAN 4 added:
Name: VLAN0004
sw1(vlan)#exit
APPLY completed.
Exiting....
******
将端口加入
VLAN******
sw1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
sw1(config)#interface f0/4
sw1(config-if)#description vlan2
sw1(config-if)#switchport access vlan 2
sw1(config-if)#exit
*****
设置端口为
TRUNK
并将
vlan3
和
vlan4
加入中继
*****
sw1(config)#interface f0/1
sw1(config-if)#switchport mode trunk
sw1(config-if)#switchport trunk allowed vlan add 3
sw1(config-if)#switchport trunk allowed vlan add 4
sw1(config-if)#exit
sw1(config)#interface f0/0
sw1(config-if)#switchport mode trunk
sw1(config-if)#switchport trunk allowed vlan add 3
sw1(config-if)#switchport trunk allowed vlan add 4
sw1(config-if)#end
sw1#write
2.
交换机
2
的配置如下所示
******
初始化交换机
******
Router>
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#host sw2
sw2(config)#lin con 0
sw2(config-line)#exec-timeout 0 0
sw2(config-line)#logg sync
sw2(config-line)#exit
sw2(config)#no ip domain lookup
sw2(config)#exit
******
创建
VLAN******
sw2#vlan database
sw2(vlan)#vlan 2
VLAN 2 added:
Name: VLAN0002
sw2(vlan)#vlan 3 name v3
VLAN 3 added:
Name: v3
sw2(vlan)#vlan 4 name v4
VLAN 4 added:
Name: v4
sw2(vlan)#exit
APPLY completed.
Exiting....
******
设置端口为中继模式并将
vlan2
加入中继
******
sw2#conf t
Enter configuration commands, one per line. End with CNTL/Z.
sw2(config)#interface f0/2
sw2(config-if)#description vlan3
sw2(config-if)#switchport access vlan 3
sw2(config-if)#exit
sw2(config)#interface f0/4
sw2(config-if)#description vlan4
sw2(config-if)#switchport access vlan 4
sw2(config-if)#exit
sw2(config)#interface f0/1
sw2(config-if)#switchport mode trunk
sw2(config-if)#switchport trunk allowed vlan add 2
sw2(config-if)#end
sw2#write
3.
路由器
1
的配置如下所示
****
初使化路由器
****
Router>
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#host R1
R1(config)#lin con 0
R1(config-line)#exec-time 0 0
R1(config-line)#loggin syn
R1(config-line)#exit
R1(config)#no ip domain lookup
R1(config)#exit
**********
为端口设置
IP
地址
**********
R1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#interface f0/0
R1(config-if)#ip add 10.0.0 .2 255.0.0.0
R1(config-if)#no shut
R1(config-if)#exit
R1(config)#interface f1/0
R1(config-if)#ip add 20.0.0 .1 255.0.0.0
R1(config-if)#no shut
R1(config-if)#exit
********
设置静态路由
********
R1(config)#ip route 30.0.0.0 255.0.0.0 20.0.0 .2
R1(config)#ip route 40.0.0.0 255.0.0.0 20.0.0 .2
R1(config)#ip route 192.168.1.0 255.255.255.192 20.0.0 .2
R1(config)#ip route 192.168.1.64 255.255.255.192 20.0.0 .2
R1(config)#ip route 192.168.1.128 255.255.255.192 20.0.0 .2
R1(config)#ip route 192.168.1.192 255.255.255.192 20.0.0 .2
R1(config)#exit
R1#write
4.
路由器
2
的配置如下所示
****
初使化路由器
****
Router>
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#host R2
R2(config)#lin con 0
R2(config-line)#exec-timeout 0 0
R2(config-line)#logg syn
R2(config-line)#exit
R2(config)#no ip domain lookup
R2(config)#exit
**********
设置子接口
**********
R2#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)#interface f0/0
R2(config-if)#no shut
R2(config-if)#exit
R2(config)#interface f0/0.1
R2(config-subif)#encapsulation dot1q 1
R2(config-subif)#ip add 192.168.1.1 255.255.255.192
R2(config-subif)#exit
R2(config)#interface f0/0.2
R2(config-subif)#encapsulation dot1q 2
R2(config-subif)#ip add 192.168.1.65 255.255.255.192
R2(config-subif)#exit
R2(config)#interface f0/0.3
R2(config-subif)#encapsulation dot1q 3
R2(config-subif)#ip add 192.168.1.129 255.255.255.192
R2(config-subif)#exit
R2(config)#interface f0/0.4
R2(config-subif)#encapsulation dot1q 4
R2(config-subif)#ip add 192.168.1.193 255.255.255.192
R2(config-subif)#exit
********
设置静态路由
*********
R2(config)#ip route 40.0.0.0 255.0.0.0 30.0.0.2
R2(config)#ip route 10.0.0 .0 255.0.0.0 20.0.0.1
R2(config)#exit
R2#write
5.
路由器
3
的配置如下所示
****
初使化路由器
****
Router>
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#lin con 00
Router(config-line)#exec-t 0 0
Router(config-line)#logg syn
Router(config-line)#exit
Router(config)#no ip domain lookup
Router(config)#host r3
*********
设置接口的
IP
地址
**********
r3(config)#interfac e0/0
r3(config-if)#ip add 30.0.0.2 255.0.0.0
r3(config-if)#no shut
r3(config-if)#exit
r3(config)#interfac loopback 0
r3(config-if)#ip add 40.0.0.1 255.0.0.0
r3(config-if)#exit
********
配置静态路由
*********
r3(config)#ip route 10.0.0 .0 255.0.0.0 30.0.0.1
r3(config)#ip route 20.0.0 .0 255.0.0.0 30.0.0.1
r3(config)#ip route 192.168.1.0 255.255.255.192 30.0.0.1
r3(config)#ip route 192.168.1.64 255.255.255.192 30.0.0.1
r3(config)#ip route 192.168.1.128 255.255.255.192 30.0.0.1
r3(config)#ip route 192.168.1.192 255.255.255.192 30.0.0.1
r3(config)#exit
r3#write
|
实验结果
|
交换机
sw1
接口
F0/0
的显示信息
sw1#show interface f0/0 switchport
Name: Fa0/0
Switchport: Enabled
Administrative Mode: trunk
Operational Mode: trunk
Administrative Trunking Encapsulation: dot1q
Operational Trunking Encapsulation: dot1q
Negotiation of Trunking: Disabled
Access Mode VLAN: 0 ((Inactive))
Trunking Native Mode VLAN: 1 (default)
Trunking VLANs Enabled: ALL
Trunking VLANs Active:
1-4
Priority for untagged frames: 0
Override vlan tag priority: FALSE
Voice VLAN: none
Appliance trust: none
交换机
sw1
接口
F0/1
的显示信息
sw1#show interface f0/1 switchport
Name: Fa0/1
Switchport: Enabled
Administrative Mode: trunk
Operational Mode: trunk
Administrative Trunking Encapsulation: dot1q
Operational Trunking Encapsulation: dot1q
Negotiation of Trunking: Disabled
Access Mode VLAN: 0 ((Inactive))
Trunking Native Mode VLAN: 1 (default)
Trunking VLANs Enabled: ALL
Trunking VLANs Active:
1-4
Priority for untagged frames: 0
Override vlan tag priority: FALSE
Voice VLAN: none
Appliance trust: none
交换机
sw2
接口
F0/1
的显示信息
sw2#show interfac f0/1 switchport
Name: Fa0/1
Switchport: Enabled
Administrative Mode: trunk
Operational Mode: trunk
Administrative Trunking Encapsulation: dot1q
Operational Trunking Encapsulation: dot1q
Negotiation of Trunking: Disabled
Access Mode VLAN: 0 ((Inactive))
Trunking Native Mode VLAN: 1 (default)
Trunking VLANs Enabled: ALL
Trunking VLANs Active:
1-4
Priority for untagged frames: 0
Override vlan tag priority: FALSE
Voice VLAN: none
Appliance trust: none
|
附
|
NAME IP/CIDR GATEWAY LPORT RPORT
PC1 192.168.1.8/26 192.168.1.1 10001 21002
PC2 192.168.1.68/26 192.168.1.65 10002 21004
PC3 192.168.1.138/26 192.168.1.129 10003 22002
PC4 192.168.1.198/26 192.168.1.193 10004 22004
|