• VLAN是一种将局域网设备从逻辑上划分成一个个网段,从而实现虚拟工作组的新兴数据交换技术。

 

vlan 配置思路 (access 、Trunk)

(1)创建Vlan

在基于IOS的交换机上配置静态VLAN:

 
  
  1. switch# vlan database  
  2.  
  3. switch(vlan)# vlan vlan-num name vlan-name  
  4.  
  5. switch(vlan)# exit  
  6.  
  7. switch# configure teriminal  
  8.  
  9. switch(config)# interface interface module/number  
  10.  
  11. switch(config-if)# switchport mode access // 设置端口模式为access模式  
  12.  
  13. switch(config-if)# switchport access vlan vlan-num // 设置端口所属的VLAN  
  14.  
  15. switch(config-if)# end 

 

核验配置:show vlan

(2)配置干道链路

干道是在两台catalyst交换机端口或catalyst交换机与路由器间的一条点对点链路。 干道链路可以承载多个vlan。

在基于IOS的交换机上配置干道链路

 
  
  1. switch(config)# interface interface mod/port  
  2.  
  3. switch(config-if)# switchport mode trunk // 设置端口模式为trunk模式  
  4.  
  5. switch(config-if)# switchport trunk encapsulation {isl|dotlq} // 设置trunk所封装的帧  
  6.  
  7. switch(config-if)# switchport trunk allowed vlan remove vlan-list // 允许那些VLAN通过干路  
  8.  
  9. ( 附:switchport trunk allowed vlan {add | all | except | remove} vlan-list ) 

 

no switchport

no switchport // 把物理端口变成三层口,即把三层口当成路由器上的口,当将一个端口配置成三层端口之后,就可以在此端口上分配IP地址了,当然还是可以连接PC机的,。 路由口:路由口是指某一物理端口在端口配置状态下用no switchport命令生成的端口,所有的三层都需要IP地址以实现路由交换。

配置举例如下:

 
  
  1. Switch# configure terminal  
  2.  
  3. Switch(config)# interface gigabitethernet0/2  
  4.  
  5. Switch(config-if)# no switchport  
  6.  
  7. Switch(config-if)# ip address 192.20.135.21 255.255.255.0  
  8.  
  9. Switch(config-if)# no shutdown  
  10.  
  11. Switch(config-if)# end 

 

附:show interfaces [interface-id] switchport // 显示二层端口的状态,可以用来决定此口是否为二层或三层口。 Eg:Switch# show interfaces fastethernet 0/1 switchport

VLAN的配置还有很多内容,本文只是介绍了一部分,希望大家多多掌握。