配置交换机VTP协议

                    首先我们来认识一下什么是 VTP
  
VLAN 可以使用 Trunk 技术跨交换机实现,也就是将交换机 A B 之间的链路配置成 Trunk ,这样,连接在交换机 A 与交换机 B 上的相同 VLAN 号的主机就可以通信。
在一台或几台交换机上配置 VLAN 的工作量不是很大,但是,在企业网环境中通常由许多的相互连接的交换机组成,因此,要对数量很多的交换机配置 VLAN 和管理就很复杂了。为了解决这一问题, Cisco 开发了管理 VLAN 的协议―― VLAN Trunk Protocol
 
VTP 协议用来确保配置的一致性,他具有以下优点:
保持 VLAN 配置的一致性
提供从一个交换机在整个管理域中增加虚拟局域网的方法
 
VTP 协议是 Cisco 的专用协议,大多数的 Catalyst 交换机都支持该协议, VTP 协议可以减少 VLAN 相关的管理任务
 
VTP 协议中,有两个重要的概念
VTP 域:也称为 VLAN 管理域,有一个以上共享 VTP 域名的相互连接的交换机组成。也就是说 VTP 域是一组 VTP 域名相同并通过中继链路相互连接的交换机
VTP 通告:在交换机之间用来传递 VLAN 信息的数据包成为 VTP 通告
 
下面是对 VTP 域的要求
域内的每台交换机都必须使用相同的 VTP 域名
Catalyst 交换机必须是相邻的,
所有的 Catalyst 交换机之间必须启用 Trunk 中继
所有的 Catalyst 交换机必须属于一个 VTP 域,也就是说一个交换机只能加入到一个 VTP 管理域
 
VTP 有三种运行模式:
 
    服务器模式 (server) :充当 VTP 服务器的交换机控制着它所在域中 VLAN 的生成和修改, VTP 服务器可以添加和修改 VLAN ,并想外部发送 VTP 通告,同时, VTP 服务器也会学习域名相同的 VTP 通告信息,默认情况下, Catalyst 交换机处于 VTP 服务器模式 (server)
    客户机模式 (client) :处于此模式的交换机上不允许管理员创建,修改或删除 VLAN ,他们监听本域中其他交换机的 VTP 通告,并相应修改他们 VTP 配置情况,这是一种被动的监听模式, VTP 客户端上也维护着 VTP 域内所有 VLAN 的列表
    透明模式 (transparent) VTP 透明模式中的交换机不参与 VTP ,当交换机处于透明模式时,他可以创建和删除本地的 VLAN ,当他不向外通告自己的 VLAN 配置信息,也不根据接收到的 VTP 通告信息更新和修改自己的 VLAN 数据库,运行 VTP 透明模式的交换机可以转发 VTP 通告信息
 
使用 VTP 时,加入 VTP 域的每台交换机在其中继端口上通告如下信息:
管理域   版本号   配置修改编号   它所知道的 VLAN  每个以知 VLAN 的某些参数
 
VTP 消息类型
 
    汇总通告 :汇总通告用于通知邻接的 Catalyst 交换机目前的 VTP 域名和配置修改编号,默认情况下, Catalyst 交换机每 5 秒钟发送一次汇总通告
    子集通告 :如果在 VTP 服务器上增加,删除和修改了 VLAN ,“配置修改编号”就会增加,交换机首先会发送汇总通告,然后发送一个或多个子集通告,子集通告中包括 VLAN 列表和相应的 VLAN 信息,如果有多个 VLAN ,为了通告所有的信息,可能需要发送多个子集通告
    通告请求 :交换机在下列情况下会发出 VTP 通告请求
交换机重新启动后 VTP 域名变更后 交换机接到了配置修改编号比自几高的 VTP 汇总通告
一旦受到请求通告, VTP 设备就会先发送汇总通告,然后发送一个或多个子集通告
 
VTP 修剪( VTP Pruning )是 VTP 的一个功能,他能减少中继端口上下必要的广播信息量
 
好了,做了以上的了解后,我们来实际配置一下 VTP 环境,首先要考虑的基本任务是:
 
确定将在网络中运行 VTP 版本
决定交换机是成为以有管理域的成员,还是另外为其创立一个新的管理域如果要加入到已有的管理域中,则确定他的名称和口令
为交换机选择一个 VTP 的工作模式
是否需要启动修剪功能
 
 
相关命令参考:

                                           SA
sA>enable
sA#config terminal
Enter configuration commands, one per line.  End with CNTL/Z.
sA(config)#interface f0/0
sA(config-if)#switchport mode trunk                   //启用trunk链路
*Mar  1 00:15:52.435: %DTP-5-TRUNKPORTON: Port Fa0/0 has become dot1q trunk
sA(config-if)#end
*Mar  1 00:17:08.131: %SYS-5-CONFIG_I: Configured from console by console
sA#vlan database                                               //进入VLAN数据库
sA(vlan)#vlan 2 name vlan2                                //创建vlan
VLAN 2 added:
    Name: vlan2
sA(vlan)#vlan 3 name vlan3
VLAN 3 added:
    Name: vlan3
sA(config)#vtp domain benet                            //配置VTP域名
Changing VTP domain name from NULL to benet
sA(config)#vtp mode server                             //配置交换机的VTP模式
*Mar  1 00:06:14.167: %SYS-5-CONFIG_I: Configured from console by console
Device mode already VTP SERVER.
sA(config)#vtp password cisco                          //配置VTP口令
Setting device VLAN database password to cisco.
sA(config)#vtp pruning                                      //配置VTP修剪
Pruning switched ON
sA(vlan)#vtp version 2                                       //默认情况下使用版本1,如果使用版本2需要使用如下命令
V2 mode enabled.
sA(config)#interface vlan 1                                 //进入VLAN 1
sA(config-if)#ip address 192.168.1.1 255.255.255.0     //配置管理IP 地址
sA(config-if)#no shutdown
sA(config-if)#exit
sA(config)#exit
*Mar  1 00:09:22.967: %SYS-5-CONFIG_I: Configured from console by console
sA#show vtp status                                               //查看VTP配置信息
VTP Version                                    : 2                 //显示设备支持扳本2
Configuration Revision                      : 2                //目前的配置修改编号
Maximum VLANs supported locally : 256            //支持的最大的VLAN数是256个
Number of existing VLANs               : 5               //已经存在的VLAN 数
VTP Operating Mode                       : Server       //VTP模式为服务器模式
VTP Domain Name                          : benet         //VTP域名
VTP Pruning Mode                          : Enabled     //VTP修剪已经启用
VTP V2 Mode                                : Enabled      //启用了VTP版本2
VTP Traps Generation                     : Disabled
MD5 digest                                      : 0x5C 0xFD 0x08 0x82 0x3E 0x7C 0xAE 0x1B  //MD5值
Configuration last modified by 0.0.0.0 at 3-1-02 00:08:13           //VTP更新者的IP及时间
Local updater ID is 192.168.1.1 on interface Vl1 (lowest numbered VLAN interface found)
                                            SB

sB>enable
sB#config terminal
Enter configuration commands, one per line.  End with CNTL/Z.
sB(config)#interface f0/0
sB(config-if)#switchport mode trunk
*Mar  1 00:18:52.435: %DTP-5-TRUNKPORTON: Port Fa0/0 has become dot1q trunk
sB(config-if)exit
sB(config)#interface f0/1
sB(config-if)#switchport mode trunk
*Mar  1 00:19:21.435: %DTP-5-TRUNKPORTON: Port Fa0/1 has become dot1q trunk
sB(config-if)#end
*Mar  1 00:20:08.131: %SYS-5-CONFIG_I: Configured from console by console
sB#vlan database
sB(vlan)#vlan 4 name vlan4
VLAN 2 added:
    Name: vlan4
sB(vlan)#vlan 5 name vlan5
VLAN 3 added:
    Name: vlan5
sB(config)#vtp domain benet
Changing VTP domain name from NULL to benet
sB(config)#vtp mode transparent
*Mar  1 00:06:14.167: %SYS-5-CONFIG_I: Configured from console by console
Device mode already VTP transparent.
sB(config)#vtp password cisco
Setting device VLAN database password to cisco.
sB(config)#vtp pruning
Pruning switched ON
sB(vlan)#vtp version 2
V2 mode enabled.
sB(config-if)#exit
sB(config)#exit
sB#show vtp status
VTP Version                                    : 2
Configuration Revision                      : 0
Maximum VLANs supported locally : 256
Number of existing VLANs              : 5
VTP Operating Mode                      : Transparent
VTP Domain Name                         : benet
VTP Pruning Mode                          : Enabled
VTP V2 Mode                                : Enabled
VTP Traps Generation                     : Disabled
MD5 digest                                      : 0xAE 0x60 0xEF 0xB9 0x4E 0x18 0x4F 0x15
Configuration last modified by 0.0.0.0 at 3-1-02 00:34:29

                                            SC
sC>enable
sC#config terminal
Enter configuration commands, one per line.  End with CNTL/Z.
sC(config)#interface f0/1
sC(config-if)#switchport mode trunk
*Mar  1 00:35:02.435: %DTP-5-TRUNKPORTON: Port Fa0/1 has become dot1q trunk
sC(config-if)#end
*Mar  1 00:17:08.131: %SYS-5-CONFIG_I: Configured from console by console
sC(config)#vtp domain benet
Changing VTP domain name from NULL to benet
sC(config)#vtp mode client
*Mar  1 00:06:14.167: %SYS-5-CONFIG_I: Configured from console by console
Device mode already VTP client.
sC(config)#vtp password cisco
Setting device VLAN database password to cisco.
sC(config)#vtp pruning
Pruning switched ON
sC(vlan)#vtp version 2
V2 mode enabled.
sC(config-if)#end
*Mar  1 00:09:22.967: %SYS-5-CONFIG_I: Configured from console by console
sC#show vtp status
VTP Version                                    : 2
Configuration Revision                      : 3
Maximum VLANs supported locally : 256
Number of existing VLANs              : 7
VTP Operating Mode                      : Client
VTP Domain Name                         : benet
VTP Pruning Mode                          : Enabled
VTP V2 Mode                                : Enabled
VTP Traps Generation                     : Disabled
MD5 digest                                     : 0x05 0x7F 0xB9 0xE6 0x48 0xD1 0xD6 0x6B
Configuration last modified by 192.168.1.1 at 3-1-02 00:19:46
 
交换机 A 查看 VLAN 信息,看是否学习到了交换 B VLAN 信息
交换机 B 上配置透明模式,验证是否能学到交换机 A VLAN 信息,同时在本地建立 VLAN4 VLAN5
交换机 C 查看本地学习到的是哪个交换机发出的 VLAN 信息

你可能感兴趣的:(配置,协议,休闲,交换机,VTP)