基于端口划分VLAN实例
1、如图连接4台PC机至交换机1-4号以太网接口。





15、创建10号、20号VLAN。Switch(config)#vlan10 name NO1外狒芙梨VLAN (创建VLAN10)Switch(config)#vlan20 name N晦倘佳鳎O2VLAN (创建VLAN20)
16、将交换机1号、3号以太网接口划分到10号VLAN,2号、4号接口划分到20号V雉搽妤粲LAN。Switch(config)#interfaceethernet 0/1(进入E1端口子配置模式)Switch(config-if)#vlan-membershipstatic 10 (将E1口划入VLAN10)Switch(config-if)#exit (返回全局模式)Switch(config)#interfaceethernet 0/2(进入E2端口子配置模式)Switch(config-if)#vlan-membershipstatic 20 (将E2口划入VLAN20)Switch(config-if)#exit (返回全局模式)Switch(config)#interfaceethernet 0/3(进入E3端口子配置模式)Switch(config-if)#vlan-membershipstatic 10 (将E3口划入VLAN11)Switch(config)#interface ethernet 0/4(进入E4端口子配置模式)Switch(config-if)#vlan-membership static 20 (将E4口划入VLAN20)Switch(config-if)#end (返回特权模式)
17、使用show vlan指令查看当前VLAN划分情况。相比此前查看到的VLAN情况,Ethernet接口部分多了10号、20号VLAN,并且1、3号接口属于10号VLAN,2、4号接口属于20号VLAN。

22、PC1机pingPC2机、PC4机此时却不通了:

26、PC2机pingPC1机、PC3机此时却不通了:
