实现同一 Vlan 内的主机互通,不同 Vlan 间的主机隔离。
创建vlan10,并将接口一配置为access模式,然后将接口放入vlan10
Switch#config t ?????进入配置模式
Switch(config)#vlan 10???创建vlan10
Switch(config-vlan)#end??返回全局模式
Switch#show ip int br????查看接口编号,我的是2/0/X
Switch#config t???????????????进入配置模式
Switch(config)#interface f2/0/1 ?进入1接口
Switch(config-if)#switchport mode access ??设置为access模式
Switch(config-if)#switchport access vlan 10??将1接口放入vlan10
Switch(config-if)#exit
创建vlan20,并将接口一配置为access模式,然后将接口放入vlan20
Switch(config)#vlan 20????????创建vlan20
Switch(config-vlan)#int f2/0/2??进入2接口
Switch(config-if)#switchport mode access???设置为access模式
Switch(config-if)#switchport access vlan 20??将2接口放入vlan20
Switch(config)#end
Switch#show int f2/0/1 switchport ??显式1接口详细信息
Mode显式为access表示成功,查看2接口同理
将11接口设置为trunk模式
选择交换机1
Switch#config t???????????进入配置模式
Switch(config)#int f2/0/11 ?进入11接口
Switch(config-if)#switch trunk encapsulation dot1q???配置封装协议为802.1Q
Switch(config-if)#switchport mode trunk ??????????设置接口模式为trunk
Switch(config-if)#switchport trunk allowed vlan all 允许所有vlan可通过
Switch(config-if)#end
Switch#show int f2/0/11 switchport??查看11接口详细信息
Mode显式trunk表示设置成功
步骤与上述配置交换机1相同,不再赘述
确保四台PC处于同一网段192.168.1.X
这里四台PC的IP分别为
192.168.1.1(PC1) 192.168.1.2(PC2)
192.168.1.3(PC3) 192.168.1.4(PC4)
PC1通过1接口ping ?PC2不通,因为属于不同vlan且采用access模式连接
PC1通过11接口ping ?PC3能通,因为同属vlan10且采用trunk模式连接