中继:中继链接(Trunk Link)指的是能够转发多个不同的通信的端口。
中继接口封装的类型
Cisco支持多种Trunk方式(即对VLAN帧标识):ISL――Cisco专有封装协议,也是默认的。前面加26字节,后面加4字节FCS。 帧长度1518/1548。可支持的VLAN数为1-1046。
IEEE 802.1Q――IEEE标准方法,在帧头写入VLAN信息,后面只增加4字节FCS。帧 长度为1518/1522。有12位的标识,它可以支持到4096个VLAN。802.1Q-为转发未被标记的frame而定义了 native VLAN(本地VLAN)。能够从未被标记的上的nativeVLAN转发2层frame,接受方将把所有的未标记frame转发到 native VLAN中 。VLAN1是默认的本地VLAN,也可以把其他的VLAN更改为本地VLAN。如果是ISL,则没被封装的frame将会丢弃,包括 nativeVLAN,所有的数据将被封装
802.10――FDDI上传输VLAN信息的Cisco专有协议,把VLAN信息写入SAID安全关联标识符部分
LANE――基于ATM上传输VLAN信息的一种IEEE标准方法。
配置中继接口模式
1.交叉线连接两台交换机
2.进入接口sw2(config)#interface f0/243.配置接口模式:switchport mode access:强制接口成为access接口,并且可以与对方主动进行协商,诱使对方成为access模式。
switchport mode dynamic auto:有邻居交换机主动与自己协商时才会变成Trunk接口,所以它是一种被动模式,当邻居接口为Trunk/desirable之一时,才会成为Trunk。如果不能形成trunk模式,则工作在access模式。
switchport mode dynamic desirable:主动与邻居协商是不是成为Trunk接口,如果邻居接口模式为Trunk/desirable/auto之一,则接口将变成trunk接口工作。如果不能形成trunk模式,则工作在access模式。这种模式是现在交换机的默认模式。
switchport mode trunk:强制接口成为Trunk接口,并且主动诱使对方成为Trunk模式,所以当邻居交换机接口为trunk/desirable/auto时会成为Trunk接口。
switchport nonegotiate:严格的说,这不算是种接口模式,它的作用只是阻止交换机接口发出DTP数据包,它必须与switchport mode trunk或者switchport mode access一起使用。必须手工去配置相邻接口的模式。
switchport mode dot1q-tunnel:设置接口为Q-in-Q隧道 。
封装配置
1.进入中继接口配置模式
interface f0/242.设置中继接口的封装类型switchport trunk encapsulation isl:中继接口的类型为cisco专有的isl(3550)
switchport trunk encapsulation dot1q:中继接口的类型为 IEEE 802.1Q (2950)
switchport trunk encapsulation negotiate:根据相邻接口的类型来协商封装类型
允许中继访问的VLAN
在默认情况下,交换机的中继接口发送和接收来自所有VLAN(1-4094)数据流量。我们可以使用命令将一些VLAN从允许访问的VLAN列表中删除,使得这些VLAN在中继链路上不装载。
配置步骤:1. 进入接口模式 interface f0/242. 将接口配置为中继模式(如果已经是中继接口就不需要) switchport mode trunk3. 配置允许VLAN列表switchport trunk allowed vlan {add | all | except | remove} vlan-listadd:将VLAN添加到允许中继运载的VLAN列表
all:允许中继链路晕在所有的VLAN,这是一个默认值
except:除了VLAN-list指定的VLAN外,其他的VLAN都允许
remove:将vlan-list指定的VLAN从允许列表中移除
vlan-list:可以使用单个(1-4094)或者一个范围(不能出现空格)
4. 查看配置结果
show running interface f0/24 //查看中继接口配置 show interface f0/24 switchport //查看中继接口的状态如: interface f0/24switchport trunk allowed vlan remove 3,5,6-10 !show interface f0/24 switchportName: Fa0/24Switchport: EnabledAdministrative Mode: dynamic desirableOperational Mode: trunkAdministrative Trunking Encapsulation: dot1qOperational Trunking Encapsulation: dot1qNegotiation of Trunking: OnAccess Mode VLAN: 1 (default)Trunking Native Mode VLAN: 1 (default)Trunking VLANs Enabled: 1,2,4,11-4094Pruning VLANs Enabled: 2-1001Capture Mode DisabledCapture VLANs Allowed: ALLProtected: falseAppliance trust: none考试题目: YY版本:SW1和SW2上做trunk,封装类型为isl,使所有的odd的vlan承载在fa0/23上,而even的vlan承载在fa0/24上,并且只承载题目中存在的vlan 配置: SW1和SW2 Interface f0/23 Switchport mode trunk Switchport trunk encapsulation isl Switchport trunk allowed vlan 11,13,15,17 Interface f0/24 Switchport trunk encapsulation isl Switchport mode trunk Switchport trunk allowed vlan 12,14,16 验证: show interface trunk |
设置中继修剪列表
Prunning-eligible合适修剪列表只能应用在中继链路上,VTP的修剪功能必须打开。
配置过程:1.打开vtp的修剪功能特权模式下:vlan databasevtp pruning2.进入中继接口模式interface f0/24switch trunk pruning vlan {add |except | none | remove} vlan-list [,vlan[,vlan[,,,]]add:将vlan加入到适宜修剪的列表中
except:除了指定的vlan之外都修剪
none:不做任何的修剪
remove:将指定的vlan移除需要修剪的列表
vlan-list:可以是用逗号分隔的单个vlan(2-1001,其他不能被修剪掉),短线表示为一个范围,不能出现空格
3.查看配置结果
show interface f0/24 switchport show running interface f0/24 show interface trunk如: interface f0/24switchport trunk pruning vlan add 3,5,6-10show running inter f0/24show interface f0/24 switchportName: Fa0/24Switchport: EnabledAdministrative Mode: dynamic desirableOperational Mode: trunkAdministrative Trunking Encapsulation: dot1qOperational Trunking Encapsulation: dot1qNegotiation of Trunking: OnAccess Mode VLAN: 1 (default)Trunking Native Mode VLAN: 1 (default)Trunking VLANs Enabled: 1,2,4-4094Pruning VLANs Enabled: 2,4,11-1001Capture Mode DisabledCapture VLANs Allowed: ALLProtected: falseAppliance trust: none配置802.1Q的本地vlan(native vlan)
封装类型为802.1q的trunk中继接口,可以接收“带标记(tagged)”和“未加标记(untagged)”的数据。缺省时,交换机会用该端口的本地vlan(native vlan)来转发未加标记的数据。
封装类型为isl的trunk中继接口,对未加标记“未加标记(untagged)”的数据将会丢弃。
缺省的本地vlan(native )为VLAN 1。
本地vlan可以被指定为任意的vlan号,它不依赖于管理vlan。
配置过程:1.进入接口模式,中继的封装类型为802.1qinterface f0/24switchport mode trunkswitchport trunk encap dot1q2.设置哪个vlan作为本地vlan switchport trunk native vlan vlan-id vlan-id:1-40943.查看配置结果 show interface f0/24 switchport如果某个数据帧的vlan id与出端口的本地vlan号相同,该数据包就按照未标记传送;否则,交换机会使用带标记来传输数据包如:interface f0/24 switchport mode trunk switchport trunk encap dot1q switchport trunk native vlan 3show interf f0/24 switchport
Name: Fa0/24Switchport: EnabledAdministrative Mode: dynamic desirableOperational Mode: trunkAdministrative Trunking Encapsulation: dot1qOperational Trunking Encapsulation: dot1qNegotiation of Trunking: OnAccess Mode VLAN: 1 (default)Trunking Native Mode VLAN: 3 (VLAN_B)Voice VLAN: noneOperational private-vlan: noneTrunking VLANs Enabled: 1,2,4-4094Pruning VLANs Enabled: 2-9,11-1001Capture Mode DisabledCapture VLANs Allowed: ALLProtected: falseAppliance trust: noneshow interface trunkPort Mode Encapsulation Status Native vlanFa0/24 desirable 802.1q trunking 3Port Vlans allowed on trunkFa0/24 1-2,4-4094Port Vlans allowed and active in management domainFa0/24 1-2,10Port Vlans in spanning tree forwarding state and not prunedFa0/24 1-2,10