VTP(VLAN Trunking Protocol):是VLAN中继协议,也被称为虚拟局域网干道协议。它是思科私有协议。十几台交换机在企业网中,配置VLAN工作量大,可以使用VTP协议,把一台交换机配置成VTP Server, 其余交换机配置成VTP Client,自动学习server 上的VLAN 信息。

注意是cisco专用协议,在其他设备上不支持,所有交换机默认就是server模式

Switch#show vtp status查看vtp状态

配置步骤

拓扑图就不画了,就是简单的两台交换机,用交叉线连接。

sw1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#vlan 10
Switch(config-vlan)#exit
Switch(config)#vlan 20
Switch(config-vlan)#exit
Switch(config)#int f0/1
Switch(config-if)#switchpo
Switch(config-if)#switchport mode trunk ;对连接交换机的端口使用中继链路
Switch(config)#vtp mode server ;将此交换机设置为vtp server
Device mode already VTP SERVER.
Switch(config)#vtp domain d1 ;新建一个名为d1的域
Changing VTP domain name from NULL to d1
Switch(config)#vtp password 123.com ;vtp密码
Setting device VLAN database password to 123.com
Switch(config)#exit

sw2

1
2
3
4
5
6
7
8
9
10
11
12
13
Switch>ena
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#vtp mode client ;将此交换机设置为vtp client
Switch(config)#vtp domain d1
Changing VTP domain name from NULL to d1
Switch(config)#vtp password 123.com
Setting device VLAN database password to 123.com
Switch(config)#exit
Switch(config)#int f0/3
Switch(config-if)#switchport mode trunk ;对连接交换机的端口使用中继链路
Switch(config-if)#exit
Switch(config)#do sh vlan

完成后sw1更新vlan时sw2会自动学习,其中f0/1和f0/3是连接两台交换机的接口