新聞中心

        EEPW首頁 > 網(wǎng)絡(luò)與存儲 > 設(shè)計應(yīng)用 > 如何通過流策略實現(xiàn)VLAN間的訪問權(quán)限,一看便知!

        如何通過流策略實現(xiàn)VLAN間的訪問權(quán)限,一看便知!

        作者: 時間:2023-12-27 來源:ICT技術(shù)社區(qū) 收藏

        01過流策略實現(xiàn)間三層隔離

        本文引用地址:http://www.104case.com/article/202312/454298.htm

        1.1 組網(wǎng)需求


        如圖 1 所示,為了的安全性,某公司將訪客、員工、服務(wù)器分別劃分到10、20、VLAN30中。公司希望:


        • 員工、服務(wù)器主機、訪客均能訪問Internet。


        • 訪客只能訪問Internet,不能與其他任何VLAN的用戶


        • 員工A可以訪問服務(wù)器區(qū)的所有資源,但其他員工只能訪問服務(wù)器A的21端口(FTP服務(wù))。


        圖 1 配置通過流策略實現(xiàn)VLAN間三層隔離組網(wǎng)圖


        1.2 配置思路


        可采用如下思路配置通過流策略實現(xiàn)VLAN間互訪控制:


        1. 配置VLAN并將各接口加入VLAN,使員工、服務(wù)器、訪客間二層隔離。


        2. 配置VLANIF接口及其IP地址,使員工、服務(wù)器、訪客間可三層互通。


        3. 配置上行路由,使員工、服務(wù)器、訪客均可通過Switch訪問Internet。


        4. 配置并應(yīng)用流策略,使員工A可以訪問服務(wù)器區(qū)的所有資源,其他員工只能訪問服務(wù)器A的21端口,且只允許員工訪問服務(wù)器;使訪客只能訪問Internet。


        1.3 操作步驟


        【1】配置VLAN并將各接口加入VLAN,使員工、服務(wù)器、訪客間二層隔離


        # 在Switch_1上創(chuàng)建VLAN10,并將接口GE1/0/1以Untagged方式加入VLAN10,接口GE1/0/2以Tagged方式加入VLAN10。Switch_2和Switch_3的配置與Switch_1類似,不再贅述。(詳看文章后面的配置文件)

        <HUAWEI> system-view
        [HUAWEI] sysname Switch_1
        [Switch_1] vlan batch 10[Switch_1] interface gigabitethernet 1/0/1[Switch_1-GigabitEthernet1/0/1] port link-type access
        [Switch_1-GigabitEthernet1/0/1] port default vlan 10[Switch_1-GigabitEthernet1/0/1] quit
        [Switch_1] interface gigabitethernet 1/0/2[Switch_1-GigabitEthernet1/0/2] port link-type trunk
        [Switch_1-GigabitEthernet1/0/2] port trunk allow-pass vlan 10[Switch_1-GigabitEthernet1/0/2] quit


        # 在Switch_4上創(chuàng)建VLAN10、VLAN20、VLAN30、VLAN100,并配置接口GE1/0/1~GE1/0/4分別以Tagged方式加入VLAN10、VLAN20、VLAN30、VLAN100。

        <HUAWEI> system-view[HUAWEI] sysname Switch_4[Switch_4] vlan batch 10 20 30 100[Switch_4] interface gigabitethernet 1/0/1[Switch_4-GigabitEthernet1/0/1] port link-type trunk[Switch_4-GigabitEthernet1/0/1] port trunk allow-pass vlan 10[Switch_4-GigabitEthernet1/0/1] quit[Switch_4] interface gigabitethernet 1/0/2[Switch_4-GigabitEthernet1/0/2] port link-type trunk[Switch_4-GigabitEthernet1/0/2] port trunk allow-pass vlan 20[Switch_4-GigabitEthernet1/0/2] quit[Switch_4] interface gigabitethernet 1/0/3[Switch_4-GigabitEthernet1/0/3] port link-type trunk[Switch_4-GigabitEthernet1/0/3] port trunk allow-pass vlan 30[Switch_4-GigabitEthernet1/0/3] quit[Switch_4] interface gigabitethernet 1/0/4[Switch_4-GigabitEthernet1/0/4] port link-type trunk[Switch_4-GigabitEthernet1/0/4] port trunk allow-pass vlan 100[Switch_4-GigabitEthernet1/0/4] quit


        【2】配置VLANIF接口及其IP地址,使員工、服務(wù)器、訪客間可以三層互通


        # 在Switch_4上創(chuàng)建VLANIF10、VLANIF20、VLANIF30、VLANIF100,并分別配置其IP地址為10.1.1.1/24、10.1.2.1/24、10.1.3.1/24、10.1.100.1/24。

        [Switch_4] interface vlanif 10[Switch_4-Vlanif10] ip address 10.1.1.1 24[Switch_4-Vlanif10] quit[Switch_4] interface vlanif 20[Switch_4-Vlanif20] ip address 10.1.2.1 24[Switch_4-Vlanif20] quit[Switch_4] interface vlanif 30[Switch_4-Vlanif30] ip address 10.1.3.1 24[Switch_4-Vlanif30] quit[Switch_4] interface vlanif 100[Switch_4-Vlanif100] ip address 10.1.100.1 24[Switch_4-Vlanif100] quit


        【3】配置上行路由,使員工、服務(wù)器、訪客均可通過Switch訪問Internet。


        # 在Switch_4上配置OSPF基本功能,發(fā)布用戶網(wǎng)段以及Switch_4與Router之間的互聯(lián)網(wǎng)段。

        [Switch_4] ospf[Switch_4-ospf-1] area 0[Switch_4-ospf-1-area-0.0.0.0] network 10.1.1.0 0.0.0.255[Switch_4-ospf-1-area-0.0.0.0] network 10.1.2.0 0.0.0.255[Switch_4-ospf-1-area-0.0.0.0] network 10.1.3.0 0.0.0.255[Switch_4-ospf-1-area-0.0.0.0] network 10.1.100.0 0.0.0.255[Switch_4-ospf-1-area-0.0.0.0] quit[Switch_4-ospf-1] quit


        Router上需要進行如下配置:

        將連接Switch的接口以Tagged方式加入VLAN100,并指定VLANIF100的IP地址與10.1.100.1在同一網(wǎng)段。

        配置OSPF基本功能,并發(fā)布Switch與Router之間的互聯(lián)網(wǎng)段。


        【4】配置并應(yīng)用流策略,控制員工、訪客、服務(wù)器之間的訪問


        A、通過ACL定義每個流


        # 在Switch_4上配置ACL 3000,禁止訪客訪問員工區(qū)和服務(wù)器區(qū)。

        [Switch_4] acl 3000[Switch_4-acl-adv-3000] rule deny ip destination 10.1.2.1 0.0.0.255[Switch_4-acl-adv-3000] rule deny ip destination 10.1.3.1 0.0.0.255[Switch_4-acl-adv-3000] quit


        # 在Switch_4上配置ACL 3001,使員工A可以訪問服務(wù)器區(qū)的所有資源,其他員工只能訪問服務(wù)器A的21端口。

        [Switch_4] acl 3001[Switch_4-acl-adv-3001] rule permit ip source 10.1.2.2 0 destination 10.1.3.1 0.0.0.255[Switch_4-acl-adv-3001] rule permit tcp destination 10.1.3.2 0 destination-port eq 21[Switch_4-acl-adv-3001] rule deny ip destination 10.1.3.1 0.0.0.255[Switch_4-acl-adv-3001] quit


        B、配置流分類,區(qū)分不同的流


        # 在Switch_4上創(chuàng)建流分類c_custom、c_staff,并分別配置匹配規(guī)則3000、3001。

        [Switch_4] traffic classifier c_custom
        [Switch_4-classifier-c_custom] if-match acl 3000[Switch_4-classifier-c_custom] quit
        [Switch_4] traffic classifier c_staff
        [Switch_4-classifier-c_staff] if-match acl 3001[Switch_4-classifier-c_staff] quit


        C、配置流行為,指定流動作


        # 在Switch_4上創(chuàng)建流行為b1,并配置允許動作。

        [Switch_4] traffic behavior b1
        [Switch_4-behavior-b1] permit
        [Switch_4-behavior-b1] quit


        D、配置流策略,關(guān)聯(lián)流分類和流行為

        # 在Switch_4上創(chuàng)建流策略p_custom、p_staff,并分別將流分類c_custom、c_staff與流行為b1關(guān)聯(lián)。

        [Switch_4] traffic policy p_custom
        [Switch_4-trafficpolicy-p_custom] classifier c_custom behavior b1
        [Switch_4-trafficpolicy-p_custom] quit
        [Switch_4] traffic policy p_staff
        [Switch_4-trafficpolicy-p_staff] classifier c_staff behavior b1
        [Switch_4-trafficpolicy-p_staff] quit


        E、應(yīng)用流策略,實現(xiàn)員工、訪客、服務(wù)器之間的訪問控制


        # 在Switch_4上,分別在VLAN10、VLAN20的入方向應(yīng)用流策略p_custom、p_staff。

        [Switch_4] vlan 10[Switch_4-vlan10] traffic-policy p_custom inbound
        [Switch_4-vlan10] quit
        [Switch_4] vlan 20[Switch_4-vlan20] traffic-policy p_staff inbound
        [Switch_4-vlan20] quit


        【5】驗證配置結(jié)果


        配置訪客A的IP地址為10.1.1.2/24,缺省網(wǎng)關(guān)為VLANIF10接口的IP地址10.1.1.1;配置員工A的IP地址為10.1.2.2/24,缺省網(wǎng)關(guān)為VLANIF20接口的從IP地址10.1.2.1;配置員工B的IP地址為10.1.2.3/24,缺省網(wǎng)關(guān)為VLANIF20接口的從IP地址10.1.2.1;配置服務(wù)器A的IP地址為10.1.3.2/24,缺省網(wǎng)關(guān)為VLANIF30接口的從IP地址10.1.3.1。


        配置完成后:


        • 訪客A不能Ping通員工A、服務(wù)器A;員工A和服務(wù)器A不能Ping通訪客A。


        • 員工A可以Ping通服務(wù)器A,即可以使用服務(wù)器A的FTP服務(wù),也可以使用服務(wù)器A的。


        • 員工B可以Ping不通服務(wù)器A,只能使用服務(wù)器A的FTP服務(wù)。


        • 訪客、員工A、員工B、服務(wù)器A均可以Ping通Router連接Switch_4的接口的IP地址10.1.100.2/24,也就都可以訪問Internet。

        1.4 配置文件

        Switch_1的配置文件

        #sysname Switch_1#vlan batch 10#interface GigabitEthernet1/0/1
         port link-type access
         port default vlan 10#interface GigabitEthernet1/0/2
         port link-type trunk
         port trunk allow-pass vlan 10#return


        Switch_2的配置文件

        #sysname Switch_2#vlan batch 20#interface GigabitEthernet1/0/1
         port link-type access
         port default vlan 20#interface GigabitEthernet1/0/2
         port link-type access
         port default vlan 20#interface GigabitEthernet1/0/3
         port link-type trunk
         port trunk allow-pass vlan 20#return


        Switch_3的配置文件

        #sysname Switch_3#vlan batch 30#interface GigabitEthernet1/0/1
         port link-type access
         port default vlan 30#interface GigabitEthernet1/0/2
         port link-type trunk
         port trunk allow-pass vlan 30#return


        Switch_4的配置文件

        #sysname Switch_4#vlan batch 10 20 30 100#acl number 3000
         rule 5 deny ip destination 10.1.2.0 0.0.0.255
         rule 10 deny ip destination 10.1.3.0 0.0.0.255acl number 3001
         rule 5 permit tcp destination 10.1.3.2 0 destination-port eq ftp 
         rule 10 permit ip source 10.1.2.2 0 destination 10.1.3.0 0.0.0.255
         rule 15 deny ip destination 10.1.3.0 0.0.0.255#traffic classifier c_custom operator or precedence 5
         if-match acl 3000traffic classifier c_staff operator or precedence 10
         if-match acl 3001#traffic behavior b1
         permit#traffic policy p_custom match-order config
         classifier c_custom behavior b1traffic policy p_staff match-order config
         classifier c_staff behavior b1#vlan 10
         traffic-policy p_custom inboundvlan 20
         traffic-policy p_staff inbound#interface Vlanif10
         ip address 10.1.1.1 255.255.255.0#interface Vlanif20
         ip address 10.1.2.1 255.255.255.0#interface Vlanif30
         ip address 10.1.3.1 255.255.255.0#interface Vlanif100
         ip address 10.1.100.1 255.255.255.0#interface GigabitEthernet1/0/1
         port link-type trunk
         port trunk allow-pass vlan 10#interface GigabitEthernet1/0/2
         port link-type trunk
         port trunk allow-pass vlan 20#interface GigabitEthernet1/0/3
         port link-type trunk
         port trunk allow-pass vlan 30#interface GigabitEthernet1/0/4
         port link-type trunk
         port trunk allow-pass vlan 100#ospf 1
         area 0.0.0.0
          network 10.1.1.0 0.0.0.255
          network 10.1.2.0 0.0.0.255
          network 10.1.3.0 0.0.0.255
          network 10.1.100.0 0.0.0.255#return




        關(guān)鍵詞: VLAN 網(wǎng)絡(luò) 通信

        評論


        相關(guān)推薦

        技術(shù)專區(qū)

        關(guān)閉
        主站蜘蛛池模板: 中宁县| 孝感市| 辽阳市| 虹口区| 松原市| 山东省| 托克逊县| 东宁县| 姚安县| 扶绥县| 什邡市| 崇仁县| 布尔津县| 金昌市| 兰西县| 永定县| 株洲市| 桐城市| 正镶白旗| 昌图县| 策勒县| 广元市| 徐汇区| 迁安市| 徐闻县| 东莞市| 五莲县| 积石山| 南丰县| 长白| 蓬溪县| 清苑县| 新野县| 桃园县| 获嘉县| 隆安县| 德令哈市| 常州市| 青冈县| 龙井市| 天台县|