三層交換機與防火牆對接上網配置示例


組網圖形

圖1 三層交換機與防火牆對接上網組網圖
  • 三層交換機簡介
  • 配置注意事項
  • 組網需求
  • 配置思路
  • 操作步驟
  • 配置文件
  • 舉例適用的產品和版本

三層交換機簡介

三層交換機是具有路由功能的交換機,由於路由屬於OSI模型中第三層網絡層的功能,所以稱為三層交換機。

三層交換機既可以工作在二層也可以工作在三層,可以部署在接入層,也可以部署在匯聚層,作為用戶的網關。

配置注意事項

  • 本舉例中的防火牆配置以USG6650 V500R001C60為例,其他防火牆的配置方法請參見對應的文檔指南。

  • 本舉例中的交換機作為DHCP服務器適用的產品和版本請參見舉例適用的產品和版本

組網需求

圖1所示,某公司擁有多個部門且位於不同網段,各部門均有訪問Internet的需求。現要求用戶通過三層交換機和防火牆訪問外部網絡,且要求三層交換機作為用戶的網關。

配置思路

采用如下思路進行配置:

  1. 配置交換機作為用戶的網關,通過VLANIF接口,實現跨網段用戶互訪。

  2. 配置交換機作為DHCP服務器,為用戶分配IP地址。

  3. 開啟防火牆域間安全策略,使不同域的報文可以相互轉發。

  4. 配置防火牆PAT轉換功能,使用戶可以訪問外部網絡。

操作步驟

  1. 配置交換機

    # 配置連接用戶的接口和對應的VLANIF接口。

    <HUAWEI> system-view
    [HUAWEI] sysname Switch [Switch] vlan batch 2 3 [Switch] interface gigabitethernet 0/0/2 [Switch-GigabitEthernet0/0/2] port link-type access//配置接口接入類型為access [Switch-GigabitEthernet0/0/2] port default vlan 2//配置接口加入VLAN 2 [Switch-GigabitEthernet0/0/2] quit [Switch] interface gigabitethernet 0/0/3 [Switch-GigabitEthernet0/0/3] port link-type access [Switch-GigabitEthernet0/0/3] port default vlan 3 [Switch-GigabitEthernet0/0/3] quit [Switch] interface vlanif 2 [Switch-Vlanif2] ip address 192.168.1.1 24 [Switch-Vlanif2] quit [Switch] interface vlanif 3 [Switch-Vlanif3] ip address 192.168.2.1 24 [Switch-Vlanif3] quit 

    # 配置連接防火牆的接口和對應的VLANIF接口。

    [Switch] vlan batch 100
    [Switch] interface gigabitethernet 0/0/1
    [Switch-GigabitEthernet0/0/1] port link-type access
    [Switch-GigabitEthernet0/0/1] port default vlan 100   
    [Switch-GigabitEthernet0/0/1] quit
    [Switch] interface vlanif 100
    [Switch-Vlanif100] ip address 192.168.100.2 24
    [Switch-Vlanif100] quit
    

    # 配置缺省路由。

    [Switch] ip route-static 0.0.0.0 0.0.0.0 192.168.100.1//缺省路由的下一跳是防火牆接口的IP地址192.168.100.1
    

    # 配置DHCP服務器。

    [Switch] dhcp enable   
    [Switch] interface vlanif 2
    [Switch-Vlanif2] dhcp select interface//DHCP使用接口地址池的方式為用戶分配IP地址
    [Switch-Vlanif2] dhcp server dns-list 114.114.114.114 223.5.5.5//配置的DNS-List 114.114.114.114是公用的DNS服務器地址,是不區分運營商的。在實際應用中,請根據運營商分配的DNS進行配置
    [Switch-Vlanif2] quit
    [Switch] interface vlanif 3
    [Switch-Vlanif3] dhcp select interface
    [Switch-Vlanif3] dhcp server dns-list 114.114.114.114 223.5.5.5
    [Switch-Vlanif3] quit
    
  2. 配置防火牆

    # 配置連接交換機的接口對應的IP地址。

    <USG6600> system-view
    [USG6600] interface gigabitethernet 1/0/1
    [USG6600-GigabitEthernet1/0/1] ip address 192.168.100.1 255.255.255.0   
    [USG6600-GigabitEthernet1/0/1] quit
    

    # 配置連接公網的接口對應的IP地址。

    [USG6600] interface gigabitethernet 1/0/2
    [USG6600-GigabitEthernet1/0/2] ip address 1.1.1.2 255.255.255.0//配置連接公網接口的IP地址和公網的IP地址在同一網段
    [USG6600-GigabitEthernet1/0/2] quit
    

    # 配置缺省路由和回程路由。

    [USG6600] ip route-static 0.0.0.0 0.0.0.0 1.1.1.1//配置靜態缺省路由的下一跳指向公網提供的IP地址1.1.1.1
    [USG6600] ip route-static 192.168.0.0 255.255.0.0 192.168.100.2//配置回程路由的下一跳就指向交換機上行接口的IP地址192.168.100.2
    

    # 配置安全策略。

    [USG6600] firewall zone trust//配置trust域
    [USG6600-zone-trust] add interface gigabitethernet 1/0/1
    [USG6600-zone-trust] quit
    [USG6600] firewall zone untrust//配置untrust域
    [USG6600-zone-untrust] add interface gigabitethernet 1/0/2
    [USG6600-zone-untrust] quit
    
    # 配置安全策略,允許域間互訪。
    [USG6600] security-policy
    [USG6600-policy-security] rule name policy1
    [USG6600-policy-security-rule-policy1] source-zone trust
    [USG6600-policy-security-rule-policy1] destination-zone untrust
    [USG6600-policy-security-rule-policy1] source-address 192.168.0.0 mask 255.255.0.0
    [USG6600-policy-security-rule-policy1] action permit
    [USG6600-policy-security-rule-policy1] quit
    [USG6600-policy-security] quit
    
    # 配置PAT地址池,開啟允許端口地址轉換。
    [USG6600] nat address-group addressgroup1    
    [USG6600-address-group-addressgroup1] mode pat
    [USG6600-address-group-addressgroup1] route enable
    [USG6600-address-group-addressgroup1] section 0 1.1.1.2 1.1.1.2 //轉換的公網IP地址
    [USG6600-address-group-addressgroup1] quit
    
    # 配置源PAT策略,實現私網指定網段訪問公網時自動進行源地址轉換。
    [USG6600] nat-policy    
    [USG6600-policy-nat] rule name policy_nat1
    [USG6600-policy-nat-rule-policy_nat1] source-zone trust
    [USG6600-policy-nat-rule-policy_nat1] destination-zone untrust
    [USG6600-policy-nat-rule-policy_nat1] source-address 192.168.0.0 mask 255.255.0.0//允許進行PAT轉換的源IP地址
    [USG6600-policy-nat-rule-policy_nat1] action nat address-group addressgroup1
    [USG6600-policy-nat-rule-policy_nat1] quit
    [USG6600-policy-nat] quit
    [USG6600] quit
    
  3. 檢查配置結果

    配置PC1的IP地址為192.168.1.2/24,網關為192.168.1.1;PC2的IP地址為192.168.2.2/24,網關為192.168.2.1。

    配置外網PC的IP地址為1.1.1.1/24,網關為1.1.1.2。

    配置完成后,PC1和PC2都可以Ping通外網的IP 1.1.1.1/24,PC1和PC2都可以訪問Internet。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM