“trunk”在网络用语中一般译为:“主干线、中继线、长途线” ,不过一般不用译意,直接使用英文。在路由/交换网络中,trunk通常被称为“中继(透传)”。在语音级应用的线路中,trunk一般指“主干网络、电话干线”,即两个交换局或交换机之间的连接电路或信道,它为两端设备之间进行转接,作为信令和终端设备数据的传输链路。
单词释义英音:[trʌŋk]美音:[trʌŋk] 名词 n. [C]
1. 树干
The trunk of this tree is four meters thick.
这棵树的树干有四米粗。
2. (旅行用)大皮箱;汽车车尾的行李箱
Let me put your baggage in the trunk.
我来把你的行李放在汽车后部的行李箱内。
3. 象鼻;昆虫等的长嘴
4. 躯干,身躯
The athlete has a powerful trunk.
那个运动员身躯强壮有力。
5. (铁路,公路等的)干线
6. 大血管,神经干
7. 男用运动短裤;男用泳裤(尤指性感或情趣类)[P]
8. 【矿】洗矿槽
及物动词 vt.
1. 槽内洗选(矿砂)
应用在路由/交换领域,VLAN的中继端口叫做trunk。trunk技术用在交换机之间互连,使不同VLAN通过共享链路与其它交换机中的相同VLAN通信。交换机之间互连的端口就称为trunk端口。trunk是基于OSI第二层数据链路层(DataLinkLayer)的技术。两台交换机上分别创建了多个VLAN(VLAN是基于Layer 2的),在两台交换机上相同的VLAN(比如VLAN10)要通信,需要将交换机A上属于VLAN10的一个端口与交换机B上属于VLAN10的一个端口互连;如果这两台交换机其它相同VLAN间需要通信,那么交换机之间需要更多的互连线,端口利用率就太低了。 交换机通过trunk功能,事情就简单了,只需要两台交换机之间有一条互连线,将互连线的两个端口设置为trunk模式,这样就可以使交换机上不同VLAN共享这条线路。
trunk不能实现不同VLAN间通信,需要通过三层设备(路由/三层交换机)来实现。
划分交换端口两种模式:access和trunk。连接终端(如PC)用access模式,设备级连接用trunk模式。把access端口加入到某个VLAN,那么这个端口就只将这个VLAN的数据转发给PC,PC发送的数据通过这个端口后会打上这个VLAN的ID,转发到相同VLAN。(这里为了简单表述,混杂模式端口不做讨论;将PC用access模式,其他情况不做讨论。)
配置Cisco默认的trunk封装协议为dot1q(802.1q)。
配置方法:
Switch(config)#interface gigabitEthernet 1/1
Switch(config-if)#switchport trunk encapsulation dot1q //默认封装,该命令可以省略,特殊情况:配置单臂路由,必须敲这条命令。
Switch(config-if)#switchport mode trunk //协议变化,端口协议会down /up转换一次。
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet1/1, changedState to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet1/1, changedState to up
Switch(config-if)#switchport trunk allowed vlan 10,20 // VLAN 修剪,add/remove 参数增减
Switch(config-if)#exit
验证方法:
Switch#show interfaces trunk // show interswitchport 命令也可以。
Port Mode Encapsulation Status Native vlan
Gig1/1 on 802.1q trunking 1
Port Vlans allowed on trunk
Gig1/1 10,20
Port Vlans allowed and active in management domain
Gig1/1 none
Port Vlans in spanning tree forwarding state and not pruned
Gig1/1 none
或
Switch#show interfaces gigabitEthernet 1/1 switchport // show running inter [interface] 验证方法其实很多的;
Name: Gig1/1
Switchport: Enabled
Administrative Mode: trunk
Operational Mode: trunk
Administrative Trunking Encapsulation: dot1q
Operational Trunking Encapsulation: dot1q
Negotiation of Trunking: On
Access Mode VLAN: 1 (default)
Trunking Native Mode VLAN: 1 (default)
Voice VLAN: none
Administrative private-vlan host-association: none
Administrative private-vlan mapping: none
Administrative private-vlan trunk native VLAN: none
Administrative private-vlan trunk encapsulation: dot1q
Administrative private-vlan trunk normal VLANs: none
Administrative private-vlan trunk private VLANs: none
Operational private-vlan: none
Trunking VLANs Enabled: ALL
Pruning VLANs Enabled: 2-1001
Capture Mode Disabled
Capture VLANs Allowed: ALL
Protected: false
Appliance trust: none1
本词条内容贡献者为:
徐恒山 - 讲师 - 西北农林科技大学