Vlan(虚拟局域网)是为了解决交换机中的广播包而出现的一种技术。默认情况下2层交换机所发送的每个广播包都被网络上的所有设备收到,而不管这些设备是否需要这些数据。 <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

为了解决这个问题就需要划分vlan了,通过划分vlan可以解决广播包问题,也可以确保了局域网安全。

VTP:是VLAN中继协议,也被称为虚拟局域网干道协议。 通过在交换机中设置VTP中让属于同一个VTP域中的交换机接收到服务器中的vlan划分。

VTP有三种模式: 服务器模式(Server)客户机模式(Client)透明模式(Transparent 服务器模式(Server
   提供VTP消息:包括VLAN ID和名字信息
  学习相同域名的VTP消息
  转发相同域名的VTP消息
  可以添加、删除和更改VLAN VLAN信息写入NVRAM

客户机模式(Client
  请求VTP消息
  学习相同域名的VTP消息
  转发相同域名的VTP消息
  不可以添加、删除和更改VLAN VLAN信息不会写入NVRAM
透明模式(Transparent
  不提供VTP消息
  不学习VTP消息
  转发VTP消息 

了解更详细VTP介绍:http://baike.baidu.com/view/123875.htm

划分vlan  VTP所需要的命令:

Switch# vlan database      进入 vlan 配置模式

Switch(vlan)# vlan  ID   name   名字                    配置一个 vlan

Switch(vlan)# no  vlan   ID                                  删除 vlan

Switch(config-if)# switchport  mode  access          把端口设置成 access 模式

Switch(config-if)# switchport  access  vlan  ID      把当前端口加入 vlan ID

Switch(config)#vtp mode server       配置VTP为服务器模式

Switch(config)#vtp mode client       配置VTP为客户机模式

Switch(config)#vtp mode transparent   配置VTP为透明模式

Switch(config)#vtp domain 域名        配置VTP的域名

Switch(config)#vtp password 口令      配置VTP密码

Switch (config) # vtp version 2(默认是版本1)   配置VTP版本

Switch (config) # vtp pruning            配置VTP修剪

Switch#show vtp status   查看VTP信息
 

 

实际操作:

交换机SERVER

Switch>en

Switch#conf t

Switch(config)#int f0/1

Switch(config-if)#switchport mode trunk 

Switch(config-if)#exit

Switch(config)#int f0/2

Switch(config-if)#switchport mode trunk 

Switch(config-if)#exit

Switch(config)#vtp ?

  domain    Set the name of the VTP administrative domain.

  mode      Configure VTP device mode

  password  Set the password for the VTP administrative domain

  version   Set the adminstrative domain to VTP version

Switch(config)#vtp mode server

Switch(config)#vtp domain xy

Switch(config)#vtp password 123

switch (config)# vtp version 2

Switch(config)#end

Switch#conf t

Switch(config)#vlan 2

Switch(config-vlan)#name vlan2

Switch(config-vlan)#end
 
 
 

 

交换机Client

Switch>en

Switch#conf t

Switch(config)#int f0/1

Switch(config-if)#switchport mode trunk 

Switch(config-if)#exit

Switch(config)#vtp mode client

Switch(config)#vtp domain xy

Switch(config)#vtp password 123

switch (config)# vtp version 2

Switch(config)#end
 
 

 

交换机 transparent

Switch>en

Switch#conf t

Switch(config)#int f0/2 t

Switch(config-if)#switchport mode trunk 

Switch(config-if)#exit

Switch(config)#vtp mode transparent

Switch(config)#vtp domain xy

Switch(config)#vtp password 123

switch (config)# vtp version 2

Switch(config)#end

 

 

配置完后通过show命令来查看成功与否

 

交换机Client属于客户机模式,在交换机Server中,所以当交换机Server进行Vlan划分后它也跟着接收,交换机 transparent虽然跟Server也在同一个域中由于它属于透明模式所以不接数据
 
哪里写的不好的!请大家给予批评