实验十七、私有 VLAN实验

一、 实验目的

1、了解私有 VLAN 原理;

2、熟练掌握交换机私有 VLAN 的划分方法;

3、 了解 VLAN 和私有 VLAN 的不同。

二、 应用环境

Vlan 带给网络很好的可管理性,vlan 之间通讯必要经过三层设备路由。

案例一、如果一个实验室的交换机上划分了若干个vlan,为了安全起见,vlan 之间不需

要通讯,但是所有的 vlan 都需要访问一台公用的服务器。怎么办?增加三层设备的投资太

高了。

案例二、一个宽带小区,每家每户都有宽带入户,每个家庭的电脑不希望被其他人家的

用户所访问,要求隔离,难道需要在交换机上配置20 多个vlan 来解决?

使用私有vlan (Pvlan )是一个很好的方法。

前提:交换机支持pvlan,并非所有的交换机支持pvlan,需要提前阅读产品手册。

三、 实验设备

1、DCS-3926S 交换机 1 台

2、PC机 2 台

3、Console 线1根

4、直通网线 2根clip_image002

四、 实验拓扑

五、 实验要求

在交换机上划分VLAN:vlan100,vlan200,vlan300,vlan400 。

VLAN Vlan 类型 端口成员

100 主vlan 1~4

200 群体vlan 7~12

300 群体vlan 13~18

400 隔离vlan 19~24

PC1 和PC2 的网络设置为:

设备 IP 地址 Mask

PC1 192.168.1.101 255.255.255.0

PC2 192.168.1.102 255.255.255.0

把 PC1、PC2 接在相应的端口上进行验证:所有的端口都可以和混杂端口通信,群体vlan 内可以通信,群体vlan 间不可以通信,隔离vlan 内部不能通信。若实验结果和理论相符,则本实验完成。

六、 实验步骤

第一步:交换机全部恢复出厂设置,创建私有 vlan 的各种成员 vlan

switch(Config)#vlan 100

switch(Config-Vlan100)#private-vlan primary

Note:This will remove all the ports from vlan 100

switch(Config-Vlan100)#exit

switch(Config)#vlan 200

switch(Config-Vlan200)#private-vlan community

Note:This will remove all the ports from vlan 200

switch(Config-Vlan200)#exit

switch(Config)#vlan 300

switch(Config-Vlan300)#private-vlan community

Note:This will remove all the ports from vlan 300

switch(Config-Vlan300)#exit

switch(Config)#vlan 400

switch(Config-Vlan400)#private-vlan isolated

Note:This will remove all the ports from vlan 400

switch(Config-Vlan400)#exit

switch(Config)#

第二步:做 vlan 之间的关联。

switch(Config)#

switch(Config)#vlan 100

switch(Config-Vlan100)#

switch(Config-Vlan100)#private-vlan association 200;300;400

Set vlan 100 associated vlan successfully

switch(Config-Vlan100)#exit

switch(Config)#

验证配置:

switch#show vlan private-vlan

VLAN Name Type Asso VLAN Ports

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

---------------------------------------- 100 VLAN0100 Primary 200 300

400

200 VLAN0200 Community 100

300 VLAN0300 Community 100

400 VLAN0400 Isolate 100

switch#

第三步:添加端口

switch(Config)#vlan 100

switch(Config-Vlan100)#switchport interface ethernet 0/0/1-4

Set the port Ethernet0/0/1 access vlan 100 successfully

Set the port Ethernet0/0/2 access vlan 100 successfully

Set the port Ethernet0/0/3 access vlan 100 successfully

Set the port Ethernet0/0/4 access vlan 100 successfully

switch(Config-Vlan100)#vlan200

switch(Config-Vlan200)#switchport interface ethernet 0/0/7-12

Set the port Ethernet0/0/7 access vlan 200 successfully

Set the port Ethernet0/0/8 access vlan 200 successfully

Set the port Ethernet0/0/9 access vlan 200 successfully

Set the port Ethernet0/0/10 access vlan 200 successfully

Set the port Ethernet0/0/11 access vlan 200 successfully

Set the port Ethernet0/0/12 access vlan 200 successfully

switch(Config-Vlan200)#vlan 300

switch(Config-Vlan300)#switchport interface ethernet 0/0/13-18

Set the port Ethernet0/0/13 access vlan 300 successfully

Set the port Ethernet0/0/14 access vlan 300 successfully

Set the port Ethernet0/0/15 access vlan 300 successfully

Set the port Ethernet0/0/16 access vlan 300 successfully

Set the port Ethernet0/0/17 access vlan 300 successfully

Set the port Ethernet0/0/18 access vlan 300 successfully

switch(Config-Vlan300)#vlan 400

switch(Config-Vlan400)#switchport interface ethernet 0/0/19-24

Set the port Ethernet0/0/19 access vlan 400 successfully

Set the port Ethernet0/0/20 access vlan 400 successfully

Set the port Ethernet0/0/21 access vlan 400 successfully

Set the port Ethernet0/0/22 access vlan 400 successfully

Set the port Ethernet0/0/23 access vlan 400 successfully

Set the port Ethernet0/0/24 access vlan 400 successfully

switch(Config-Vlan400)#

验证配置:

switch#show vlan private-vlan

VLAN Name Type Asso VLAN Ports

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

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

100 VLAN0100 Primary 200 300 Ethernet0/0/1 Ethernet0/0/2 400 Ethernet0/0/3 Ethernet0/0/4

Ethernet0/0/7 Ethernet0/0/8

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/17 Ethernet0/0/18

Ethernet0/0/19 Ethernet0/0/20

Ethernet0/0/21 Ethernet0/0/22

Ethernet0/0/23 Ethernet0/0/24

200 VLAN0200 Community 100 Ethernet0/0/1 Ethernet0/0/2

Ethernet0/0/3 Ethernet0/0/4

Ethernet0/0/7 Ethernet0/0/8

Ethernet0/0/9 Ethernet0/0/10

Ethernet0/0/11 Ethernet0/0/12

300 VLAN0300 Community 100 Ethernet0/0/1 Ethernet0/0/2

Ethernet0/0/3 Ethernet0/0/4

Ethernet0/0/13 Ethernet0/0/14

Ethernet0/0/15 Ethernet0/0/16

Ethernet0/0/17 Ethernet0/0/18

400 VLAN0400 Isolate 100 Ethernet0/0/1 Ethernet0/0/2

Ethernet0/0/3 Ethernet0/0/4

第四步:。

switch(Config)#vlan 100 !进入 vlan 100

第五步:验证实验。

PC1 位置 PC2 位置 动作 表示 结果

1 端口 2-4 端口 PC1 ping PC2 主 vlan ping 主 vlan 通

1 端口 7-12 端口 PC1 ping PC2 群体 vlan ping 主 vlan 通

1 端口 13-18 端口 PC1 ping PC2 群体 vlan ping 主 vlan 通

1 端口 19-24 端口 PC1 ping PC2 隔离 vlan ping 主 vlan 通

7-12 端口 7-12 端口 PC1 ping PC2 群体 vlan 内通信 通

7-12 端口 13-18 端口 PC1 ping PC2 群体 vlan 间通信 不通

7-12 端口 19-24 端口 PC1 ping PC2 群体 vlan ping 隔离 vlan 不通

19-24 端口 19-24 端口 PC1 ping PC2 隔离 vlan ping 隔离 vlan 不通