实验 VLAN配置2
一.实训目的:
1.掌握VLAN的端口配置方法;
2.掌握多交换机的Trunk配置方法。
二. 基本概念:
图1 按端口划分VLAN
1、Trunk技术
Trunk称为中继技术,用它可以解决用多台交换机设置VLAN时,存在的VLAN跨多个交换机的问题。比如某个VLAN既使用交换机1的若干端口,也使用交换机2的若干端口,这时交换机就之间必须使用Trunk连接。
在Trunk中,交换机必须能识别每个数据报来源于哪个VLAN,这样交换机才能够决定是否把这个数据报转发到其它交换机
图2 交换机的Trunk连接
2、VTP
协议
离婚协议模板下载合伙人协议 下载渠道分销协议免费下载敬业协议下载授课协议下载
在使用了Trunk的交换机系统中,利用VTP协议可以对VLAN进行集中管理,这样可以提高管理效率。
VTP采用客户/服务器模式(C/S),把一台交换机设置为VTP服务器,其它交换机设置成VTP客户机。所有VLAN都在服务器上定义,在客户机上只是划分端口。
VTP包含了域的概念,所有处于同一个域内的交换机才构成一个管理体系。整个VTP域还可添加口令认证功能,提高了VTP域的安全性。
三、实验内容:
本实验要求掌握的CLI命令:
模式
命令
功能
(config)#
vlan no name VLAN-Name
定义一个VLAN
(config)#
interface FastEthernet port
指定一个快速以太网端口
(config)#
vtp server
设置为VTP服务器
(config)#
vtp client
设置为VTP客户机
(config)#
vtp domain name
设置VTP域名
(config)#
vtp pruning disable/enable
关闭/打开VTP整理功能
(config-if)#
trunk on
启动trunk
#
show vlan
查看VLAN配置
#
show vlan-membership
查看VLAN端口配置
#
show trunk port
查看trunk端口状态
#
show vtp
查看VTP配置
1、配置VLAN
配置VLAN分为2步:1、建立一个新的VLAN;2、指定新的VLAN所包含的端口号。
说明:在默认情况下交换机的所有端口都在一个VLAN中,所以1号VLAN不需要定义,只需要定义和划分其它VLAN即可。
例:
图3
①定义VLAN2、VLAN3:
(config)# vlan 2 name VLAN2
(config)# vlan 3 name VLAN3
②为VLAN2分配端口e0/6~e0/8:
(config)# interface e 0/6
(config-if)# vlan-membership static 2
(config-if)# interface e 0/7
(config-if)# vlan-membership static 2
(config-if)# interface e 0/8
(config-if)# vlan-membership static 2
③为VLAN3分配端口e0/9~e0/12:
(config-if)# interface e 0/9
(config-if)# vlan-membership static 3
(config-if)# interface e 0/10
(config-if)# vlan-membership static 3
(config-if)# interface e 0/11
(config-if)# vlan-membership static 3
(config-if)# interface e 0/12
(config-if)# vlan-membership static 3
所有未分配的端口属于VLAN1。定义完成后,退回到特权模式,可以用show vlan-membership命令查看VLAN的配置情况。
2、配置Trunk(两种方法配置trunk,1、直接配置 2、使用vtp协议)
例:
图4
选择Switch1作为VTP服务器,Switch2作为VTP客户机。
①配置Switch1:
把Switch1定义为VTP服务器,并在其上定义VLAN:
(config)# vtp server
(config)# vtp domain netfield
(config)# vtp pruning enable
(config)# vlan 2 name VLAN2
(config)# vlan 3 name VLAN3
(config)# vlan 4 name VLAN4
为Switch1划分VLAN端口:
(config)# interface e 0/6
(config-if)# vlan-membership static 2
(config-if)# interface e 0/7
(config-if)# vlan-membership static 2
(config-if)# interface e 0/8
(config-if)# vlan-membership static 2
(config-if)# interface e 0/9
(config-if)# vlan-membership static 3
(config-if)# interface e 0/10
(config-if)# vlan-membership static 3
(config-if)# interface e 0/11
(config-if)# vlan-membership static 3
(config-if)# interface e 0/12
(config-if)# vlan-membership static 3
配置Switch1的Trunk端口fa 0/26:
(config-if)# interface fa 0/26
(config-if)# trunk on
②配置Switch2:
把Switch2定义为VTP客户机,它不需定义VLAN,只需划分端口:
(config)# vtp client
为Switch2划分VLAN端口:
(config)# interface e 0/1
(config-if)# vlan-membership static 2
(config-if)# interface e 0/2
(config-if)# vlan-membership static 2
(config-if)# interface e 0/3
(config-if)# vlan-membership static 2
(config-if)# interface e 0/4
(config-if)# vlan-membership static 2
(config-if)# interface e 0/5
(config-if)# vlan-membership static 4
(config-if)# interface e 0/6
(config-if)# vlan-membership static 4
(config-if)# interface e 0/7
(config-if)# vlan-membership static 4
(config-if)# interface e 0/8
(config-if)# vlan-membership static 4
(config-if)# interface e 0/9
(config-if)# vlan-membership static 4
配置Switch2的Trunk端口fa 0/26:
(config-if)# interface fa 0/26
(config-if)# trunk on
说明:
未配置的端口都默认属于VLAN1,所以VLAN1不用设置。
命令vtp domain netfield中,netfield是域名,vtp pruning enable是将整理功能打开,由于Switch2中没有VLAN3,因此VTP从Switch2中整理掉VLAN3,Switch1收到的VLAN3的广播不会转发到VLAN2。
配置完成后,可以退回到特权方式下,用show命令查看配置结果:
# show vtp 查看VTP配置;
# show trunk a 查看trunk配置,a表示端口0/26;
# show vlan 查看VLAN配置;
# show vlan-membership 查看VLAN端口;
四、实验要求:
按照图6所示制作拓扑图
图6
Switch1和Switch2之间用fa0/26端口连接,PC1连接在Switch1的e0/1端口,PC2连接在Switch1的e0/6端口,PC3连接在Switch2的e0/1端口,PC4连接在Switch2的e0/5端口,PC5连接在Switch2的e0/10端口。
①配置PC机
PC1~PC5的IP地址为192.168.0.51~192.168.0.55,子网掩码均为255.255.255.0。
用ping命令检查它们能否通讯。
②配置交换机
设置Switch1的名字为Switch1,IP地址为192.168.0.11,子网掩码为255.255.255.0。
设置Switch2的名字为Switch2,IP地址为192.168.0.12,子网掩码为255.255.255.0。
按图4所示配置VTP、trunk和VLAN。
③检查结果
用show命令查看配置情况,用ping命令检查PC机间的通讯情况,理解其中的原因。
五、练习题:
按照下图的拓扑结构连接交换机,对三台交换机进行配置,在每个VLAN中接上计算机,检查它们的通信情况。
图7
Switch1:VLAN2:0/2、0/3、0/5,VLAN3:0/11,0/12,其余为VLAN1。
Switch2:VLAN2:0/5~0/7,VLAN3:0/8、0/9,VLAN4:0/10~0/12,其余为VLAN1。
Switch3:VLAN4:0/11、0/12,其余为VLAN1。
子网掩码均为255.255.255.0,默认网关均为192.168.0.1。