1.实验环境
实验拓扑图结构如图12.12所示,其中PC1和PC3属于VLAN 2,PC2属于VLAN 3,PC1的IP
地址为192.168.0.2/24,PC2的P 地址为 192.168.1.2/24,PC3的P地址为192.168.0.3/24
2.需求描述
要求处于相同VLAN中的主机能够相互通信,处于不同VLAN中的主机不能相互通信
3.推荐步骤
- 在交换机上添加两个VLAN.
- 将交换机的第1~3端口分配给相应的VLAN
- 验证PC1和PC3是否能正常通信,而PC2无法和PC1、PC3通信
4.实验步骤
1.在交换机上添加两个VLAN
sw1(config)#vlan 2
sw1(config-vlan)#exit
sw1(config)#vlan 3
sw1(config-vlan)#exit
2.将交换机的第1端口分配给VLAN2
sw1(config)#interface fastEthernet 0/1
sw1(config-if)#switchport mode access
sw1(config-if)#switchport access vlan 2
sw1(config-if)#exit
3.将交换机的第2端口分配给VLAN3
sw1(config)#interface fastEthernet 0/2
sw1(config-if)#switchport mode access
sw1(config-if)#switchport access vlan 3
sw1(config-if)#exit
4.将交换机的第3端口分配给VLAN2
sw1(config)#interface fastEthernet 0/3
sw1(config-if)#switchport mode access
sw1(config-if)#switchport access vlan 2
sw1(config-if)#exit
5.验证PC1和PC3是否能正常通信
C:\>ping 192.168.0.3
Pinging 192.168.0.3 with 32 bytes of data:
Reply from 192.168.0.3: bytes=32 time<1ms TTL=128
Reply from 192.168.0.3: bytes=32 time<1ms TTL=128
Reply from 192.168.0.3: bytes=32 time<1ms TTL=128
Reply from 192.168.0.3: bytes=32 time<1ms TTL=128
Ping statistics for 192.168.0.3:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
C:\>
6.PC2无法和PC1、PC3通信
C:\>ping 192.168.0.2
Pinging 192.168.0.2 with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Ping statistics for 192.168.0.2:
Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
C:\>ping 192.168.0.3
Pinging 192.168.0.3 with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Ping statistics for 192.168.0.3:
Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
C:\>