定义 VLAN 配置 Trunk
维护特有VLAN 标识: TRUNK是为了实现多VLAN 内部流量的勾通 在每一个帧上打上一个独一无二的标识 是在 Layer 2来实现功能 能传输多个VLAN数据的端口叫做TRUNK;TRUNK是一个二层链路,是物理层的复用,是交换机间VLAN的延伸;发交换机上TAG,收换机去掉TAG,由此,知道此数据是哪个VLAN的; TRUNK是为了实现多VLAN 内部流量的勾通 在每一个帧上打上一个独一无二的标识 是在 Layer 2来实现功能
VLAN Trunking 交换机之间,路由器和交换机之间都可以用TRUNK;
比较 ISL and 802.1Q ISL 802.1Q Proprietary Nonproprietary Encapsulated Tagged Protocol independent Protocol dependent Encapsulates the old frame in a new frame Adds a field to the frame header TRUNK封装的目的:让接受者能知道这个数据帧交给哪个vlan;ISL是硬件封装,速度快。802.1Q是拆包打入标记,速度没有ISL快。
通过 ISL来实现Trunking: ISL是cisco私有协议 支持 PVST 使用 封装的方式来实现 不会修改最初的数据帧 支持多种二层协议
ISL 封装:
通过 802.1Q 来实现Trunking Dolt1Q是一个IEEE 公认的标准 在原数据帧里面添加一个四字节的标识来实现 添加的tag 包含有优先级的字段 native VLAN是不会打上tag的 支持cisco IP电话技术 支持4096vlan,支持RSTP,MSTP,支持NATIVE,支持QOS,只支持以太网。
802.1Q 打标的过程
802.1Q Native VLAN NATIVE是为了接受数据而服务的,native vlan也可以认识是trunk口上的port vlan id(PVID),每个trunk只能有一个native vlan;所有端口默认是vlan 1;trunk口的native vlan必须相同。 Native VLAN frames are carried over the trunk link untagged.
VLAN 号的范围: VLAN Range Use 0, 4095 Reserved for system use only 1 Cisco default 2–1001 For Ethernet VLANs 1002–1005 Cisco defaults for FDDI and Token Ring 1006–4094 Ethernet VLANs only, unusable on specific legacy platforms VLAN 1 不能被修改和删除;三层接口会占用一个内部VLAN,从1006开始;建议使用扩展VLAN时,从4094开始开始往下用。
Trunking 配置命令: Configuring a Trunk Trunks can be configured statically or via DTP. DTP provides the ability to negotiate the trunking method. Configuring a Trunk switchport trunk switchport mode switchport nonegotiate关掉DTP协商
交换模式的相互作用: Note: Table assumes DTP is enabled at both ends. Dynamic Auto Dynamic Desirable Trunk Access Not recommended Note: Table assumes DTP is enabled at both ends. show dtp interface – to determine current setting
怎么来配置 Trunking: Enter interface configuration mode. Shut down interface. Select the encapsulation (802.1Q or ISL). Configure the interface as a Layer 2 trunk. Specify the trunking native VLAN (for 802.1Q). Configure the allowable VLANs for this trunk. Use the no shutdown command on the interface to activate the trunking process. Verify the trunk configuration. 做配置前,建议吧端口关掉。
802.1Q Trunk Configuration Switch(config)#interface fastethernet 5/8 Switch(config-if)#shutdown Switch(config-if)#switchport trunk encapsulation dot1q Switch(config-if)#switchport trunk allowed vlan 1,5,11,1002-1005 Switch(config-if)#switchport mode trunk Switch(config-if)#switchport trunk native vlan 99 Switch(config-if)#switchport nonegotiate Switch(config-if)#no shutdown 建议把native vlan设成没有用的VLAN,更加安全
检查802.1Q配置: Switch#show running-config interface {fastethernet | gigabitethernet} slot/port Switch#show interfaces [fastethernet | gigabitethernet] slot/port [ switchport | trunk ] Switch#show interfaces fastEthernet 5/8 switchport Name: fa5/8 Switchport: Enabled Administrative Mode: trunk Operational Mode: trunk Administrative Trunking Encapsulation: dot1q Operational Trunking Encapsulation: dot1q Negotiation of Trunking: Off Access Mode VLAN: 1 (default) Trunking Native Mode VLAN: 99 (trunk_only) Trunking VLANs Enabled: 1,5,11,1002-1005 Pruning VLANs Enabled: 2-1001 . . .
检查802.1Q 动态Trunk 链路 Switch#show running-config interface fastethernet 5/8 Building configuration... Current configuration: ! interface FastEthernet5/8 switchport mode dynamic desirable switchport trunk encapsulation dot1q Switch#show interfaces fastethernet 5/8 trunk Port Mode Encapsulation Status Native vlan Fa5/8 desirable 802.1q trunking 99 Port Vlans allowed on trunk Fa5/8 1,5,11,1002-1005 Port Vlans allowed and active in management domain Fa5/8 1,5,1002-1005 Port Vlans in spanning tree forwarding state and not pruned
ISL Trunk 配置: Switch(config)#interface fastethernet 2/1 Switch(config-if)#shutdown Switch(config-if)#switchport trunk encapsulation isl Switch(config-if)#switchport trunk allowed vlan 1-5,1002-1005 Switch(config-if)#switchport mode trunk Switch(config-if)#switchport nonegotiate Switch(config-if)#no shutdown
检查ISL Trunking Switch#show running-config interface {fastethernet | gigabitethernet} slot/port Switch#show interfaces [fastethernet | gigabitethernet] slot/port [ switchport | trunk ] Switch#show interfaces fastethernet 2/1 trunk Port Mode Encapsulation Status Native VLAN Fa2/1 trunk isl trunking 99 Port VLANs allowed on trunk Fa2/1 1-5,1002-1005 Port VLANs allowed and active in management domain Fa2/1 1-2,1002-1005 Port VLANs in spanning tree forwarding state and not pruned
总结: Trunk 链路是用来携带多VLAN流量。 ISL 是思科私有的协议,使用二层封装的方式来实现。 802.1Q 是一个 IEEE 标准, 通过使用四字节的标计来实现。 802.1Q 的native VLAN转发帧不用打标. VLAN 号码有不同的范围和用途 不用的命令可以用来检查 ISL and 802.1Q trunk links. 可以配置只让必需的VLAN穿越TRUNK.