• 沒有找到結果。

4.4  Cisco IOS 交换机二层接口模式配置

4.4.2  配置以太网接口为二层 Trunk 端口

中继是在一个或多个以太网交换接口和其他网络设备(如路由器或交换机)之间的点对点链 路。中继模式允许属于不同 VLAN 的数据帧都可以通过中继链路传输数据帧。有关 Trunk 端口模式 请参见 4.2.1 节。 

1.Trunk 模式类型

可以在单一以太网接口或以太网通道上配置中继模式。以太网中继接口支持不同的中继模式,

具体如表 4­9 所示。可以指定使用 ISL 或 802.1Q 封装,或者通信双方自动协商(Negotiate)封装方 式。中继协商是由  DTP(Dynamic  Trunking  Protocol,动态中继协议)管理的。DTP  支持  ISL  和  802.1Q 两种封装的协商。

表 4­9  以太网中继封装类型

封装类型 封装命令 用途说明 

ISL  switchport trunk encapsulation isl  指定在中继链路采用 ISL 封装类型 

802.1Q  switchport trunk encapsulation dot1q  指定在中继链路采用 802.1Q 封装类型 

Negotiate  switchport trunk encapsulation negotiate  指定接口与邻居接口协商封装类型,协商的依据是配置、邻居接口性能等

要配置成自动协商中继模式,必须确保接口在同一个  VTP(VLAN  Trunking  Protocol,VLAN  中继协议)域(有关 VTP 方面的具体知识将在第 8 章介绍)中。使用 trunk 或 nonegotiate 关键字 可以强制不同域的接口中继。通信中的两个相邻接口的中继模式、中继封装类型和硬件性能决定了 是采用 ISL 还是 802.1Q 中继模式。 

Trunk  端口可以允许多个  VLAN  通过,可以接收和发送多个  VLAN  的数据帧,一般用于交换 机间的连接。二层接口默认是  dynamic  auto  模式(动态自动模式,具体解释参见表  4­8  中的  switchport  mode  命令介绍)。如果邻居接口支持中继(Trunk),并且配置为  trunk  或  dynamic  desirable 模式,则链路将成为二层中继链路,而且默认是采用中继封装类型协商方式;如果邻居接 口支持  ISL 和  802.1Q  封装类型,且两个接口都设置为封装类型协商模式,则链路使用  ISL 封装类 型。但是 Supervisor Engine 6­E 不支持 ISL 封装。

【说明】完成本小节的各种配置前,必须先完成 4.4.1 节第 1 小点中介绍的通过 switchport 命 令把以太网接口配置成交换端口的步骤。 

2.配置一个以太网接口作为二层 Trunk 端口

配置二层中继的步骤如表 4­10 所示(自特权模式开始)。

最系统的交换机配置与管理手册

表 4­10  配置二层中继的步骤

步骤 命令 用途说明 

Switch(config)#interface {fastethernet | gigabitethernet | 

tengigabitethernet} slot/port  指定要配置的接口,进入接口配置模式 

Switch(config­if)#shutdown  (可选)关闭接口以阻止通信流,直到配置完成 

Switch(config­if)#switchport trunk encapsulation {isl |  dot1q | negotiate} 

(可选)指定封装类型。必须在此命令中键入  isl  或  dot1q  关键 字,以支持下一步的 switchport  mode  trunk 命令,因为默认的  negotiate(协商)模式是不支持下一步的 switchport mode trunk  命令的 

Switch(config­if)#switchport mode {dynamic {auto |  desirable} | trunk} 

配置接口作为二层中继(仅当接口是作为二层  Access  端口或者 指定中继模式时才需要) 

Switch(config­if)#switchport access vlan vlan_id 

(可选)指定访问  VLAN,在接口停止中继时使用。访问  VLAN  不能用作本地 VLAN。

参数  vlan_id  要么是一个范围为  1~1005  的单独  VLAN  ID  或者 以逗号分隔的多个单独 VLAN,要么是一个由两个 VLAN  ID 指 定的范围,中间以连接号连接。但在两个以逗号分隔的  VLAN  或者以破折号连接的两个 VLAN 之间不要键入任何空格 

Switch(config­if)#switchport trunk native vlan vlan_id 

对于 802.1Q 中继类型,指定本地 VLAN,此  VLAN 的 ID 作为  PVID 值。如果不指定本地 VLAN,则默认是使用 VLAN  1 作为 本地 VLAN 

Switch(config­if)#switchport trunk allowed vlan {add |  except | all |remove} vlan_id[,vlan_id[,vlan_id[,....]] 

(可选)配置允许中继的  VLAN  列表。默认是所有  VLAN  都可 以中继。不能从中继中删除任何默认 VLAN 

Switch(config­if)#switchport trunk pruning vlan {add |  except | none | remove} vlan_id[,vlan_id[,vlan_id[,....]] 

(可选)配置在中继中有资格修剪的  VLAN  列表。默认所有  VLAN 都具有修剪资格,除了 VLAN 1 外 

Switch(config­if)#no shutdown  激活接口(仅在接口处于关闭状态时需要) 

10  Switch(config­if)#end  退出接口配置模式 

11  Switch#show running­config interface {fastethernet | 

gigabitethernet | tengigabitethernet} slot/port  显示在运行配置中的指定接口配置  12  Switch#show interfaces [fastethernet | gigabitethernet | 

tengigabitethernet] slot/port switchport  显示指定接口的交换端口配置 

13  Switch#show interfaces [{fastethernet | gigabitethernet | 

tengigabitethernet} slot/port] trunk  显示指定接口的中继配置

【示例 1】配置 fastethernet 5/8 接口 802.1Q 中继,中继模式为 dynamic desirable(动态适应)。

示例中假设邻居接口已配置支持 802.1Q 中继,本地 VLAN 默认为 VLAN 1。 

Switch#configure terminal 

Enter configuration commands, one per line.    End with CNTL/Z. 

Switch(config)#interface fastethernet 5/8 

最系统的交换机配置与管理手册 

Operational Mode: trunk 

Administrative Trunking Encapsulation: negotiate  Operational Trunking Encapsulation: dot1q  Negotiation of Trunking: Enabled  Access Mode VLAN: 1 (default)  Trunking Native Mode VLAN: 1 (default)  Trunking VLANs Enabled: ALL  Pruning VLANs Enabled: 2­1001 

【示例 4】校验 fastethernet 5/8 接口的中继配置。 

Switch#show interfaces fastethernet 5/8 trunk 

Port      Mode      Encapsulation    Status      Native vlan  Fa5/8      desirable        n­802.1q      trunking      1 

Port      Vlans allowed on trunk  Fa5/8 1­1005 

Port  Vlans allowed and active in management domain 

Fa5/8 1­6,10,20,50,100,152,200,300,303­305,349­351,400,500,521,524,570,801­8  02,850,917,999,1002­1005 

Port      Vlans in spanning tree forwarding state and not pruned 

Fa5/8 1­6,10,20,50,100,152,200,300,303­305,349­351,400,500,521,524,570,801­8  02,850,917,999,1002­1005 

Switch# 

3.配置二层中继使用 DTP 

Cisco  DTP  是  VLAN  协议组中  Cisco  的专有协议,主要用于协商两台设备间链路上的中继模 式及中继封装(如 ISL 或 802.1Q)类型。如果一个端口可以成为 Trunk 端口,那么该端口也可能具 有自动中继功能,在某些情况下,甚至具有协商哪种中继类型的功能。这种与其他设备之间进行的 协商中继方法的过程被称为动态中继技术。

可以配置二层接口使用 DTP,配置二层接口使用 DTP 的命令如表 4­11 所示。

表 4­11  配置二层中继使用 DTP 的命令

命令 用途说明 

Switch(config­if)#switchport mode dynamic {auto | desirable}  (可选)配置中继接口使用 DTP 

Switch(config­if)#no switchport mode  恢复中继接口到默认的中继模式(动态交换模式)

【注意】在配置了二层中继使用  DTP  后,仅当接口是二层访问或者指定了中继模式时才需要 使用 DTP。 

4.配置二层中继不使用 DTP 

配置二层中继不使用 DTP 的步骤如表 4­12 所示。

表 4­12  配置二层中继不使用 DTP 的步骤

步骤 命令 用途说明 

Router(config­if)#switchport mode trunk  (可选)配置端口无条件地中继 

Router(config­if)#no switchport mode  恢复到默认的中继模式(使用 dynamic desirable 交换模式) 

Router(config­if)#switchport nonegotiate  (可选)配置中继不使用 DTP  Router(config­if)#no switchport nonegotiate  在端口上启用 DTP 

在配置二层中继不使用 DTP 时,应注意以下事项:

l 在键入 switchport mode trunk 命令前必须配置封装方式,参见本节第 2 小点。

最系统的交换机配置与管理手册 l 要支持 switchport nonegotiate 命令,必须键入 switchport mode trunk 命令。

l 需要键入 switchport mode dynamic trunk 命令。

l 在键入  switchport  nonegotiate  命令前必须配置封装方式,参见本节第  2  小点;并且配置 端口使用 switchport mode trunk 命令无条件地中继,参见本小节第 3 小点。 

5.配置 802.1Q  本地 VLAN 

本地 VLAN(Native VLAN)是 IEEE 802.1Q 中的概念,是一个不带标记(Tag)的 VLAN,主 要用于管理,默认为 VLAN  1。配置本地 VLAN 的命令为 switchport  trunk  native  vlan  vlan_ID, 

vlan_ID  参数的取值范围也为  1~4094。如果指定的  VLAN  是锁定的,则可以使用  VLAN  名替代  VLAN 号。访问 VLAN 不自动用于本地 VLAN。 

6.校验二层中继配置

想要查看二层中继配置,可以使用表 4­13 所列的命令。

表 4­13  查看二层中继配置的命令

命令 用途说明 

Router#show running­config interface type slot/port  显示指定接口上当前运行的配置  Router#show interfaces [type slot/port] switchport  显示指定接口上的交换端口配置  Router#show interfaces [type slot/port] trunk  显示指定接口上的中继配置

下面是一个显示如何把 Catalyst  6500 系列交换机上的 Fa5/8 接口配置成 802.1Q  Trunk 端口(假 设其邻接端口也是配置成支持 802.1Q 中继的),并校验该接口的配置的示例。 

Router#configure terminal 

Enter configuration commands, one per line.    End with CNTL/Z. 

Router(config)#interface fastethernet 5/8  Router(config­if)#shutdown 

Router(config­if)#switchport 

Router(config­if)#switchport mode dynamic desirable  Router(config­if)#switchport trunk encapsulation dot1q  Router(config­if)#no shutdown 

Router(config­if)#end  Router#exit 

Router#show running­config interface fastethernet 5/8  Building configuration... 

Current configuration: 

interface FastEthernet5/8  no ip address  switchport 

switchport trunk encapsulation dot1q  end 

Router#show interfaces fastethernet 5/8 switchport  Name: Fa5/8 

Switchport: Enabled 

Administrative Mode: dynamic desirable  Operational Mode: trunk 

Administrative Trunking Encapsulation: negotiate  Operational Trunking Encapsulation: dot1q  Negotiation of Trunking: Enabled  Access Mode VLAN: 1 (default)  Trunking Native Mode VLAN: 1 (default)  Trunking VLANs Enabled: ALL  Pruning VLANs Enabled: ALL

最系统的交换机配置与管理手册 

Router#show interfaces fastethernet 5/8 trunk 

Port      Mode      Encapsulation    Status      Native vlan  Fa5/8      desirable        n­802.1q      trunking      1 

Port      Vlans allowed on trunk  Fa5/8 1­1005 

Port      Vlans allowed and active in management domain 

Fa5/8 1­6,10,20,50,100,152,200,300,303­305,349­351,400,500,521,524,570,801­8  02,850,917,999,1002­1005 

Port      Vlans in spanning tree forwarding state and not pruned 

Fa5/8 1­6,10,20,50,100,152,200,300,303­305,349­351,400,500,521,524,570,801­8  02,850,917,999,1002­1005 

Router# 

相關文件