VLAN(Virtual LAN),翻译成中文是“虚拟局域网”。VLAN所指的LAN特指使用路由器分割的网络——也就是广播域,可以理解为一个独立的空间,valn是交换机经常使用的功能。
1.添加VLAN
第一种
Switch>enable //进入特权模式
Switch#configure terminal //进入配置模式
Switch(config)# vlan * //建立vlan * (*为数字,尽量不要设置为vlan1,因为vlan是作为默认vlan的)
cisco的设备支持65535个vlan
Switch(config-vlan)# name * // vlan的名字为*
第二种
Switch>enable //进入特权模式
Switch#vlan database //进入vlan库
Switch(vlan)# vlan * //没有就建立,有就可以设置
2.在vlan中添加端口
添加一个端口
Switch>enable
Switch#configure terminal //进入配置模式
Switch(config)# int f0/1
Switch(config-if)# switchport access vlan 10
添加多个端口
Switch>enable
Switch# configure terminal
Switch(config)# int range f0/1-5
Switch(config-if)# switchport access vlan 10
3.删除vlan
先删接口
switch(config)# int range f0/1-5或者int f0/1
switch(config-if)# no switchport access vlan 20
switch(config-if)# exit
再删除配置接口
switch(config)# no int vlan 20
删除VLAN
switch(config)# no vlan 20