计算机网络与组网工程

173课时
2.5K学过
6分

课程评价 (0)

请对课程作出评价:
0/300

学员评价

暂无精选评价
15分钟

3.3.2 交换机上配置VLAN Trunk

1. 配置iVLANTrunk

( 1 )配置接口为 Trunk 模式。

Switch(config)# interfaceinterface-id

Switch(config-if)#switchport modetnmk

interface-id为端口 ID。

(2) 接口的模式有以下三种:

Switch(config-if)#switchport mode?

access Set trunking mode toACCESS unconditiona11y

dynamic Set trunking mode to dynamically negotiate access

or trunk mode

mnk Set trunking mode to TRUNK unconditionally

● access接口为接入模式

● dynamic接口为动态协商模式

● trunk 接口为中继模式

(3 ) 査看接口模式。

Switch#show interface interface_id switchport

(4)从Trunk 中添加、删除VLAN。

1 )去除 VLAN。

Switch(config-if)# switchporttrun],( a11owed vlan remove vlan-1ist

2)添加 VLAN。

Switch(config-if)# switchporttmnk a11owedvlan add vlan-1ist

3 ) 检査中继端口允许 VLAN的列表。

Switch# show interface interface-id switchport

2. 配置i VLAN Trunk 实例

VLAN Tnmk 实例如图3-7所.

图3-7

• 第一步:在交换机上添加VLAN

• SW1#vlan database

• SW1(vlan)#vlan 2

• VLAN 2 added:

• Name: VLAN0002

• SW1(vlan)#vlan 3

• VLAN 3 added:

• Name: VLAN0003

• SW1(vlan)#exit

• APPLY completed.

• Exiting....

第二步:将接口添加到相应的VLAN中

• SW1#config terminal

• SW1(config)#interface range f0/1 - 5

• SW1(config-if-range)#switchport access vlan 2

• SW1(config)#interface range f0/6 - 9

• SW1(config-if-range)#switchport access vlan 3

第三步:配置交换机之间互联的端口为Trunk并验证

• SW1(config)#interface f0/15

• SW1(config-if)#switchport mode trunk

• SW1#show interface f0/15 switchport

• Name: Fa0/15

• 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

• Operational private-vlan: none

• Pruning VLANs Enabled: 2-1001 ④

• Capture Mode Disabled

• Capture VLANs Allowed: ALL

从上面命令输出中带蓝色的字体部分可以看出:

• ① 接口f0/15管理模式为trunk。

• ② 工作模式也是trunk。

• ③ trunk封装的协议是802.1Q,

• ④ 默认情况下,trunk可以传送所有的VLAN数据。

第四步:如果不需要在Trunk上传输VLAN 2的数据,可以在Trunk上移去VLAN2。

Sw1(config)#interface f0/15 Sw1(config-if)#switchport trunk allowed vlan remove 2 Sw1(config-if)#end Sw1#show interface f0/15 switchport Name: F0/15 Switchport: Enabled Administrative Mode: trunk Operational Mode: trunk Adinistrative Trunking Encapsulation: dot1q Operational of Trunking Encapsulation: dot1q Negotiation of Trunking: On Access Mode VLAN: 1 (default) Voice VLAN: none Administrative private-vlan host-association: none Operational private-vlan: none Trunking VLANs Enabled: 1,3-1005 Pruning VLANs Enabled: 2-1001 Capture Mode Disabled

从上面命令输出中加粗的字体部分可以看出,Trunk中已经移去了VLAN 2。也可以在sw2上执行类似的配置,配置完成以后,使用show interface命令进行验证。