基础配置:cisco交换机配置vlan(2)

VLAN网络可以是有混合的网络类型设备组成,比如:10M以太网、100M以太网、令牌网、FDDI、C
首页 新闻资讯 行业资讯 基础配置:cisco交换机配置vlan(2)

三层交换机上VLAN的设置

(1)方法一:一般常规配置

复制

Switch# configure terminal   Switch(config)# vlan 20   Switch(config-vlan)# name test20   Switch(config-vlan)#ip address 1.1.1.1 255.255.255.0   Switch(config-vlan)# end
  • 1.

  • 2.

  • 3.

  • 4.

  • 5.

  • 6.

  • 7.

  • 8.

  • 9.

 

方法二:也可以在enable状态下,进行VLAN配置:

复制

Switch# vlan database // 进入VLAN配置状态   Switch(vlan)# vlan 20 name test20 // 加入VLAN号及VLAN名   Switch(vlan)# exit 更新VLAN数据库并退出
  • 1.

  • 2.

  • 3.

  • 4.

  • 5.

 

(2)将端口分配给某个VLAN

复制

Switch# configure terminal   Switch(config)# interface fastethernet0/1   Switch(config-if)# switchport mode access // 定义二层口的工作模式为接入模式   Switch(config-if)# switchport access vlan 2 // 把端口分配给某一VLAN   Switch(config-if)# end   Switch#
  • 1.

  • 2.

  • 3.

  • 4.

  • 5.

  • 6.

  • 7.

  • 8.

  • 9.

  • 10.

  • 11.

 

(3)配置VLAN Trunks

复制

Switch# configure terminal   Switch(config)# interface fastethernet0/4   Switch(config-if)# switchport mode trunk   Switch(config-if)# switchport trunk encapsulation dot1q   Switch(config-if)# end   附:switchport trunk encapsulation {isl | dot1q | negotiate} // 配置trunk封装ISL 或 802.1Q 或自动协商
  • 1.

  • 2.

  • 3.

  • 4.

  • 5.

  • 6.

  • 7.

  • 8.

  • 9.

  • 10.

  • 11.

 

switchport mode {dynamic {auto | desirable} | trunk} (一般不用它),配置二层trunk模式。(dynamic auto—自动协商是否成为trunk;dynamic desirable—把端口设置为trunk如果对方端口是trunk, desirable, 或自动模式;trunk—设置端口为强制的trunk方式,而不理会对方端口是否为trunk)

(4)定义trunk允许的VLAN

复制

Switch(config)# interface fastethernet0/1   Switch(config-if)# switchport trunk allowed vlan remove 2 // 配置trunk允许的VLAN   Switch(config-if)# end   附:switchport trunk allowed vlan {add | all | except | remove} vlan-list
  • 1.

  • 2.

  • 3.

  • 4.

  • 5.

  • 6.

  • 7.

 

(5)配置Native VLAN(802.1q)

复制

switch(config-if)# switchport trunk native vlan-num    // 封装802.1q的trunk端口可以接受带有标签和不带标签的数据流,交换机向native vlan传送不带标签的数据流,缺省情况下native VLAN是VLAN 1使用no switchport trunk native vlan 端口配置命令回到缺省的状态
  • 1.

  • 2.

  • 3.

 

(6)配置一组端口

复制

4006# configure terminal   4006(config)# interface range fastethernet2/1 – 5   4006(config-if-range)# no shutdown   // 注意:端口号之间需要加入空格,如:interface range fastethernet 2/1 – 5 是有效的,而interface range fastethernet 2/1-5 是无效的.   以下的例子显示使用逗号来配置不同类型端口的组:   4006# configure terminal   4006(config)# interface range fastethernet2/1 – 3, gigabitethernet3/1 - 2   4006(config-if-range)# no shutdown
  • 1.

  • 2.

  • 3.

  • 4.

  • 5.

  • 6.

  • 7.

  • 8.

  • 9.

  • 10.

  • 11.

  • 12.

  • 13.

  • 14.

  • 15.

 

(7)其它常用命令

复制

duplex {auto | full | half}    // 设置全双工或半双工.   speed {10 | 100 | 1000 | auto | nonegotiate} 设置端口速率    // 注:1000 只工作在千兆口. GBIC模块只工作在1000 Mbps下. nonegotiate 只能在这些GBIC上用 1000BASE-SX, -LX, and -ZX GBIC.   copy running-config startup-config    // 保存设置
  • 1.

  • 2.

  • 3.

  • 4.

  • 5.

  • 6.

  • 7.

  • 8.

  • 9.

  • 10.

  • 11.

 

(8)配置EtherChannel

以太通道捆绑几个以太端口为一个独立的逻辑链路。如4006交换机,你可以捆绑在4006任何模块上最多8个兼容的具有相同速率的端口。每个以太通道具有一个port-channel端口号。要捆绑一个以太通道时,会产生一个逻辑port-channel端口,逻辑端口下的配置可影响与之捆绑的物理端口,但物理端口下的配置不能影响逻辑端口的配置。

1) 三层以太通道(逻辑port-channe)的配置

复制

Switch# configure terminal   Switch(config)# interface port-channel 1 // 创建一个逻辑端口   Switch(config-if)# ip address 172.32.52.10 255.255.255.0   Switch(config-if)# end
  • 1.

  • 2.

  • 3.

  • 4.

  • 5.

  • 6.

  • 7.

 

2) 三层物理端口配置

复制

Switch# configure terminal   Switch(config)# interface range fastethernet 5/4 – 5 (注意: 空格是必需的)   Switch(config-if)# no switchport // 改变该端口为三层接口   Switch(config-if)# no ip address // 确认接口没有配置IP地址   Switch(config-if)# channel-group 1 mode desirable   Switch(config-if)# end   附: Switch(config-if)# channel-group port_channel_number mode {auto | desirable | on} // 将该物理端口加入一个以太通道中,并确定PagP模式。
  • 1.

  • 2.

  • 3.

  • 4.

  • 5.

  • 6.

  • 7.

  • 8.

  • 9.

  • 10.

  • 11.

  • 12.

  • 13.

 

3) 二层以太通道配置

复制

Switch# configure terminal   Switch(config)# interface range fastethernet 5/6 - 7 (注意: 空格是必需的)   Switch(config-if-range)# channel-group 2 mode desirable   Switch(config-if-range)# end   Switch# show running-config interface port-channel 2   Building configuration...   Current configuration:   !   interface Port-channel2   switchport access vlan 10   switchport mode access   end   Switch#
  • 1.

  • 2.

  • 3.

  • 4.

  • 5.

  • 6.

  • 7.

  • 8.

  • 9.

  • 10.

  • 11.

  • 12.

  • 13.

  • 14.

  • 15.

  • 16.

  • 17.

  • 18.

  • 19.

  • 20.

  • 21.

  • 22.

  • 23.

  • 24.

  • 25.

三层交换机上VLAN的设置就为大家介绍完了,希望大家已经掌握。

【编辑推荐】


    1. VLAN-VPN典型配置

    2. 组播VLAN的典型配置

    3. 基于端口的VLAN典型配置指导

    4. 基础配置:cisco交换机配置vlan(1)

    5. 基础配置:cisco交换机配置vlan(2)

17    2011-04-02 17:29:12    vlan