VLAN隔離是什麼?具有哪些應用場景?0基礎掌握VLAN隔離技術

VLAN隔離應用場景

場景1:同一設備下掛的用戶屬於同一VLAN,需要禁止某些用戶訪問。

場景2:設備下掛許多用戶,需要

  • 部分VLAN間可以互通
  • 部分VLAN間隔離
  • VLAN內用戶隔離

場景3:VLAN間三層互通後,需要禁止部分用戶互訪或者只允許用哪個和單向互訪。


端口隔離

如果不希望同一VLAN下某些用戶進行互通,可以通過配置端口隔離實現。用戶只需要將端口加入到隔離組中,就可以實現隔離組內端口直接二層數據的隔離。

拓撲圖

VLAN隔離是什麼?具有哪些應用場景?0基礎掌握VLAN隔離技術

需求:PC1與PC2在VLAN10內不能相互訪問,但是,PC3與PC1、PC2之間能相互訪問。

關鍵配置

<code>[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 /<code>

驗證結果

VLAN隔離是什麼?具有哪些應用場景?0基礎掌握VLAN隔離技術

通過上圖可以看到雖然PC1與PC2屬於同一VLAN,但是不能通信的。PC3與PC1、PC2是能正常通信的。

MUX VLAN

MUX VLAN只適用於二層網絡中,對同一網段的用戶進行部分VLAN間互通、部分VLAN間隔離和VLAN內用戶隔離。

拓撲圖

VLAN隔離是什麼?具有哪些應用場景?0基礎掌握VLAN隔離技術

需要:

  • 所有用戶都能訪問server。
  • PC1和PC2可以互訪,和PC3、PC4不能互訪;
  • PC3和PC4之間隔離,不能互訪。

關鍵配置

<code>[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配置類型,不再贅述/<code>

驗證結果

VLAN隔離是什麼?具有哪些應用場景?0基礎掌握VLAN隔離技術

VLAN隔離是什麼?具有哪些應用場景?0基礎掌握VLAN隔離技術

基於流策略的VLAN隔離

VLAN間三層互通後,如果需要禁止部分用戶互訪或者只允許用戶單向訪問,則需要配置VLAN間三層隔離功能。VLAN間三層隔離一般通過流策略實現。

拓撲圖

VLAN隔離是什麼?具有哪些應用場景?0基礎掌握VLAN隔離技術

需求:

  • VALN10、VLAN20、VLAN30均可以訪問互聯網。
  • 訪客只能訪問互聯網,不能與其他任何VLAN的用戶通信
  • 員工A可以訪問服務器區的所有資源,但其他員工只能訪問服務器A的21端口。

關鍵配置

<code>[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
/<code>


分享到:


相關文章: