实验十五、跨交换机相同VLAN 间通讯

一、 实验目的

1、了解 IEEE802.1q 的实现方法,掌握跨二层交换机相同 VLAN 间通信的调试方法;

2、 了解交换机接口的 trunk 模式和access 模式;

3、 了解交换机的 tagged 端口和 untagged 端口的区别。

二、 应用环境

教学楼有两层,分别是一年级、二年级,每个楼层都有一台交换机满足老师上网需求;

每个年级都有语文教研组和数学教研组;两个年级的语文教研组的计算机可以互相访问;两

个年级的数学教研组的计算机可以互相访问;语文教研组和数学教研组之间不可以自由访

问;

通过划分VLAN 使得语文教研组和数学教研组之间不可以自由访问;使用 802.1Q 进行

跨交换机的VLAN 。

三、 实验设备

1、DCS-3926S 交换机 2 台

2、PC机 2 台

3、Console 线1根

4、直通网线 2根

四、 实验拓扑

clip_image002

五、 实验要求

在交换机A 和交换机B 上分别划分两个基于端口的VLAN:VLAN100,VLAN200 。 VLAN 端口成员

100 1~8

200 9~16

Trunk 口 24

使得交换机之间 VLAN100 的成员能够互相访问,VLAN200 的成员能够互相访问;

VLAN100 和VLAN200 成员之间不能互相访问。

PC1 和PC2 的网络设置为:

设备 IP 地址 Mask

交换机A 192.168.1.11 255.255.255.0

交换机B 192.168.1.12 255.255.255.0

PC1 192.168.1.101 255.255.255.0

PC2 192.168.1.102 255.255.255.0

PC1、PC2 分别接在不同交换机VLAN100 的成员端口 1~8 上,两台 PC 互相可以ping

通;PC1、PC2 分别接在不同交换机VLAN 的成员端口9~16 上,两台PC 互相可以ping 通;

PC1 和PC2 接在不同VLAN 的成员端口上则互相ping 不通。

若实验结果和理论相符,则本实验完成。

六、 实验步骤

第一步:交换机恢复出厂设置

switch#set default

switch#write

switch#reload

第二步:给交换机设置标示符和管理 IP。

交换机 A:

switch(Config)#hostname switchA

switchA(Config)#interface vlan 1

switchA(Config-If-Vlan1)#ip address 192.168.1.11 255.255.255.0

switchA(Config-If-Vlan1)#no shutdown

switchA(Config-If-Vlan1)#exit

switchA(Config)#

交换机 B:

switch(Config)#hostname switchB

switchB(Config)#interface vlan 1

switchB(Config-If-Vlan1)#ip address 192.168.1.12 255.255.255.0

switchB(Config-If-Vlan1)#no shutdown

switchB(Config-If-Vlan1)#exit

switchB(Config)#

第三步:在交换机中创建 vlan100 和 vlan200,并添加端口。

交换机 A:

switchA(Config)#vlan 100

switchA(Config-Vlan100)# switchA(Config-Vlan100)#switchport interface ethernet 0/0/1-8

switchA(Config-Vlan100)#exit

switchA(Config)#vlan 200

switchA(Config-Vlan200)#switchport interface ethernet 0/0/9-16

switchA(Config-Vlan200)#exit

switchA(Config)#

验证配置:

switchA#show vlan

VLAN Name Type Media Ports

---- ------------ ---------- ---------

----------------------------------------

1 default Static ENET Ethernet0/0/17 Ethernet0/0/18

Ethernet0/0/19 Ethernet0/0/20

Ethernet0/0/21 Ethernet0/0/22

Ethernet0/0/23 Ethernet0/0/24

100 VLAN0100 Static ENET Ethernet0/0/1 Ethernet0/0/2

Ethernet0/0/3 Ethernet0/0/4

Ethernet0/0/5 Ethernet0/0/6

Ethernet0/0/7 Ethernet0/0/8

200 VLAN0200 Static ENET Ethernet0/0/9 Ethernet0/0/10

Ethernet0/0/11 Ethernet0/0/12

Ethernet0/0/13 Ethernet0/0/14

Ethernet0/0/15 Ethernet0/0/16

switchA#

交换机 B:

配置与交换机 A 一样。

第四步:设置交换机 trunk 端口

交换机 A:

switchA(Config)#interface ethernet 0/0/24

switchA(Config-Ethernet0/0/24)#switchport mode trunk

Set the port Ethernet0/0/24 mode TRUNK successfully

switchA(Config-Ethernet0/0/24)#switchport trunk allowed vlan all

set the port Ethernet0/0/24 allowed vlan successfully

switchA(Config-Ethernet0/0/24)#exit

switchA(Config)#

验证配置:

switchA#show vlan

VLAN Name Type Media Ports

---- ------------ ---------- ---------

----------------------------------------

Ethernet0/0/21 Ethernet0/0/22

Ethernet0/0/23

Ethernet0/0/24(T)

100 VLAN0100 Static ENET Ethernet0/0/1 Ethernet0/0/2

Ethernet0/0/3 Ethernet0/0/4

Ethernet0/0/5 Ethernet0/0/6

Ethernet0/0/7 Ethernet0/0/8

Ethernet0/0/24(T)

200 VLAN0200 Static ENET Ethernet0/0/9 Ethernet0/0/10

Ethernet0/0/11 Ethernet0/0/12

Ethernet0/0/13 Ethernet0/0/14

Ethernet0/0/15 Ethernet0/0/16

Ethernet0/0/24(T)

switchA#

24口已经出现在vlan1、vlan100和vlan200中,并且24口不是一个普通端口,是tagged

端口。

交换机 B:

配置同交换机 A

第五步:验证实验。

交换机 Aping 交换机B:

switchA#ping 192.168.1.12

Type ^c to abort.

Sending 5 56-byte ICMP Echos to 192.168.1.12, timeout is 2 seconds.

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms

switchA#

表明交换机之前的 trunk 链路已经成功建立。

按下表验证,PC1 插在交换机 A 上,PC2 插在交换机 B 上:

PC1 位置 PC2 位置 动作 结果

1-8 端口 PC1 ping 交换机 B 不通

9-16 端口 PC1 ping 交换机 B 不通

17-24 端口 PC1 ping 交换机 B 通

1-8 端口 1-8 端口 PC1 ping PC2 通

1-8 端口 9-16 端口 PC1 ping PC2 不通

1 default Static ENET Ethernet0/0/17 Ethernet0/0/18

Ethernet0/0/19 Ethernet0/0/20