实现不同vlan间PC不可访问,不同vlan的PC均可访问服务器的效果,具体要求如下
方案
使用eNSP搭建实验环境
步骤
配置第一台交换机
ps:交换机1与pc的接口为0/0/1,与pc的接口为0/0/2,交换机与交换机之间的接口为0/0/3,交换机2与pc3的接口为0/0/1@H_403_22@
[SW1]vlan batch 5 10 50 //创建5 10 50的vlan [SW1]interface Ethernet0/0/1 //进入接口0/0/1 [SW1-Ethernet0/0/1]port hybrid untagged vlan 5 50 //此端口发送vlan5 10 50数据帧时不带标签 [SW1-Ethernet0/0/1]port hybrid pvid vlan 5 //把端口加入vlan5 [SW1]interface Ethernet0/0/2 //进入接口0/0/2 [SW1-Ethernet0/0/2]port hybrid untagged vlan 10 50 //此端口发送vlan10 50数据帧时不带标签 [SW1-Ethernet0/0/2]port hybrid pvid vlan 10 //把端口接入vlan10 [SW1]interface Ethernet0/0/3 //进入接口0/0/3 [SW1-Ethernet0/0/3]port hybrid tagged vlan 5 10 50 //此端口发送vlan 5 10 50数据帧时加标签 [SW1]dis vlan //查看路由表 The total number of vlans is : 4 ------------------------------------------------------------------ U: Up; D: Down; TG: Tagged; UT: Untagged; MP: Vlan-mapping; ST: Vlan-stacking; #: ProtocolTransparent-vlan; *: Management-vlan; -------------------------------------------------------------------- VID Type Ports -------------------------------------------------------------------------------- 1 common UT:Eth0/0/1(U) Eth0/0/2(U) Eth0/0/3(U) Eth0/0/4(D) Eth0/0/5(D) Eth0/0/6(D) Eth0/0/7(D) Eth0/0/8(D) Eth0/0/9(D) Eth0/0/10(D) Eth0/0/11(D) Eth0/0/12(D) Eth0/0/13(D) Eth0/0/14(D) Eth0/0/15(D) Eth0/0/16(D) Eth0/0/17(D) Eth0/0/18(D) Eth0/0/19(D) Eth0/0/20(D) Eth0/0/21(D) Eth0/0/22(D) GE0/0/1(D) GE0/0/2(D) 5 common UT:Eth0/0/1(U) TG:Eth0/0/3(U) 10 common UT:Eth0/0/2(U) //在这里可以看到哪个端口去标签哪个端口带加标签 TG:Eth0/0/3(U) //UT去标签,TG加标签 50 common UT:Eth0/0/1(U) Eth0/0/2(U) TG:Eth0/0/3(U) VID Status Property MAC-LRN Statistics Description -------------------------------------------------------------------- 1 enable default enable disable VLAN 0001 5 enable default enable disable VLAN 0005 10 enable default enable disable VLAN 0010 50 enable default enable disable VLAN 0050 [SW1]dis port vlan 显示交换机所有端口的vlan信息 Port Link Type PVID Trunk VLAN List -------------------------------------------------------------------- Ethernet0/0/1 hybrid 5 - Ethernet0/0/2 hybrid 10 - Ethernet0/0/3 hybrid 1 5 10 50 Ethernet0/0/4 hybrid 1 - Ethernet0/0/5 hybrid 1 - Ethernet0/0/6 hybrid 1 - Ethernet0/0/7 hybrid 1 - Ethernet0/0/8 hybrid 1 - Ethernet0/0/9 hybrid 1 - Ethernet0/0/10 hybrid 1 - Ethernet0/0/11 hybrid 1 - Ethernet0/0/12 hybrid 1 - Ethernet0/0/13 hybrid 1 - Ethernet0/0/14 hybrid 1 - Ethernet0/0/15 hybrid 1 - Ethernet0/0/16 hybrid 1 - Ethernet0/0/17 hybrid 1 - Ethernet0/0/18 hybrid 1 - Ethernet0/0/19 hybrid 1 - Ethernet0/0/20 hybrid 1 - Ethernet0/0/21 hybrid 1 - Ethernet0/0/22 hybrid 1 - GigabitEthernet0/0/1 hybrid 1 - GigabitEthernet0/0/2 hybrid 1 -
配置第二台交换机@H_403_22@
[SW2]vlan batch 5 10 50 //创建5 10 50的vlan [SW2]interface Ethernet0/0/1 //进入0/0/1接口 [SW2-Ethernet0/0/1]port hybrid tagged vlan 5 10 50 //此端口发送vlan5 10 50数据帧时加标签 [SW2]interface Ethernet0/0/2 //进入接口0/0/2 [SW2-Ethernet0/0/2]port hybrid untagged vlan 5 10 50 //此端口发送vlan 5 10 50的数据帧时去标签 [SW2-Ethernet0/0/2]port hybrid pvid vlan 50 //把端口加入vlan50 [SW2]dis vlan //查看路由表 The total number of vlans is : 4 -------------------------------------------------------------------- U: Up; D: Down; TG: Tagged; UT: Untagged; MP: Vlan-mapping; ST: Vlan-stacking; #: ProtocolTransparent-vlan; *: Management-vlan; -------------------------------------------------------------------- VID Type Ports -------------------------------------------------------------------------------- 1 common UT:Eth0/0/1(U) Eth0/0/2(U) Eth0/0/3(D) Eth0/0/4(D) Eth0/0/5(D) Eth0/0/6(D) Eth0/0/7(D) Eth0/0/8(D) Eth0/0/9(D) Eth0/0/10(D) Eth0/0/11(D) Eth0/0/12(D) Eth0/0/13(D) Eth0/0/14(D) Eth0/0/15(D) Eth0/0/16(D) Eth0/0/17(D) Eth0/0/18(D) Eth0/0/19(D) Eth0/0/20(D) Eth0/0/21(D) Eth0/0/22(D) GE0/0/1(D) GE0/0/2(D) 5 common UT:Eth0/0/2(U) TG:Eth0/0/1(U) 10 common UT:Eth0/0/2(U) TG:Eth0/0/1(U) 50 common UT:Eth0/0/2(U) TG:Eth0/0/1(U) VID Status Property MAC-LRN Statistics Description -------------------------------------------------------------------- 1 enable default enable disable VLAN 0001 5 enable default enable disable VLAN 0005 10 enable default enable disable VLAN 0010 50 enable default enable disable VLAN 0050 [SW2]dis port vlan // 查看交换机所有端口的vlan信息 Port Link Type PVID Trunk VLAN List ------------------------------------------------------------------- Ethernet0/0/1 hybrid 1 5 10 50 Ethernet0/0/2 hybrid 50 - Ethernet0/0/3 hybrid 1 - Ethernet0/0/4 hybrid 1 - Ethernet0/0/5 hybrid 1 - Ethernet0/0/6 hybrid 1 - Ethernet0/0/7 hybrid 1 - Ethernet0/0/8 hybrid 1 - Ethernet0/0/9 hybrid 1 - Ethernet0/0/10 hybrid 1 - Ethernet0/0/11 hybrid 1 - Ethernet0/0/12 hybrid 1 - Ethernet0/0/13 hybrid 1 - Ethernet0/0/14 hybrid 1 - Ethernet0/0/15 hybrid 1 - Ethernet0/0/16 hybrid 1 - Ethernet0/0/17 hybrid 1 - Ethernet0/0/18 hybrid 1 - Ethernet0/0/19 hybrid 1 - Ethernet0/0/20 hybrid 1 - Ethernet0/0/21 hybrid 1 - Ethernet0/0/22 hybrid 1 - GigabitEthernet0/0/1 hybrid 1 - GigabitEthernet0/0/2 hybrid 1 -
测试
vlan5与vlan10的pc之间不能互相访问,但是都可以访问vlan50的服务器@H_403_22@