各接口连接如下:
sw1 f0/0 与sw2 f0/0相连
sw1 f0/1 与PC1相连;f0/2 与PC2连
sw2 f0/1 与PC3相连;f0/2 与PC4连
 
实验说明:
    在sw 1,sw2分别划分两个vlan,vlan 2和vlan 3,将PC1和PC3加入vlan 2中,将PC2和PC4加入vlan 3中,
PC1--------ip地址:192.168.1.1
PC2--------ip地址:192.168.1.2
PC3--------ip地址:192.168.1.3
PC4--------ip地址:192.168.1.4
实现PC1,PC3;PC2,PC4互通,不同VLAN的PC不通.
Sw1 配置:

 

interface FastEthernet0/0

 switchport trunk encapsulation dot1q

 switchport mode trunk

!        

interface FastEthernet0/1

 switchport access vlan 2

!        

interface FastEthernet0/2

 switchport access vlan 3

!        

Sw2 配置:

 

interface FastEthernet0/0

 switchport trunk encapsulation dot1q

 switchport mode trunk

!        

interface FastEthernet0/1

 switchport access vlan 2

!        

interface FastEthernet0/2

 switchport access vlan 3

!        

 验证:在PC1上 ping 192.168.1.3

Sending 5, 100-byte ICMP Echos to 192.168.1.3, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 20/55/104 ms

同一个vlan的 能ping通

 

        ping 192.168.1.2

 

Sending 5, 100-byte ICMP Echos to 192.168.1.2, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5

   不同vlan 不能通