一、将PC0、PC1、PC2、PC3 IP地址分别设置为192.168.1.2、192.168.1.3、192.168.1.4、192.168.1.5,子网掩码都设置为255.225.255.0,网关也都设置为192.168.1.1。
接下来我们将PC0和PC2划分到vlan 2当中,将PC1和划PC3分到vlan 3当中。
第一台交换机配置如下:
Switch>en
Switch#conf t //进入全局配置模式
Switch(config)#hostname Switch1 //修改交换机的名字
Switch1(config)#vlan 2 //创建vlan 2
Switch1(config-vlan)#exit
Switch1(config)#vlan 3 //创建vlan 3
Switch1(config-vlan)#exit
Switch1(config)#int fa 0/1 //打开0/1端口
Switch1(config-if)#switchport access vlan 2 // 将端口换分到vlan 2中
Switch1(config-if)#exit
Switch1(config)#int fa 0/2 //打开0/2端口
Switch1(config-if)#switchport access vlan 3 // 将端口换分到vlan 3中
Switch1(config-if)#exit
Switch1(config)#int fa 0/3 //打开0/3端口
Switch1(config-if)#switchport mode trunk //将端口设置为trunk模式
第二台交换机配置如下:
Switch>en
Switch#conf t
Switch(config)#hostname Switch2
Switch2(config)#vlan 2
Switch2(config-vlan)#exit
Switch2(config)#vlan 3
Switch2(config-vlan)#exit
Switch2(config)#int fa 0/1
Switch2(config-if)#switchport access vlan 2
Switch2(config-if)#exit
Switch2(config)#int fa 0/2
Switch2(config-if)#switchport access vlan 3
Switch2(config-if)#exit
Switch2(config)#int fa 0/3
Switch2(config-if)#sw
Switch2(config-if)#switchport mode trunk
二、不同vlan之间测试一下,用PC0去ping一下PC1,此时是ping不通的,如果ping通那证明我们实验失败。
同vlan之间测试一下,用PC3去ping一下PC1,此时是能ping通的,如果ping通,恭喜你!实验成功。