-----------------VLAN-----------------
1、交换机功能
1MAC地址学习(基于源、每个MAC只能从1个端口学习、一个端口可以学习多个)
2)转发及过滤
3loopfree--->stp
2VLAN--->一个逻辑局域网需求
1)控制广播域范围
2安全需求
3管理
3VLAN特性
1)一个VLAN对应一个网段
2end to end vlan 跨过多个大楼
3local vlan 一幢楼
4、配置VLAN
1)配置VLAN
    特权和全局配置区别在于VTP修订号增长不一样
2)绑定端口
sw mode access
sw access vlan #
show vlan
5VLAN范围
1 默认
1002-1005 其它
交换机支持多少个VLAN是跟:型号、VTP 模式
6MAC地址老化时间
默认300
Switch#sh mac address-table aging-time
Global Aging Time: 300
Vlan    Aging Time
----    ----------
Switch(config)#mac address-table aging-time 150
-----------------Trunk-----------------
1trunk 一条能传输多个VLAN信息链路
2trunk标记技术
isl:   cisco      30byte     封装
802.1q: 标准       4byte      标记
802.1q 帧结构:以太网类型 pri(QOS标记数据) tokenring vlanid=12可以标记4096vlan
3native vlan 不打标签的vlan
默认是vlan 1
Switch#sh int trunk
Port        Mode             Encapsulation Status        Native vlan
Fa0/24      auto             n-isl          trunking      1
可以修改native vlan ,但是要求二边的native vlan要一致
如果不一致,会有环路的可能
Switch(config-if)#sw trunk native vlan #
4trunk 模式
手工:强制配置为trunk on
动态:DTP
dynamic desirable:主动发包去协商
dynamic auto 被动响应
on---->on 可以
on---->dd 可以
on---->da 可以
dd---->dd 可以
dd---->da 可以
da---->da 不可以
5、配置
Switch#sh int trunk查看trunk
Port        Mode             Encapsulation Status        Native vlan
Fa0/24      auto             n-isl          trunking      1
Switch#sh int f0/24 sw
Name: Fa0/24
Switchport: Enabled
Administrative Mode: dynamic auto
3550(config-if)#sw tr encapsulation dot1q
3550(config-if)#sw mode trunk 
3550(config-if)#sw mode dynamic auto
最佳实践:
3550(config-if)#sw nonegotiate
3550(config-if)#sw mode trunk
Switch(config-if)#sw trunk encapsulation dot1q
Switch(config-if)#sw nonegotiate
6native vlan 不一致导致不同vlan互通
3550(config)#int vlan 1
3550(config-if)#ip add 1.1.1.1 255.255.255.0
3550#sh int trunk
Port        Mode         Encapsulation Status        Native vlan
Fa0/48      on           802.1q         trunking      1
3550#sh spanning-tree
VLAN0001
---------------- ---- --- --------- -------- --------------------------------
Fa0/48           Desg BKN*19        128.48   P2p *PVID_Inc
3560(config)#int vlan 2
3560(config-if)#ip add 1.1.1.2 255.255.255.0
3560#sh int trunk
Port        Mode             Encapsulation Status        Native vlan
Fa0/24      on               802.1q         trunking      2
3550(config)#no spanning-tree vlan 1
3550#ping 1.1.1.2
.!!!!
-----------------VTP-----------------
1VTP作用:同步vlan达到简化vlan 的配置
2VTP同步条件trunk、域名、密码
3VTP同步依据:修订号---反映vlan变化(增加、删除、更改)
高的同步低的 
4vtp mode
              add/del/mod      同步      转发          保存位置
server:          可以           可以      可以           vlan.dat
client          不可以          可以      可以           vlan.dat
transparent      可以          不可以     可以(域名)    配置
5、配置
3550#sh vtp status
VTP Version                        :running VTP1 (VTP2 capable)    版本号
Configuration Revision          : 0     修订号
Maximum VLANs supported locally : 1005     最大支持vlan
Number of existing VLANs        : 5     现存vlan
VTP Operating Mode                :       Server VTP模式
VTP Domain Name                   :       域名
VTP Pruning Mode                  : Disabled 是否启用pruning
VTP V2 Mode                        : Disabled 是否用的版本2
VTP Traps Generation              : Disabled 
MD5 digest                         : 0x57 0xCD 0x40 0x65 0x63 0x59 0x47 0xBD
Configuration last modified by 0.0.0.0 at 0-0-00 00:00:00
Local updater ID is 0.0.0.0(no valid interface found)
3550#sh vtp password
The VTP password is not configured.
3550(config)#vtp domain chuyue100
3550(config)#vtp password chuyue100
3560(config)#vtp mode transparent
6VTP修剪
减少没有必要广播流量
3560#sh int trunk
Port        Vlans in spanning tree forwarding state and not pruned
Fa0/24      1-4
3560# sh cdp nei detail
Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge
                  S - Switch, H - Host, I - IGMP, r - Repeater, P - Phone
 
Device ID        Local Intrfce     Holdtme    Capability Platform Port ID
Switch          Fas 0/23          143           S I      WS-C2960- Fas 0/23
Switch           Fas 0/24          179           S I      WS-C2960- Fas 0/24
邻居名字         自己接口     存活时间      对方类型       平台    对方接口
3550(config)#vtp pruning
7、防止加交换机时把现网的vlan同步掉---->修订号清0
1)删除vlan.dat
2)改为透明模式:修订号永远为0
3)改域名
实验:
native vlan 不一致
VTP 修剪
排错