Cisco交换机虚拟局域网vlan配置

发布时间 2023-07-18 11:46:45作者: Evan-whc
Cisco交换机虚拟局域网vlan配置

一、 交换机端口成员资格模式
交换机端口指工作在第2层的接口,并与具体的物理端口相关联。
配置VLAN时,必须为它分配一个数字ID,也可根据需要为其指定一个名称。

  1. 静态VLAN配置

    S3# configure terminal
    S3(config)# interface fastEthernet 0/18
    S3(config-if)# switchport mode access
    S3(config-if)# switchport access vlan 20
    S3(config-if)# end
    
  2. 语音VLAN配置

    S3# configure terminal
    S3(config)# interface fastEthernet 0/18
    S3(config-if)# mls qos trust cos
    S3(config-if)# switchport voice vlan 150
    S3(config-if)# switchport mode access
    S3(config-if)# switchport access vlan 20
    S3(config-if)# end
    S3# show interface fa0/18 switchport
    

支持语音和数据的交换机端口,其配置遵循以下要点。

  • 使用配置命令 mls qos trust cos 可确保将语音流量识别为需要优先传送的流量。注意,必须将整个网络设置为优先传送语音流量,不能只是使用此命令配置端口。
  • switchport voice VLAN 150命令将VLAN 150标识为语音VLAN。
  • switchport access VLAN 20命令将VLAN 20配置为接入模式(数据)VLAN。
    有关配置语音VLAN的详细信息,可访问Cisco.com网站。

二、 VLAN中继
VLAN和VLAN中继有关密不可分的联系,如果没有VLAN中继,现代交换LAN中的VLAN实际上没有任何用处。
Cisco交换机在快速以太网和千兆以太网接口上支持IEEE 802.1Q中继格式。

  1. 本征VLAN配置

    S1# configure terminal
    S1(config)# interface f0/1
    S1(config-if)# switchport trunk native vlan 99
    S1(config)# end
    S1# show interface f0/1 switchport
    
  2. 配置VLAN
    命令模板

    S1# configure terminal
    S1(config)# vlan vlan-id
    S1(config-vlan)# name vlan-name
    S1(config-vlan)# end
    

    例3-5

    S1# configure terminal
    S1(config)# vlan 20
    S1(config-vlan)# name student
    S1(config-vlan)# end
    

    例3-6 显示vlan.dat文件的内容
    S1# show vlan brief
    例3-7 静态VLAN端口设置

    S1# configure terminal
    S1(config)# interface f0/18
    S1(config-if)# switchport mode access
    S1(config-if)# switchport access vlan 20
    S1(config-if)# end
    S1# show vlan brief
    
  3. 管理VLAN
    管理VLAN成员资格

    S1# configure terminal
    S1(config)# interface interface_id
    S1(config-if)# no switchport access vlan    #删除此端口分配的VLAN,恢复为默认的vlan1
    S1(config-if)# end
    

    例3-15 删除vlan

    S1# no vlan 20
    S1# show vlan brief
    
  4. 配置中继
    要在交换机端口上配置中继,可使用switchport mode trunk命令。
    表3-7 配置802.1Q中继

    S1# configure terminal
    S1(config)# interface interface_id
    S1(config-if)# switchport mode trunk
    S1(config-if)# switchport trunk native vlan vlan_id
    S1(config-if)# switchport trunk allowed vlan add vlan_list
    S1(config-if)# end
    

    例3-16 启动受限中继链路

    S1# configure terminal
    S1(config)# interface f0/1
    S1(config-if)# switchport mode trunk
    S1(config-if)# switchport trunk native vlan 99
    S1(config-if)# switchport trunk allowed vlan add 10,20,30
    S1(config-if)# end
    

    表3-8 修改IEEE 802.1Q中继

    S1(config-if)# no switchport trunk allowed vlan
    S1(config-if)# no switchport trunk native vlan
    S1(config-if)# switchport mode access
    

    例3-18 重置中继

    S1# configure terminal
    S1(config)# interface f0/1
    S1(config-if)# no switchport trunk allowed vlan
    S1(config-if)# no switchport trunk native vlan
    S1(config-if)# end
    

    例3-19 删除中继

    S1(config)# interface f0/1
    S1(config-if)# switchport mode access
    S1(config-if)#end
    S1# show interface f0/1 switchport