本文转自:http://zcm8483.blog.163.com/blog/static/38866452012112162031907/

Cisco 交换机端口模式

交换机的端口工作模式一般可以分为三种:Access,Multi,Trunk。
cisco网络中,交换机在局域网中最终稳定状态的接口类型主要有四种:access、trunk、 multi、dot1q-tunnel。
1、access: 主要用来接入终端设备,如PC机、服务器、打印服务器等。
2、trunk: 主要用在连接其它交换机,以便在线路上承载多个vlan。
———————————————————————————————————–
Cisco支持多种Trunk方式(即对VLAN帧标识):
2.1. ISL――Cisco专有封装协议,也是默认的。前面加26字节,后面加4字节FCS。 帧长度1518/1548。可支持的VLAN数为1-1046。
2.2. IEEE 802.1Q――IEEE标准方法,在帧头写入VLAN信息,后面只增加4字节FCS。
帧长度为1518/1522。有12位的vlan标识,它可以支持到4096个VLAN。
802.1Q- trunk为转发未被标记的frame而定义了native VLAN(本地VLAN)。交换机能够从未被标记的trunk上的nativeVLAN转发2层frame,接受方将把所有的未标记frame转发到 native VLAN中 。VLAN1是默认的本地VLAN,也可以把其他的VLAN更改为本地VLAN。如果是ISL,则没被封装的frame将会丢弃,包括 nativeVLAN,所有的数据将被封装
2.3. 802.10――FDDI上传输VLAN信息的Cisco专有协议,把VLAN信息写入SAID安全关联标识符部分
2.4. LANE――基于ATM上传输VLAN信息的一种IEEE标准方法。
————————————————————————————————————-
3、multi: 在一个线路中承载多个vlan,但不像trunk,它不对承载的数据打标签。主要用于接入支持多vlan的服务器或者一些网络分析设备。现在基本不使用此类接口,在cisco的网络设备中,也基本不支持此类接口了。
4、dot1q-tunnel: 用在Q-in-Q隧道配置中。
Cisco 网络设备支持动态协商端口的工作状态,这为网络设备的实施提供了一定的方便(但不建议使用动态方式)。cisco动态协商协议从最初的 DISL(Cisco私有协议)发展到DTP(公有协议)。根据动态协议的实现方式,Cisco网络设备接口主要分为下面几种模式:
1、switchport mode access: 强制接口成为access接口,并且可以与对方主动进行协商,诱使对方成为access模式。
2、 switchport mode dynamic desirable: 主动与对方协商成为Trunk接口的可能性,如果邻居接口模式为Trunk/desirable/auto之一,则接口将变成trunk接口工作。如果不 能形成trunk模式,则工作在access模式。这种模式是现在交换机的默认模式。
3、 switchport mode dynamic auto: 只有邻居交换机主动与自己协商时才会变成Trunk接口,所以它是一种被动模式,当邻居接口为Trunk/desirable之一时,才会成为 Trunk。如果不能形成trunk模式,则工作在access模式。
4、switchport mode trunk: 强制接口成为Trunk接口,并且主动诱使对方成为Trunk模式,所以当邻居交换机接口为trunk/desirable/auto时会成为Trunk接口。
5、 switchport nonegotiate: 严格的说,这不算是种接口模式,它的作用只是阻止交换机接口发出DTP数据包,即禁止端口向对方发送协商包,它必须与switchport mode trunk或者switchport mode access一起使用。
6、switchport mode dot1q-tunnel: 配置交换机接口为隧道接口(非Trunk),以便与用户交换机的Trunk接口形成不对称链路。
在思科4507交换机上查看端口的模式
cisco4507(config-if)#switchport ?
  access         Set access mode characteristics of the interface
  block          Disable forwarding of unknown uni/multi cast addresses
  host           Set port host
  mode           Set trunking mode of the interface
  nonegotiate    Device will not engage in negotiation protocol on this
                 interface
  port-security  Security related command
  priority       Set appliance 802.1p priority
  private-vlan   Set the private VLAN configuration
  trunk          Set trunking characteristics of the interface
  voice          Voice appliance attributes
  <cr>
 
cisco4507(config-if)#switchport mode access ?
  <cr>
 
cisco4507(config-if)#switchport mode trunk ?
  <cr>
 
cisco4507(config-if)#switchport mode ?
  access        Set trunking mode to ACCESS unconditionally
  dot1q-tunnel  set trunking mode to TUNNEL unconditionally
  dynamic       Set trunking mode to dynamically negotiate access or trunk mode
  private-vlan  Set the mode to private-vlan host or promiscuous
  trunk         Set trunking mode to TRUNK unconditionally
  <cr>
 
cisco4507(config-if)#switchport mode dynamic ?
  auto       Set trunking mode dynamic negotiation parameter to AUTO
  desirable  Set trunking mode dynamic negotiation parameter to DESIRABLE
  <cr>

 
配置交换机模式举例1
SW1:
interface FastEthernet0/1
switchport mode dynamic desirable
 

查看该端口的模式,假定对方接口配置为静态access,此时我们查看到的该接口模式协商为access,如下所示

SW1#show interface fa0/1 switchport
Name: Fa0/1
Switchport: Enabled
Administrative Mode: dynamic desirable
Operational Mode: static access
Administrative Trunking Encapsulation: negotiate
Operational Trunking Encapsulation: native
Negotiation of Trunking: On
Access Mode VLAN: 1 (default)
Trunking Native Mode VLAN: 1 (default)
如果两个相连的交换机端口都配置为switchport mode dynamic desirable,首先会协商为trunk,并且封装为ISL
配置举例说明2:(假定SW1的f0/13 连接到SW2的F0/13上)
 
SW1(f0/13)——–(f0/13)SW2
 
SW1
interface FastEthernet0/13
switchport mode dynamic desirable
 
SW2
interface FastEthernet0/13
switchport mode dynamic desirable
 
SW1#show interface status | include (Port|Fa0/13)
Port Name Status Vlan Duplex Speed Type
Fa0/13 connected trunk a-full a-100 10/100BaseTX
 
注意加粗部分,最终协商的模式为trunk,并且封装的协议为ISL
SW1#show interface fa0/13 switchport
Name: Fa0/13
Switchport: Enabled
Administrative Mode: dynamic desirable
Operational Mode: trunk
Administrative Trunking Encapsulation: negotiate
Operational Trunking Encapsulation: isl
Negotiation of Trunking: On
Access Mode VLAN: 1 (default)
Trunking Native Mode VLAN: 1 (default)