一、实验拓扑图:
二、实验要求:
1.将所有的交换机名称改为对应的S1 S2 S3。
2.从PC1上分别PING PC2-PC6的IP,能否PING通?
3.按拓扑图中所示,分别将PC划分到相应的交换机的VLAN中。
4.再次从PC1上分别PING PC2-PC6的IP,能否PING通?
三、配置命令与原因分析:
1.将所有的交换机名称改为对应的S1 S2 S3。
S1上配置命令:
#
sysname S1
S2上配置命令:
#
sysname S2
S3上配置命令:
#
sysname S3
2.从PC1上分别PING PC2-PC6的IP,能否PING通?答:所有PC都能互通,因为它们都处于同一个广播域并且同一网段下(192.168.1.X)。
3.按拓扑图中所示,分别将PC划分到相应的交换机的VLAN中。答:将PC划分到相应交换机的VLAN中后:处于相同VLAN的PC才能够互通,不同VLAN下的PC之间不能互通。 【注:每个交换机都要创建VLAN10 20 30 这3个VLAN,不然会出现PC1 ping不通PC2的情况,原因是STP协议的防环机制。】
S1上配置命令:
vlan batch 10 20 30
#
interface Ethernet0/0/1
port link-type trunk
port trunk allow-pass vlan all
#
interface Ethernet0/0/2
port link-type trunk
port trunk allow-pass vlan all
#
interface Ethernet0/0/3
port link-type access
port default vlan 10
#
interface Ethernet0/0/4
port link-type access
port default vlan 30
#
S2上配置命令:
vlan batch 10 20 30
#
interface Ethernet0/0/1
port link-type trunk
port trunk allow-pass vlan all
#
interface Ethernet0/0/2
port link-type access
port default vlan 10
#
interface Ethernet0/0/3
port link-type access
port default vlan 20
#
interface Ethernet0/0/4
port link-type trunk
port trunk allow-pass vlan all
S3上配置命令:
vlan batch 10 20 30
#
interface Ethernet0/0/1
port link-type trunk
port trunk allow-pass vlan all
#
interface Ethernet0/0/2
port link-type access
port default vlan 30
#
interface Ethernet0/0/3
port link-type access
port default vlan 20
#
interface Ethernet0/0/4
port link-type trunk
port trunk allow-pass vlan all
四、验证:
4.再次从PC1上分别PING PC2-PC6的IP,能否PING通?
①拿PC1 ping同一VLAN下的PC6,能通信:
通过抓包软件抓取S1上的接口E0/0/3,可以看到来自PC1的request请求报文和PC6回复给PC1的reply应答报文。
②拿PC1 ping不同VLAN下的PC2,不能通信:
实验结束...