查看文章 |
在全局配置模式下创建VLAN v Switch(config)#vlan vlan-id v Switch(config-vlan)#name vlan-name
进入VLAN 数据库创建VLAN v Switch#vlan database v Switch(vlan)#vlan 2 VLAN 2 added: Name: VLAN0002 v Switch(vlan)#exit APPLY completed. Exiting.... 删除已创建的VLAN v Switch#vlan database v Switch(vlan)#no vlan 2 Deleting VLAN 2... 或: v Switch(config)#no vlan 2
将端口加入VLAN v Switch(config)# interface f0/1 v Switch(config-if)# switchport access vlan vlan-id v Switch(config-if)# no switchport access vlan vlan-id
Switch(config)# interface range f0/1 – 10 Switch(config-if-range)# switchport access vlan vlan-id
验证VLAN的配置 v Switch# show vlan brief v Switch# show vlan id vlan-id
VLAN配置实例 Switch#vlan database Switch(vlan)#vlan 2 name v2 VLAN 2 added: Name: v2 Switch(vlan)#exit APPLY completed. Exiting.... Switch#config terminal Switch(config)#interface range f0/5 - 10 Switch(config-if-range)#switchport access vlan 2
查看VLAN配置 v Switch#show vlan brief
VLAN Name Status Ports ---- -------------------------------- --------- ------------------------------- 1 default active Fa0/1, Fa0/2, Fa0/3, Fa0/4 Fa0/11, Fa0/12, Fa0/13, Fa0/14 Fa0/15, Fa0/16, Fa0/17, Fa0/18 Fa0/19, Fa0/20, Fa0/21, Fa0/22 Fa0/23, Fa0/24 2 v2 active Fa0/5, Fa0/6, Fa0/7, Fa0/8 Fa0/9, Fa0/10 1002 fddi-default active 1003 token-ring-default active 1004 fddinet-default active 1005 trnet-default active
其他常用命令 v 其他常用命令 § 指定/删除VLAN描述字符 • description string • no description § 查看VLAN设置 • show vlan [vlan_id ] § 开启/关闭VLAN接口 • shutdown • no shutdown • ?的使用 v Switch# ? Exec commands: access-enable Create a temporary Access-List entry access-template Create a temporary Access-List entry archive manage archive files cd Change current directory clear Reset functions clock Manage the system clock cns CNS subsystem configure Enter configuration mode connect Open a terminal connection copy Copy from one file to another debug Debugging functions (see also 'undebug') delete Delete a file dir List files on a filesystem disable Turn off privileged commands disconnect Disconnect an existing network connection dot1x IEEE 802.1X commands enable Turn on privileged commands v Switch(config)#s? scheduler service shutdown snmp snmp-server spanning-tree stackmaker system v Switch(config)#spanning-tree ? backbonefast Enable BackboneFast Feature etherchannel Spanning tree etherchannel specific configuration extend Spanning Tree 802.1t extensions loopguard Spanning tree loopguard options mode Spanning tree operating mode pathcost Spanning tree pathcost options portfast Spanning tree portfast options uplinkfast Enable UplinkFast Feature vlan VLAN Switch Spanning Tree
Tab键的使用 v Switch(config)#ena v Switch(config)#enable
使用命令简写 v Switch>en v Switch#conf t v Switch(config)#ena pass 123
使用缓存命令 v 使用向上箭头,出现上一次执行的命令 v Switch# show history
阶段总结: î 划分VLAN的作用 ø 控制广播 ø 安全性 î VLAN的种类 ø 静态VLAN-基于端口划分的 ø 动态VLAN-基于MAC地址 î VLAN的配置 ø 添加VLAN、删除VLAN ø 将端口加入VLAN ø 查看VLAN的配置
ISL和802.1Q 的异同 v 相同点 § 都是显式标记,即帧被显式标记了VLAN的信息 v 不同点 § IEEE 802.1Q是公有的标记方式,ISL是Cisco私有的 § ISL采用外部标记的方法,802.1Q采用内部标记的方法 § ISL标记的长度为30字节,802.1Q标记的长度为4字节
配置接口为Trunk模式 Switch(config)# interface interface-id Switch(config-if)#switchport mode ? access Set trunking mode to ACCESS unconditionally dynamic Set trunking mode to dynamically negotiate access or trunk mode trunk Set trunking mode to TRUNK unconditionally Switch(config-if)#switchport mode trunk
配置接口为动态协商模式 v Switch(config-if)#switchport mode dynamic ? auto Set trunking mode dynamic negotiation parameter to AUTO desirable Set trunking mode dynamic negotiation parameter to DESIRABLE
查看接口模式 Switch#show interface interface-id switchport Name: Fax/x Switchport: Enabled Administrative Mode: dynamic desirable Operational Mode: down Administrative Trunking Encapsulation: dot1q Negotiation of Trunking: On Access Mode VLAN: 1 (default) Trunking Native Mode VLAN: 1 (default) Voice VLAN: none Administrative private-vlan host-association: none Administrative private-vlan mapping: none Operational private-vlan: none Trunking VLANs Enabled: ALL Pruning VLANs Enabled: 2-1001 Capture Mode Disabled Capture VLANs Allowed: ALL
配置VLAN Trunk v 第一步:在交换机上添加VLAN SW1#vlan database SW1(vlan)#vlan 2 VLAN 2 added: Name: VLAN0002 SW1(vlan)#vlan 3 VLAN 3 added: Name: VLAN0003 SW1(vlan)#exit APPLY completed. Exiting.... v 第二步:将接口添加到相应的VLAN中 SW1#config terminal SW1(config)#interface range f0/4 - 10 SW1(config-if-range)#switchport access vlan 2 SW1(config)#interface range f0/11 - 23 SW1(config-if-range)#switchport access vlan 3 v 第三步:配置交换机之间互联的端口为Trunk SW1(config)#interface f0/24 SW1(config-if)#switchport mode trunk 查看端口状态 SW1#show interface f0/24 switchport Name: Fa0/24 Switchport: Enabled Administrative Mode: trunk Operational Mode: trunk Administrative Trunking Encapsulation: dot1q Operational Trunking Encapsulation: dot1q Negotiation of Trunking: On Access Mode VLAN: 1 (default) Trunking Native Mode VLAN: 1 (default) Voice VLAN: none Administrative private-vlan host-association: none Administrative private-vlan mapping: none Operational private-vlan: none Trunking VLANs Enabled: ALL Pruning VLANs Enabled: 2-1001 Capture Mode Disabled Capture VLANs Allowed: ALL |