VLAN隔离应用场景

场景1:同一设备下挂的用户属于同一VLAN,需要禁止某些用户访问。

场景2:设备下挂许多用户,需要

  • 部分VLAN间可以互通
  • 部分VLAN间隔离
  • VLAN内用户隔离

场景3:VLAN间三层互通后,需要禁止部分用户互访或者只允许用哪个和单向互访。

端口隔离

如果不希望同一VLAN下某些用户进行互通,可以通过配置端口隔离实现。用户只需要将端口加入到隔离组中,就可以实现隔离组内端口直接二层数据的隔离。

拓扑图
1652762414254_0.png

需求:PC1与PC2在VLAN10内不能相互访问,但是,PC3与PC1、PC2之间能相互访问。

关键配置

[SW1]interface GigabitEthernet 0/0/1 #进入接口1配置模式 
[SW1-GigabitEthernet0/0/1]port link-type access #端口模式修改成access 
[SW1-GigabitEthernet0/0/1]port default vlan 10 #接口1加入到VLAN10中 
[SW1-GigabitEthernet0/0/1]port-isolate enable #开启端口隔离 
[SW1]interface GigabitEthernet 0/0/2 
[SW1-GigabitEthernet0/0/2]port link-type access 
[SW1-GigabitEthernet0/0/2]port default vlan 10 
[SW1-GigabitEthernet0/0/2]port-isolate enable

验证结果
1652762414254_1.png

通过上图可以看到虽然PC1与PC2属于同一VLAN,但是不能通信的。PC3与PC1、PC2是能正常通信的。

MUX VLAN

MUX VLAN只适用于二层网络中,对同一网段的用户进行部分VLAN间互通、部分VLAN间隔离和VLAN内用户隔离。

拓扑图
1652762414254_2.png

需要:

  • 所有用户都能访问server。
  • PC1和PC2可以互访,和PC3、PC4不能互访;
  • PC3和PC4之间隔离,不能互访。

关键配置

[SW1]vlan 2 
[SW1-vlan2]mux-vlan #指定VLAN2为Principal VLAN 
[SW1-vlan2]subordinate group 3 #指定VLAN3为Group VLAN 
[SW1-vlan2]subordinate separate 4 #指定VLAN4为Separate VLAN 
[SW1-vlan2]quit [SW1]interface GigabitEthernet 0/0/24 
[SW1-GigabitEthernet0/0/24]port link-type access 
[SW1-GigabitEthernet0/0/24]port default vlan 2 
[SW1-GigabitEthernet0/0/24]port mux-vlan enable GE0/0/1-GE0/0/4配置类型,不再赘述

验证结果
1652762414254_3.png
1652762414254_4.png

基于流策略的VLAN隔离

VLAN间三层互通后,如果需要禁止部分用户互访或者只允许用户单向访问,则需要配置VLAN间三层隔离功能。VLAN间三层隔离一般通过流策略实现。

拓扑图
1652762414254_5.png

需求:

  • VALN10、VLAN20、VLAN30均可以访问互联网。
  • 访客只能访问互联网,不能与其他任何VLAN的用户通信
  • 员工A可以访问服务器区的所有资源,但其他员工只能访问服务器A的21端口。

关键配置

[SW1]acl 3000 
[SW1-acl-adv-3000]rule deny ip destination 192.168.3.0 0.0.0.255 #禁止访客访问员工区 
[SW1-acl-adv-3000]rule deny ip destination 192.168.2.0 0.0.0.255 #禁止访客访问服务区 
[SW1]acl 3001 #员工A可以访问服务器的所有资源 
[SW1-acl-adv-3001]rule permit ip source 192.168.2.30 0 destination 192.168.3.0 0 .0.0.255 #其他员工只能访问192.168.3.100服务器的21端口 
[SW1-acl-adv-3001]rule permit tcp destination 192.168.3.100 0 destination-port e q 21 
[SW1-acl-adv-3001]rule deny ip destination 192.168.3.0 0.0.0.255 [SW1]traffic classifier c_custom 
[SW1-classifier-c_custom]if-match acl 3000 #匹配流分类c_custom,匹配acl 3000 
[SW1-classifier-c_custom]q 
[SW1]traffic classifier c_staff 
[SW1-classifier-c_staff]if-match acl 3001 #匹配流分类c_staff,匹配acl 3001 
[SW1-classifier-c_staff]q 
[SW1]traffic behavior b1 
[SW1-behavior-b1]permit #配置流行为b1,动作为permit 
[SW1-behavior-b1]q 
[SW1]traffic policy p_custom 
[SW1-trafficpolicy-p_custom]classifier c_custom behavior b1 #配置流策略p_custom,将p_custorm和b1关联 
[SW1]traffic policy p_staff 
[SW1-trafficpolicy-p_staff]classifier c_staff behavior b1 
[SW1-trafficpolicy-p_staff]q 
[SW1]vlan 10 
[SW1-vlan10]traffic-policy p_custom inbound #应用流策略p_custorm 
[SW1]vlan 20 
[SW1-vlan20]traffic-policy p_staff inbound #应用流策略p_staff