实验目的
通过本实验,掌握可以如下技能:
1、VLAN的创建、修改、删除
2、将交换机端口分配到某个VLAN
3、配置交换机接口Trunk模式,理解DTP协商
4、理解VTP三种模式,熟悉VTP的配置,理解VTP pruning
5、熟悉配置SVI接口
实验拓扑
94338890[6]
实验过程
(1) 创建VLAN的两种配置模式:全局配置模式和VLAN数据库配置模式
        交换机VLAN信息单独存放在flash:vlan.dat文件中,要完全清除交换机的配置,必须先"erase start-config",然后"delete flash:vlan.dat"把VLAN数据删除
        删除某一VLAN时,需先把在该VLAN的端口划分到其他VLAN中,否则端口会进入"非活跃"状态,而且show vlan 中无法看到接口。
全局配置模式
Sw_Server(config)#vlan 10
Sw_Server(config-vlan)#name ABC //VLAN10的名字ABC
Sw_Server(config-vlan)#exi
VLAN数据库配置模式
Sw_Server#vlan database
Sw_Server(vlan)#vlan 20 name DEF
Sw_Server(vlan)#exit                      //此命令必须敲,作用创建和退出
(2) 将端口划分到VLAN中
Sw_Server(config)#int f0/2
Sw_Server(config-if)#switchport mode access  //指定接入模式,此接口接接入设备
Sw_Server(config-if)#switchport access vlan 10 //将f0/2接口划分到VLAN10中
Sw_Server(config-if)#no shutdown
 
Sw_Trans(config)#int f0/3
Sw_Trans(config-if)#switchport mode access
Sw_Trans(config-if)#switchport access vlan 20
% Access VLAN does not exist. Creating vlan 20 //交换机中没有LVAN20,自动创建
Sw_Trans(config-if)#no sh
(3) 交换机之间连接端口协商起Trunk
        Native VLAN的数据不会被重新封装,如果链路两端的Native VLAN不一致,交换机会报错。  
在Trunk链路中还可以配置允许哪些VLAN通过,命令:switchport trunk allowed vlan 1,10,20,1002-1005,这里为了测试VTP不进行设置.。
Sw_Server(config)#int f0/1
Sw_Server(config-if)#switchport trunk encapsulation dot1q //Trunk封装模式:dot1q、另外还有cisco私有的ISL封装模式
Sw_Server(config-if)#switchport mode dynamic desirable //DTP协商,desirable:渴望形成Trunk,收发DTP报文
Sw_Server(config-if)#switchport trunk native vlan 99 //Native VLAN不打tag标记,交换机之间Native VLAN必须一致。
Sw_Server(config-if)#no sh
Sw_Trans(config)#int f0/1
Sw_Trans(config-if)#switchport trunk encapsulation dot1q
Sw_Trans(config-if)#switchport mode dynamic auto //dynamic auto 只收不发DTP报文,愿意成为Trunk模式
Sw_Trans(config-if)#switchport trunk native vlan 99
Sw_Trans(config-if)#no sh
Sw_Trans(config)#int f0/2
Sw_Trans(config-if)#switchport trunk encapsulation dot1q
Sw_Trans(config-if)#switchport mode trunk //强制开启Trunk,不管邻近是接口什么模式
Sw_Trans(config-if)#switchport nonegotiate //禁止DTP,配合Trunk使用
Sw_Trans(config-if)#switchport trunk native vlan 99
Sw_Trans(config-if)#no sh
Sw_Client(config)#int f0/1
Sw_Client(config-if)#switchport mode trunk
Sw_Client(config-if)#switchport nonegotiate
Sw_Client(config-if)#switchport trunk native vlan 99
Sw_Client(config-if)#no sh
(4) VTP三种模式:server、transparent、client,VTP默认版本1、server模式,不属于任何域。
Server模式:增删改VLAN信息,同步VLAN信息,保存在NVRAM中
Transparent模式:本地增删改VLAN信息,不同步VLAN信息,保存NVRAM中
Client模式:不能增删改VLAN信息,同步VLAN信息,不能保存在NVRAM中
VTP同步:配置版本号低的向配置版本号高的同步。
VTP Pruning:在Trunk链路上修剪不必要的流量。
VTP三要素:Trunk、domain、password
Sw_Server(config)#vtp mode server //VTP server模式
Sw_Server(config)#vtp domain cisco //VTP域名cisco
Sw_Server(config)#vtp password cisco1 //VTP认证,密码cisco1
Sw_Server(config)#vtp version 2 //开启VTP版本2
Sw_Server(config)#vtp pruning //VTP修剪,PT模拟器不支持。
Sw_Trans(config)#vtp mode transparent //VTP Transparent模式
Sw_Trans(config)#vtp domain cisco
Sw_Trans(config)#vtp password cisco1
Sw_Trans(config)#vtp version 2
Sw_Client#vlan database //VLAN 数据库配置模式
Sw_Client(vlan)#vtp client //VTP client模式
Sw_Client(vlan)#vtp domain cisco
Sw_Client(vlan)#vtp password cisco1
Sw_Client(vlan)#vtp v2-mode //开启VTP版本2
Sw_Client(vlan)#exit
(5) 配置SVI管理地址
Sw_Server(config)#int vlan 1 //创建SVI接口
Sw_Server(config-if)#ip address 192.168.1.1 255.255.255.0 //配置IP地址
Sw_Server(config-if)#no sh
Sw_Trans(config)#int vlan 1
Sw_Trans(config-if)#ip address 192.168.1.2 255.255.255.0
Sw_Trans(config-if)#no sh
Sw_Client(config)#int vlan 1
Sw_Client(config-if)#ip add 192.168.1.3 255.255.255.0
Sw_Client(config-if)#no sh
实验验证
查看VLAN信息和端口处于哪个VLAN:show vlan / show vlan brief
 
90633772[6]
 
查看Trunk模式是否形成、Native VLAN等:show interface trunk
 
90792191[6]
 
查看VTP信息:show vtp status
 
90931516[6]
 
查看VTP密码:show vtp password
 
91003994[6]
 
查看SVI接口信息:show ip interface brief
 
91703814[6]
91725561[6]
 
        验证VLAN信息的同步,在server上查看VLAN和VTP信息(上面有图show vlan brief 和show vtp status)
       添加修改删除VLAN信息后再查看VTP信息,配置版本号已经发生改变,修改一次加1
Sw_Server(config)#vlan 100
Sw_Server(config-vlan)#name AAA
Sw_Server(config-vlan)#exi
Sw_Server(config)#vlan 100
Sw_Server(config-vlan)#name BBB
Sw_Server(config-vlan)#exi
Sw_Server(config)#no vlan 100 //删除VLAN
 
92417503[6]
 
配置版本号从上面的1变成了5,再看Client端也变成了5,VLAN信息同步没有问题
 
92544270[6]
 
测试SVI的连通性
 
92736073[6]