VLAN是很实用的技术,且工作中经常用到。实际工作中,采用三层交换机实现VLAN间的互通是最为广泛的,下面一起来做个简单的实验。
实验环境:三层交换机一台,PC机两台。可以使用模拟器完成实验,有条件的最好使用真设备。
实验拓扑:
SW-1的配置:(基本配置省略)
sw-1(config)#ip routing   --开启交换机路由功能
sw-1(config)#exit
sw-1(config)#vlan 10     --划分VLAN10  (不使用老方法划分)
sw-1(config-vlan)#vlan 20   --划分VLAN20
sw-1(config-vlan)#exit
sw-1(config)#interface f0/1
sw-1(config-if)#switchport mode access
sw-1(config-if)#switchport access vlan 10  --将f0/1加入VLAN10
sw-1(config-if)#int f0/2
sw-1(config-if)#switchport mode access
sw-1(config-if)#switchport access vlan 20   --将f0/2加入VLAN20
sw-1(config-if)#exit
 
查看VLAN信息:
sw-1(config)#int vlan 10    --进入VLAN10并指定IP地址及掩码
sw-1(config-if)#ip add 192.168.1.1 255.255.255.0
sw-1(config)#int vlan 20   --进入VLAN20并指定IP地址及掩码
sw-1(config-if)#ip add 192.168.2.1 255.255.255.0
sw-1(config-if)#exit
PC的配置:
因为直接用的PC机,所以直接在机器上设定好IP地址及默认网关即可。
 
验证测试:
PC1pingPC2:
 
PC2pingPC1:
 
成功连通,实验成功!