VTP基本使用
VTP(Vlan Trunk Protocol)即VLAN中继协议。VTP通过网络(ISL帧或者cisco私有的DTP帧)保证VLAN配置的统一性。VTP在系统级管理增加、删除,跳转VLAN,自动地将信息向网络中其他的交换机广播。此外,VTP减小了那些可能导致安全问题的配置。便于管理,只要在vtp server做相应的设置,vtp client会自动学习vtp server上的vlan信息。
3.1 实例拓扑图
3.2 配置VTP
核心交换机Cisco 3650配置为vtp Server,vtp domain为senya。
Switch#vlan database
% Warning: It is recommended to configure VLAN from config mode,
as VLAN database mode is being deprecated. Please consult user
documentation for configuring VTP/VLAN in config mode.
Switch(vlan)#vtp domain senya
Changing VTP domain name from NULL to senya
Switch(vlan)#vtp server
Device mode already VTP SERVER.
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#int fa 0/1
Switch(config-if)#switchport mode trunk
Command rejected: An interface whose trunk encapsulation is "Auto" can not be configured to "trunk" mode.
报错了,我的天,含义是,命令被拒绝:接口的中继封装是“自动”不能被配置为“主干”模式
那就先封装一下吧
Switch(config-if)#switchport trunk encapsulation dot1q
Switch(config-if)#switchport mode trunk
Switch(config)#int fa 0/2
Switch(config-if)#switchport trunk encapsulation dot1q
Switch(config-if)#switchport mode trunk
Switch(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to up
图3-2-2 配置trunk链路,允许带vlan标记的以太网帧通过该链路
Switch#vlan database
% Warning: It is recommended to configure VLAN from config mode,
as VLAN database mode is being deprecated. Please consult user
documentation for configuring VTP/VLAN in config mode.
Switch(vlan)#vtp domain senya
Domain name already set to senya.
Switch(vlan)#vtp client
Setting device to VTP CLIENT mode.
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#int fa 0/1
Switch(config-if)#switchport mode trunk
3.3 创建Vlan及端口划分
Switch>en
Switch#vlan database
% Warning: It is recommended to configure VLAN from config mode,
as VLAN database mode is being deprecated. Please consult user
documentation for configuring VTP/VLAN in config mode.
Switch(vlan)#vlan 2
VLAN 2 added:
Name: VLAN0002
Switch(vlan)#vlan 3
VLAN 3 added:
Name: VLAN0003
Switch#show vlan
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#int fa 0/1
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 2
3.4 配置pc测试vlan
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#int vlan 2
Switch(config-if)#
%LINK-5-CHANGED: Interface Vlan2, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan2, changed state to up
Switch(config-if)#ip address 192.168.1.1 255.255.255.0
Switch(config-if)#no shutdown
Switch(config-if)#int vlan 3
Switch(config-if)#
%LINK-5-CHANGED: Interface Vlan3, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan3, changed state to up
Switch(config-if)#ip address 192.168.2.1 255.255.255.0
Switch(config-if)#no shutdown
结果不同网段一直不能ping通,到另外VLAN的网关也不同,后来百度找到需要顶层启用路由功能
Switch(config)#ip routing
验证: