实验二十七、使用多层交换机实现二层交换机 VLAN 之间的路由

一、 实验目的

1、理解多层交换机的路由原理

2、 了解多层交换机在实际网络中的常用配置

3、 回顾二层交换机 VLAN 的划分方法

4、进一步理解 802.1Q 的原理和使用方法

二、 应用环境

二层交换机属于接入层交换机,在二层交换机上根据连接用户的不同,划分了不同

VLAN,有时候会出现同一个 VLAN 处于不同的交换机上。这些二层交换机被一台三层交换机所汇聚。因此我们需要实现多交换机的跨交换机VLAN 通信,也需要实现VLAN 间的通信。因此出现本实验所要演示的功能。

三、 实验设备

1、DCRS-7604(或 6804 或 5526S)交换机1 台

2、DCS-3926S 交换机 1-2 台

3、PC机 2-4 台

4、Console 线1-3 根

5、直通网线若干

四、 实验拓扑

五、 实验要求

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

100 1~8

200 9~16

Trunk 口 24

在交换机C 上也划分两个基于端口的VLAN:VLAN100,VLAN200 。把端口1 和端口

2 都设置成Trunk 口。

VLAN IP Mask

100 192.168.10.1 255.255.255.0

200 192.168.20.1 255.255.255.0

Trunk 口 1/1 和 1/2

交换机A 的24 口连接交换机C 的1 口,交换机B 的24 口连接交换机C 的2 口。

PC1-PC4 的网络设置为:

设备 IP 地址 gateway Mask

PC1 192.168.10.11 192.168.10.1 255.255.255.0

PC2 192.168.20.22 192.168.20.1 255.255.255.0

PC3 192.168.10.33 192.168.10.1 255.255.255.0

PC4 192.168.20.44 192.168.20.1 255.255.255.0

验证:

1、不给PC 设置网关:

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

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

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

2、给PC 设置网关:

PC1、PC3 和PC2、PC4 接在不同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)#

交换机 C:

DCRS-7604#config

DCRS-7604(Config)#

DCRS-7604(Config)#hostname switchC

switchC(Config)#interface vlan 1

switchC(Config-If-Vlan1)#ip address 192.168.1.13 255.255.255.0

switchC(Config-If-Vlan1)#no shutdown

switchC(Config-If-Vlan1)#exit

switchC(Config)#exit

switchC#

第三步:在交换机中创建 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

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

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

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(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

交换机 C:

switchC(Config)#vlan 100

switchC(Config-Vlan100)#exit

switchC(Config)#vlan 200

switchC(Config-Vlan200)#exit

switchC(Config)#interface ethernet 1/1-2 switchC(Config-Port-Range)#switchport mode trunk

Set the port Ethernet1/1 mode TRUNK successfully

Set the port Ethernet1/2 mode TRUNK successfully

switchC(Config-Port-Range)#switchport trunk allowed vlan all

set the port Ethernet1/1 allowed vlan successfully

set the port Ethernet1/2 allowed vlan successfully

switchC(Config-Port-Range)#exit

switchC(Config)#exit

验证配置:

switchC#show vlan

VLAN Name Type Media Ports

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

1 default Static ENET Ethernet1/1(T) Ethernet1/2(T)

Ethernet1/3 Ethernet1/4

Ethernet1/5 Ethernet1/6

Ethernet1/7 Ethernet1/8

Ethernet1/9 Ethernet1/10

Ethernet1/11 Ethernet1/12

Ethernet1/13 Ethernet1/14

Ethernet1/15 Ethernet1/16

Ethernet1/17 Ethernet1/18

Ethernet1/19 Ethernet1/20

Ethernet1/21 Ethernet1/22

Ethernet1/23 Ethernet1/24

Ethernet1/25 Ethernet1/26

Ethernet1/27 Ethernet1/28

100 VLAN0100 Static ENET Ethernet1/1(T) Ethernet1/2(T)

200 VLAN0200 Static ENET Ethernet1/1(T) Ethernet1/2(T)

switchC#

第五步:交换机 C 添加 vlan 地址。

switchC(Config)#interface vlan 100

switchC(Config-If-Vlan100)#ip address 192.168.10.1 255.255.255.0

switchC(Config-If-Vlan100)#no shut

switchC(Config-If-Vlan100)#exit

switchC(Config)#interface vlan 200

switchC(Config-If-Vlan200)#no shutdown

switchC(Config-If-Vlan200)#exit

switchC(Config)#

验证配置:

switch#show ip route

Total route items is 3, the matched route items is 3

Codes: C - connected, S - static, R - RIP derived, O - OSPF derived

A - OSPF ASE, B - BGP derived, D - DVMRP derived Destination Mask Nexthop Interface Preference

C 192.168.1.0 255.255.255.0 0.0.0.0 Vlan1 0

C 192.168.10.0 255.255.255.0 0.0.0.0 Vlan100 0

C 192.168.20.0 255.255.255.0 0.0.0.0 Vlan200 0

switch#

第七步:验证实验。

1、PC 不配置网关,互相 ping,查看结果;

2、PC 配置网关,互相 ping,查看结果;