实验3 VLAN的划分与互通配置
实验学时:2 一、实验目的
1、掌握交换机的连接方法; 2、掌握交换机的基本配置; 3、掌握VLAN划分和设置。
二、实验设备与环境
Windows 2000 Server/Advance Server主机局域网、CISCO Catalyst 2950/2960/3560交换机,Cisco Packet Tracer 7.0软件。
三、预备知识
1、配置端口 1)配置一组端口
步骤
命令
目的 进入配置状态 进入组配置状态
使用端口配置命令进行配置 退回 验证配置
Step1 configure terminal
Step2 interface range {port-range} Step3 ?? Step4 end
Step5 show interfaces [interface-id]
Step6 copy running-config startup-config 保存
说明:
A、有效的组范围 vlan从1 到4094
fastethernet 槽位/{first port} - {last port}, 槽位为0 gigabitethernet槽位/{first port} - {last port},槽位为0
port-channel port-channel-number - port-channel-number, port-channel号从1到64 B、端口号之间需要加入空格,如:interface range fastethernet 0/1 – 5 是有效的, 而interface range fastethernet 0/1-5 是无效的.
C、interface range 命令只能配置已经存在的interface vlan D、所有在同一组的端口必须是相同类别的。 配置举例:
Switch# configure terminal
Switch(config)# interface range fastethernet0/1 - 5 Switch(config-if-range)# no shutdown
以下的例子显示使用句号来配置不同类型端口的组:
Switch# configure terminal
Switch(config)# interface range fastethernet0/1 - 3, gigabitethernet0/1 - 2 Switch(config-if-range)# no shutdown
1
CISCO Catalyst 1912/2950是二层交换机,而CISCO Catalyst 3550是三层交换机。3550的所有端口缺省的端口都是二层口,如果此端口已经配置成三层端口的话,则需要用switchport来使其成为二层端口。
2)配置端口速率及双工模式
可以配置快速以太口的速率为10/100Mbps及千兆以太口的速率为10/100/1000-Mbps; 但对于GBIC端口则不能配置速率及双工模式,当需要联接不支持自适应的其它千兆端口时,有时可以配置nonegotiate。
步骤
Step1 Step2 Step3 Step4 Step5 Step6 Step7
命令
configure terminal
interface interface-id.
speed {10 |100 |1000 |auto |nonegotiate} duplex {auto | full | half} end
show interfaces interface-id
copy running-config startup-config 目的
进入配置状态 进入端口配置状态 设置端口速率
设置全双工或半双工 退出
显示有关配置情况 保存
3)端口描述 步骤
命令
目的
Step1 configure terminal Step2 interface interface-id Step3 description string Step4 end
Step5 show interfaces interfaceid description
show running-config
Step6 copy running-config startup-config 配置举例:
Switch# config terminal
Switch(config)# interface fastethernet0/4
Switch(config-if)# description Connects to Marketing Switch(config-if)# end
Switch# show interfaces fastethernet0/4 description Interface Status Protocol Description Fa0/4 up down Connects to Marketing
4)配置三层口(3500系列三层交换机) 配置步骤如下: 步骤 命令
Step1 configure terminal
进入配置模式
进入要加描述的端口 加入描述 退回. 验证. 保存
目的 进入配置状态
Step2 interface {{fastethernet | gigabitethernet} 进入端口配置状态
interface-id}|{vlan vlan-id}|{port-channel
2
port-channel-number}
Step3 no switchport
Step4 ip address ip_address subnet_mask Step5 no shutdown Step6 end
Step7 show interfaces [interface-id]
show ip interface [interface-id]
show running-configinterface [interface-id] Step8 copy running-config startup-config
把物理端口变成三层口 配置IP地址和掩码 激活端口 退出 验证配置
保存配置
配置举例:
Switch# configure terminal
Enter configuration commands, one per line. End with CNTL/Z. Switch(config)# interface gigabitethernet0/2 Switch(config-if)# no switchport
Switch(config-if)# ip address 192.20.135.21 255.255.255.0 Switch(config-if)# no shutdown Switch(config-if)# end 2、监控及维护端口 监控端口和控制器的状态: 命令
show interfaces [interface-id]
目的
显示所有端口或某一端口的状态和配置.
Show interfaces interface-id status 显示一系列端口的状态或错误-关闭的状态 [err-disabled]
show interfaces [interface-id] switchport 显示二层端口的状态,可以用来决定此口是否
为二层或三层口。
show interfaces [interface-id] description 显示端口描述 show ip interface [interface-id] 显示所有或某一端口的IP可用性状态 show running-config interface [interface-id] show version
刷新、重置端口及计数器: Clear命令
clear counters [interface-id]
clear interface interface-id
clear line [number | console 0 | vty number] 关
闭
步骤 命令
Step1 configure terminal
和
打
目的
清除端口计数器. 重置某一端口的硬件逻辑 重置异步串口的硬件逻辑
开
端目的 进入配置状态
口
:
显示当前配置中的端口配置情况 显示软硬件等情况
Step2 interface {vlan vlan-id} | {{fastethernet | 选择要关闭的端口
gigabitethernet} interface-id} | {port-channel port-channel-number} Step3 Shutdown(no shutdown)
关闭(打开)
3
Step4 end
Step5 show running-config 3、配置VLAN
退出 验证
一个VLAN就是一个交换网,其逻辑上按功能、项目、应用来分而不必考虑用户的物理位置。任何交换口都可以属于某一VLAN,IP包、广播包及组播包均可以发送或广播给在此VLAN内的最终用户。每一个VLAN均可看成是一个逻辑网络,发往另一VLAN的数据包必须由路由器或网桥转发(如下图)。由于VLAN被看成是一个逻辑网络,其具有自己的网桥管理信息庫 (MIB) 并可支持自己的生成树。 VLAN作为逻辑定义的网络示意图
VLAN常常与IP子网相联系,同一IP子网属于同一VLAN。在VLAN之间的数据包可以由VLAN端口进行转发。Catalyst 3550交换机支持1005个 VLAN,可以分别是VTP client、server及 transparent modes.。 VLAN号可以从1到4094,VLAN号1002到1005保留给令牌环及FDDI。VLAN VTP只能学习到普通范围的VLAN, 即从VLAN到1到1005; VLAN号大于1005属于扩展VLAN,不存在VLAN数据库中。当需要生成VLAN 号从1006到4094时交换机必须配置成VTP透明模式。 1)配置普通范围的VLAN
VLAN号1,1002到1005是自动生成的不能被去掉。VLAN号1到1005的配置被写到文件vlan.dat 中, 可以用show vlan 命令查看, vlan.dat 文件存放在NVRAM中。不要手工删除vlan.dat 文件,可能造成VLAN的不完整。如要删除vlan需要用有关的命令来进行。 生成、修改以太网VLAN: 步骤 命令
Step1 configure terminal Step2 vlan vlan-id
目的 进入配置状态
输入一个VLAN号, 然后进入vlan配置
4
状态,可以输入一个新的VLAN号或旧的来进行修改。
Step3 name vlan-name
(可选)输入一个VLAN名,如果没有配置VLAN名,缺省的名字是VLAN号前面用0填满的4位数,如VLAN0004是VLAN4的缺省名字 (可选) 改变MTU大小 退出
(可选) 保存配置
Step4 mtu mtu-size Step5 end
Step7 copy running-config startup config 也可以在enable状态下,进行VLAN配置: 步骤 命令 Step1 vlan database
Step2 vlan vlan-id name vlan-name Step3 vlan vlan-id mtu mtu-size Step4 exit
Step6 copy running-config startup config 删除VLAN:
Step6 show vlan {name vlan-name | id vlan-id} 验证
目的
进入VLAN配置状态 加入VLAN号及VLAN名 (可选) 修改MTU大小 更新VLAN数据庫并退出 保存配置(可选)
Step5 show vlan {name vlan-name | id vlan-id} 验证配置
当删除一个处于VTP服务器的交换机上删除VLAN时,则此VLAN将在所有相同VTP的交换机上删除。当在透明模式下删除时,只在当前交换机上删除。当删除一个VLAN时,原来属于此VLAN的端口将处于非激活的状态,直到将其分配给某一VLAN。 步骤 命令
Step1 configure terminal Step2 no vlan vlan-id Step3 end
Step4 show vlan brief
Step5 copy running-config startup config 将端口分配给一个VLAN: 步骤 命令
Step1 configure terminal Step2 interface interface-id Step3 switchport mode access Step4 switchport access vlan vlan-id Step5 end
Step6 show running-config interface interface-id Step7 show interfaces interface-id switchport Step8 copy running-config startup-config
5
目的 进入配置状态 删除某一VLAN. 退出 验证 保存
目的 进入配置状态 进入要分配的端口
定义二层口(用于三层交换机) 把端口分配给某一VLAN 退出
验证端口的VLAN号
验证端口管理模式和VLAN情况 保存配置