VTP中继协议,是CISCO专用协议,。VTP域控制器主要作用负责统一管理VLAN信息,并在VTP域内同步VLAN信息,这样就不必在每个交换上配置相同的VLAN信息,实现了VLAN的统一配置和管理。

VTP三种模式

* 服务器模式(Server
         可以创建、删除和修改VLAN
         学习、转发相同域名的VTP通告
* 客户机模式(Client
         学习、转发相同域名的VTP通告
        不可以创建、删除和修改VLAN
* 透明模式(Transparent
        可以创建、删除和修改VLAN,但只在本地有效
        转发但不学习VTP通告

实例:

 

Cisco三层交换VTP域控_Cisco三层交换_04 

 

一、配置VTP域控
SW1上配置(由于vtp域会管理vlan信息,所以只需在vtp域控上创建vlan,将连接交换机的端口配置为trunk,其余交换机会自动学习vtp域上的配置)
Switch >enable
Switch#conf t
Switch(config)#hostname SW1
SW1 (config)#vtp domain test
SW1 (config)#vtp mode server    #配置为vtp域控(服务器模式)
SW1 (config)#vtp password 123
SW1 (config)#interface range f0/1-2
SW1 (config-if-range)#switchport mode trunk
SW1 (config-if-range)#exit
SW1 (config)#vlan 2
SW1 (config-vlan)#exit
SW1 (config)#vlan 3
SW1 (config-vlan)#exit
SW1 (config)#end
SW1#show vlan brief
 
VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Fa0/3, Fa0/4, Fa0/5, Fa0/6
                                                Fa0/7, Fa0/8, Fa0/9, Fa0/10
                                                Fa0/11, Fa0/12, Fa0/13, Fa0/14
                                                Fa0/15, Fa0/16, Fa0/17, Fa0/18
                                                Fa0/19, Fa0/20, Fa0/21, Fa0/22
                                                Fa0/23, Fa0/24, Gig0/1, Gig0/2
2    VLAN0002                         active   
3    VLAN0003                         active   
SW1#show vtp status     #查看vtp状态
VTP Version                     : 2
Configuration Revision          : 2
Maximum VLANs supported locally : 1005
Number of existing VLANs        : 7
VTP Operating Mode              : Server
VTP Domain Name                 : test
VTP Pruning Mode                : Disabled
VTP V2 Mode                     : Disabled
VTP Traps Generation            : Disabled
 
SW2配置(先配置vtp域客户端,这样在二层交换上就不用配置vlan了,二层交换会自动学习vtp域控制器上的vlan信息)
Switch>enable
Switch#conf t
Switch(config)#hostname SW2  
SW2 (config)#vtp domain test     #交换机上的 域名和密码必须和服务器上的相符,否则不能自动学习
SW2 (config)#vtp mode client     #二层交换上配置vtp客户经理模式
SW2 (config)#vtp password 123
SW2 (config)#interface f0/1
SW2 (config-if)#switchport mode trunk
SW2 (config-if)#end
SW2#show vlan brief
 
VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Fa0/2, Fa0/3, Fa0/4, Fa0/5
                                                Fa0/6, Fa0/7, Fa0/8, Fa0/9
                                                Fa0/10, Fa0/11, Fa0/12, Fa0/13
                                                Fa0/14, Fa0/15, Fa0/16, Fa0/17
                                                Fa0/18, Fa0/19, Fa0/20, Fa0/21
                                                Fa0/22, Fa0/23, Fa0/24, Gig1/1
                                                Gig1/2
2    VLAN0002                         active   #发现vtp客户端自动创建了vlan信息
3    VLAN0003                         active   
SW2#show vtp status
VTP Version                     : 2
Configuration Revision          : 2
Maximum VLANs supported locally : 255
Number of existing VLANs        : 7
VTP Operating Mode              : Client
VTP Domain Name                 : test
VTP Pruning Mode                : Disabled
VTP V2 Mode                     : Disabled
VTP Traps Generation            : Disabled
 
SW3配置(和SW2上配置一样)
Switch>enable
Switch#conf t
Switch(config)#hostname SW3
SW3 (config)#vtp domain test    #
SW3 (config)#vtp mode client   #二层交换上配置vtp客户经理模式
SW2 (config)#vtp password 123
SW3 (config)#interface f0/1
SW3 (config-if)#switchport mode trunk
SW3 (config-if)#end
SW3#show vlan brief
 
VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Fa0/2, Fa0/3, Fa0/4, Fa0/5
                                                Fa0/6, Fa0/7, Fa0/8, Fa0/9
                                                Fa0/10, Fa0/11, Fa0/12, Fa0/13
                                                Fa0/14, Fa0/15, Fa0/16, Fa0/17
                                                Fa0/18, Fa0/19, Fa0/20, Fa0/21
                                                Fa0/22, Fa0/23, Fa0/24, Gig1/1
                                                Gig1/2
2    VLAN0002                         active   
3    VLAN0003                         active   
SW3#show vtp status
VTP Version                     : 2
Configuration Revision          : 2
Maximum VLANs supported locally : 255
Number of existing VLANs        : 7
VTP Operating Mode              : Client
VTP Domain Name                 : test
VTP Pruning Mode                : Disabled
VTP V2 Mode                     : Disabled
VTP Traps Generation            : Disabled
 
二、让内部网络可以互相通信
配置4台PC机的ip地址
SW1配置
SW1 (config)#ip routing    #在三层交换上开启路由转发,使得不同的vlan之间可以互相通信
SW1 (config)#interface vlan 2
SW1 (config-if)#ip address 192.168.1.1 255.255.255.0
SW1 (config-if)#no shutdown
SW1 (config-if)#exit
SW1 (config)#interface vlan 3
SW1 (config-if)#ip address 192.168.2.1 255.255.255.0
SW1 (config-if)#no shutdown
SW1 (config-if)#exit
SW2配置
SW2 (config)#interface f0/2
SW2 (config-if)#switchport mode access
SW2 (config-if)#switchport access vlan 2
SW2 (config-if)#exit
SW2 (config)#interface f0/3
SW2 (config-if)#switchport mode access
SW2 (config-if)#switchport access vlan 3
SW3配置
SW3(config)#interface range f0/2-3
SW3(config-if-range)#switchport mode access
SW3(config-if-range)#switchport access vlan 3
 
测试:
(1)在PC 1 ping PC3 通
(2)在vtp域上创建一个vlan,到SW2和SW3上查看,发现已经自动学习