A-A+
Cisco交换机Vlan的划分的一些思路
Cisco交换机的vlan划分,这个是基础中的基础,VLAN(Virtual LocalArea Network)的中文名为“虚拟局域网”。VLAN是一种将局域网设备从逻辑上划分成一个个网段,从而实现虚拟工作组的新兴数据交换技术。这一新兴技术主要应用于交换机和路由器中,但主流应用还是在交换机之中。但又不是所有交换机都具有此功能,只有VLAN协议的第二层以上交换机才具有此功能,这一点可以查看相应交换机的说明书即可得知。一般的,交换机默认配置都是具有vlan 1的,所有端口均在vlan 1下。
配置实例:
- switch>en //进入特权模式
- switch#vlan database //进入vlan数据库
- switch(vlan)#vlan 2 name lab //创建vlan 2,名称为lab
- switch(vlan)#vlan 3 name administration //创建vlan 3,名称为administration
- switch(vlan)#exit //退出vlan数据库,此时交换机会自动保存vlan信息数据,当然也有个别交换机需要输入apply命令进行保存,保存后输入exit进行退出。
- switch#show vlan //查看vlan信息
- VLAN Name Status Ports
- —- ——————————– ——— ——————————-
- 1 default active Fa0/1, Fa0/2, Fa0/3, Fa0/4
- Fa0/5, Fa0/6, Fa0/7, Fa0/8
- Fa0/9, Fa0/10, 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
- Gig0/1, Gig0/2
- 2 lab active //刚刚我创建的vlan 2的信息
- 3 administration active //刚刚我创建的vlan 3的信息
- 1002 fddi-default act/unsup
- 1003 token-ring-default act/unsup
- 1004 fddinet-default act/unsup
- 1005 trnet-default act/unsup
- VLAN Type SAID MTU Parent RingNo BridgeNoStp BrdgMode Trans1 Trans2
- —- —– ———- —– —— —— ——– —- ——– —— ——
- 1 enet 100001 1500 – – – – – 0 0
- 2 enet 100002 1500 – – – – – 0 0
- 3 enet 100003 1500 – – – – – 0 0
- 1002 fddi 101002 1500 – – – – – 0 0
- 1003 tr 101003 1500 – – – – – 0 0
- 1004 fdnet 101004 1500 – – – ieee – 0 0
- 1005 trnet 101005 1500 – – – ibm – 0 0
- Remote SPAN VLANs
- ——————————————————————————
- PrimarySecondary Type Ports
- ——- ——— —————– ——————————————
- switch#conf t //进入全局配置模式
- switch(config)#int vlan 1 //进入vlan 1接口,默认vlan 1是存在的,不用我们在vlan数据库中添加
- switch(config-if)#ip add 192.168.0.254 255.255.255.0 //配置vlan 1接口下的ip地址为192.168.0.254,掩码为255.255.255.0
- switch(config-if)#no shut //启用vlan 1接口
- switch(cofnig-if)#int vlan 2 //进入vlan 2接口
- switch(config-if)#ip add 192.168.2.254 255.255.255.0 //配置vlan 2接口下的ip地址为2.254
- switch(config-if)#no shut //启用vlan 2接口
- switch(config-if)#int vlan 3 //进入vlan 3接口
- switch(config-if)#ip add 192.168.3.254 255.255.255.0 //配置vlan 3接口下的ip地址为3.254
- switch(config-if)#no shut //启用vlan 3接口
- switch(config-if)#int f0/2 //进入交换机的f0/2端口
- switch(config-if)#switchport mode access //端口模式为access模式
- switch(config-if)#switchport access vlan 2 //将f0/2端口划分到vlan 2下
- switch(config-if)#no shut //启用f0/2端口
- switch(config-if)#int f0/3 //进入交换机的f0/3端口
- switch(config-if)#switchport mode access //f0/3端口模式为access模式
- switch(config-if)#switchport access vlan 3 //将f0/3端口模式划分到vlan 3下
- switch(config-if)#no shut //启用f0/3端口
- switch(config-if)#^Z //Ctrl+Z返回特权模式
- switch#write //将设置保存到startup-config配置文件中,即flash:目录下的config.text中
至此vlan的简单划分就完成了,我们可以通过show vlan命令查看我们划分的vlan信息,这里就不列出来了。