实验1 是使用路由器来实现不同VLAN之间的互相访问,而我们还可以将路由器换成3层交换机来实现不同VLAN之间的访问
 
实验步骤:
a.首先在两台交换机上做VTP协议
    SW1(config)# vtp mode server
    SW1  (config)   # vtp domain cisconet
    SW1  (config)   # vtp password cisconet
 
    SW2  (config)   # vtp mode client
    SW2  (config)   # vtp domain cisconet
    SW1  (config)   # vtp password cisconet
 
注:SW1与SW2的VTP的名字与密码必须一致
 
b.然后再在SW1和SW2上配置TRUNK
    SW1(config) # interface fastethernet 0/1
    SW1(config) # switchport mode trunk
 
    SW2(config) # interface fastethernet 0/1
    SW2(config) # switchport mode trunk
 
 
c.然后创建VLAN2和VLAN3
    SW1 # vlan database
    SW1 # vlan 2
    SW1 # vlan 3
   
接着使用show vlan 查看SW2是否学习到SW1的VLAN2 和VLAN2
 
d.将SW1和SW2与PC相连的端口加入VLAN2和VLAN3
     SW1(config) # interface fastethernet 0/2
     SW1(config-if) # switchport mode access
     SW1(config-if) # switchport access vlan 2
     SW1(config) # interface fastethernet 0/3
     SW1(config-if) # switchport mode access
     SW1(config-if) # switchport access vlan 3
 
     SW2(config) # interface fastethernet 0/2
     SW2(config-if) # switchport mode access
     SW2(config-if) # switchport access vlan 2
     SW2(config) # interface fastethernet 0/3
     SW2(config-if) # switchport mode access
     SW2(config-if) # switchport access vlan 3
 
e.配置PC机的IP :  PC1:192.168.1.1/24
                                  PC2:192.168.2.1/24
                                  PC3:192.168.1.2/24
                                  PC4:192.168.2.2/24
然后测试以下相同VLAN之间的连通性
注:PC连交换用直通线
 
f.用一台3层交换机连SW1,并进行配置
     SW3 # vlan database
     SW3(VLAN) # vlan 2
     SW3(VLAN) # vlan 3
     SW3(config) # interface vlan 2
     SW3(config-if) # ip address 192.168.1.5   255.255.255.0
     SW3(config-if) # no shutdown
     SW3(config) # interface vlan 3
     SW3(config-if) # ip address 192.168.2.5   255.255.255.0
     SW3(config-if) # no shutdown
g.再给SW1和SW3相连的接口配置TRUNK
     SW3(config) # interface fastethernet 0/4
     SW3(config-if) # switchport mode trunk
     SW3(config-if) # no shutdown
 
     SW1(config) # interface fastethernet 0/4
     SW1(config-if) # switchport mode trunk
     SW1(config-if) # no shutdown
 
 
 
最后将PC1,PC3的网关设置为SW3的VLAN 2的IP
            PC2,PC4的网关设置为SW3的VLAN 3的IP
 
 
 
接着就是测试一下VLAN2与VLAN3的连通性了