华为交换机配置教程 2.二层交换机与防火墙对接上网

  • 时间:2025-10-17 03:55 作者: 来源: 阅读:0
  • 扫一扫,手机访问
摘要:关于华为交换机配置教程搜集整理了一下,从基础组网,对接防火墙、多种方式的设备登录开始,一直到安全认证、故障处理,内容比较全面细致。近期更新一下,更新完了之后做一个汇总。有需要的可以关注一下。这篇文章我们来了解一下,使用二层交换机与防火墙对接上网时,交换机如何配置。1、应用场景如图所示,交换机Switch和防火墙对接,使用户PC1和PC2可以实现上网功能。交换

关于华为交换机配置教程搜集整理了一下,从基础组网,对接防火墙、多种方式的设备登录开始,一直到安全认证、故障处理,内容比较全面细致。近期更新一下,更新完了之后做一个汇总。有需要的可以关注一下。


这篇文章我们来了解一下,使用二层交换机与防火墙对接上网时,交换机如何配置。

1、应用场景

如图所示,交换机Switch和防火墙对接,使用户PC1和PC2可以实现上网功能。交换机是二层交换机,仅能实现二层转发。

华为交换机配置教程 2.二层交换机与防火墙对接上网


2、配置思路

  • 交换机基于接口划分VLAN,实现二层转发。

  • 防火墙的配置有两种情况(这里使用的是USG防火墙):

  1. 一种是防火墙的接口是三层口,通过配置子接口终结VLAN功能,实现和交换机的通信。

  2. 一种是防火墙的接口是二层口,通过配置VLANIF接口,实现和交换机的通信。

配置步骤

交换机的配置步骤(共2步)

第一步:配置下行连接用户的接口。

<Switch> system-view
[Switch] vlan batch 2 3[Switch] interface gigabitethernet0/0/2[Switch-GigabitEthernet0/0/2] port link-type access
[Switch-GigabitEthernet0/0/2] port default vlan 2[Switch-GigabitEthernet0/0/2] quit
[Switch] interface gigabitethernet0/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 gigabitethernet0/0/1[Switch-GigabitEthernet0/0/1] port link-type trunk[Switch-GigabitEthernet0/0/1] port trunk allow-pass vlan 2 3[Switch-GigabitEthernet0/0/1] quit


防火墙的接口作为三层口,通过配置子接口终结VLAN进行通信的配置步骤(共5步)

第一步:配置终结子接口。

<USG> system-view[USG] vlan batch 2 3[USG] interface gigabitethernet0/0/1.1[USG-GigabitEthernet0/0/1.1] vlan-type dot1q 2[USG-GigabitEthernet0/0/1.1] ip address 192.168.1.1 24[USG-GigabitEthernet0/0/1.1] quit[USG] interface gigabitethernet0/0/1.2[USG-GigabitEthernet0/0/1.2] vlan-type dot1q 3  [USG-GigabitEthernet0/0/1.2] ip address 192.168.2.1 24[USG-GigabitEthernet0/0/1.2] quit

第二步:配置DHCP和DNS功能,为内网用户分配IP地址和指定DNS服务器地址。

[USG] dhcp enable[USG] interface gigabitethernet0/0/1.1[USG-GigabitEthernet0/0/1.1] dhcp  select interface[USG-GigabitEthernet0/0/1.1] dhcp server dns-list 114.114.114.114 223.5.5.5[USG-GigabitEthernet0/0/1.1] quit[USG] interface gigabitethernet0/0/1.2[USG-GigabitEthernet0/0/1.2] dhcp  select interface[USG-GigabitEthernet0/0/1.2] dhcp server dns-list 114.114.114.114 223.5.5.5[USG-GigabitEthernet0/0/1.2] quit

第三步:配置域并开启域间策略。

[USG] firewall zone trust[USG-zone-trust] add interface gigabitethernet0/0/1[USG-zone-trust] add interface gigabitethernet0/0/1.1   [USG-zone-trust] add interface gigabitethernet0/0/1.2[USG-zone-trust] quit[USG] firewall zone untrust[USG-zone-untrust] add interface gigabitethernet0/0/2[USG-zone-untrust] quit[USG] firewall packet-filter default permit all

第四步:配置公网接口的IP地址和静态路由。

[USG] interface gigabitethernet0/0/2  [USG-GigabitEthernet0/0/2] ip address 200.0.0.2 255.255.255.0[USG-GigabitEthernet0/0/2] quit[USG] ip route-static 0.0.0.0 0.0.0.0 200.0.0.1

第五步:配置NAT功能,使内网用户可以访问外网。

[USG] nat address-group 1 200.0.0.2 200.0.0.2[USG] nat-policy interzone trust untrust outbound[USG-nat-policy-interzone-trust-untrust-outbound] policy 1[USG-nat-policy-interzone-trust-untrust-outbound-1] policy source 192.168.0.0 0.0.255.255[USG-nat-policy-interzone-trust-untrust-outbound-1] action source-nat[USG-nat-policy-interzone-trust-untrust-outbound-1] address-group 1[USG-nat-policy-interzone-trust-untrust-outbound-1] quit[USG-nat-policy-interzone-trust-untrust-outbound] quit


防火墙的接口作为二层口,通过VLANIF进行通信的配置步骤(共5步)

第一步:配置VLANIF接口。

<USG> system-view[USG] vlan batch 2 3[USG] interface gigabitethernet0/0/1   [USG] portswitch   [USG-GigabitEthernet0/0/1] port link-type trunk[USG-GigabitEthernet0/0/1] port trunk permit vlan 2 3 [USG-GigabitEthernet0/0/1] quit[USG] interface vlanif 2[USG-Vlanif2] ip address 192.168.1.1 24[USG-Vlanif2] quit[USG] interface Vlanif 3[USG-Vlanif3] ip address 192.168.2.1 24[USG-Vlanif3] quit

第二步:配置DHCP和DNS功能,为内网用户分配IP地址和指定DNS服务器地址。

[USG] dhcp enable[USG] interface vlanif 2  [USG-Vlanif2] dhcp  select interface[USG-Vlanif2] dhcp server dns-list 114.114.114.114 223.5.5.5[USG-Vlanif2] quit[USG] interface vlanif 3 [USG-Vlanif3] dhcp  select interface[USG-Vlanif3] dhcp server dns-list 114.114.114.114 223.5.5.5[USG-Vlanif3] quit


第三步:配置域并开启域间策略。

[USG] firewall zone trust[USG-zone-trust] add interface gigabitethernet0/0/1[USG-zone-trust] add interface Vlanif 2   [USG-zone-trust] add interface Vlanif 3[USG-zone-trust] quit[USG] firewall zone untrust[USG-zone-untrust] add interface gigabitethernet0/0/2[USG-zone-untrust] quit[USG] firewall packet-filter default permit all

第四步:配置公网接口的IP地址和静态路由。

[USG] interface gigabitethernet0/0/2  [USG-GigabitEthernet0/0/2] ip address 200.0.0.2 255.255.255.0[USG-GigabitEthernet0/0/2] quit[USG] ip route-static 0.0.0.0 0.0.0.0 200.0.0.1


第五步:配置NAT功能,使内网用户可以访问外网。

[USG] nat address-group 1 200.0.0.2 200.0.0.2[USG] nat-policy interzone trust untrust outbound[USG-nat-policy-interzone-trust-untrust-outbound] policy 1[USG-nat-policy-interzone-trust-untrust-outbound-1] policy source 192.168.0.0 0.0.255.255[USG-nat-policy-interzone-trust-untrust-outbound-1] action source-nat[USG-nat-policy-interzone-trust-untrust-outbound-1] address-group 1[USG-nat-policy-interzone-trust-untrust-outbound-1] quit[USG-nat-policy-interzone-trust-untrust-outbound] quit

这样二层交换机与防火墙对接上网的配置就完成了。


下一篇为大家介绍一下三层交换机与防火墙的对接,欢迎持续关注。

更新完了之后会做一个汇总放在主页栏目里面。

上一篇:华为交换机配置教程 1.基础组网 二、三层交换机在局域网中的应用

  • 全部评论(0)
最新发布的资讯信息
【系统环境|】从谷歌到手机厂商都下决心了,要清除32位应用这匹“害群之马”(2025-10-17 05:41)
【系统环境|】Windows上使用QEMU创建aarch64(ARM64)虚拟机(2025-10-17 05:40)
【系统环境|】nodejs 如何安装在aarch64平台(2025-10-17 05:39)
【系统环境|】常用git命令-从远程更新代码合并分支、提交代码等(2025-10-17 05:38)
【系统环境|】技术干货|常用的 Git 功能和选项(2025-10-17 05:38)
【系统环境|】掌握git命令,图解一目了然(2025-10-17 05:37)
【系统环境|】总结几个常用的Git命令的使用方法(2025-10-17 05:36)
【系统环境|】这篇 Git 教程太清晰了,很多 3 年经验程序员都收藏了(2025-10-17 05:35)
【系统环境|】Git常用命令及操作指南(2025-10-17 05:35)
【系统环境|】「实用」盘点那些开发中最常用的Git命令(2025-10-17 05:34)
手机二维码手机访问领取大礼包
返回顶部