配置华为防火墙确实需要熟悉一些核心命令。虽然华为防火墙的命令行界面(CLI)非常强大且功能丰富,但以下 10 类命令是 2025 年(乃至任何时候)进行日常配置、管理和监控时非常基础且常用的,您一定要牢记:
"1. 登录与基础操作类 (Login & Basic Operations)"
`system-view`: 进入系统视图,这是进行配置的根级别视图。
`user-interface
"2. 接口配置类 (Interface Configuration)"
`interface
相关内容:
虽说华为防火墙能用 WEB 界面来配置,不过也能通过命令行进行操作。
华为防火墙有 50 个常用的配置命令,把基础配置、安全策略、NAT、VPN、高可用性这些场景都涵盖了。

一、系统基础配置
- 进入系统视图
system-view - 设置设备名称
sysname - 查看当前配置
display current-configuration - 保存配置
save - 查看设备版本信息
display version - 查看接口状态
display interface brief - 配置时钟时区
clock timezone add/minus - 配置SSH登录
ssh user authentication-type password
ssh client enable - 配置Telnet登录
telnet server enable
user-interface vty 0 4
authentication-mode password - 配置管理口IP
interface GigabitEthernet 0/0/0
ip address
二、接口与安全区域
- 将接口加入安全区域
firewall zone
add interface - 配置接口IP地址
interface
ip address - 开启/关闭接口
shutdown(关闭)
undo shutdown(开启) - 配置接口描述
description - 查看安全区域绑定
display zone
三、安全策略
- 创建安全策略规则
security-policy
rule name
source-zone
destination-zone
source-address
destination-address
action permit/deny - 启用默认拒绝所有流量
security-policy
default action deny - 查看安全策略列表
display security-policy all - 配置基于服务的策略
service
protocol tcp/udp
source-port
destination-port - 配置策略生效时间
time-range
periodic
rule中引用:time-range
四、NAT配置
- 配置源NAT(动态PAT)
nat-policy
rule name
source-zone
destination-zone
action source-nat easy-ip(使用接口IP) - 配置静态NAT(一对一映射)
nat static global inside - 配置端口映射(NAT Server)
nat server global inside - 查看NAT会话表
display nat session all - NAT地址池配置
nat address-group
section
五、VPN配置
- 创建IPSec VPN隧道
ipsec policy
proposal
ike-peer
tunnel local
tunnel remote - 配置IKE提议
ike proposal
encryption-algorithm aes-256
dh group14
authentication-algorithm sha2-256 - 配置预共享密钥
ike peer
pre-shared-key - 查看IPSec状态
display ipsec session all - 配置L2TP VPN
interface Virtual-Template 1
ppp authentication-mode chap
l2tp enable
六、路由与网关
- 配置静态路由
ip route-static - 查看路由表
display ip routing-table - 配置默认网关
ip route-static 0.0.0.0 0.0.0.0 - 配置策略路由(PBR)
policy-based-route permit node 10
apply ip-address next-hop
七、高可用性(HA)
- 配置VRRP虚拟IP
interface
vrrp vrid virtual-ip
vrrp vrid priority - 启用双机热备(主备模式)
hrp enable
hrp interface remote - 查看HRP状态
display hrp state
八、日志与监控
- 配置日志主机
info-center enable
info-center loghost facility local6 - 查看实时日志
terminal monitor
terminal logging - 查看会话表
display firewall session table - 清除会话表
reset firewall session table
九、对象与服务定义
- 定义地址对象
address-set type object
address - 定义服务对象
service-set
service source-port destination-port - 定义时间段对象
time-range to daily
十、其他实用命令
- Ping测试连通性
ping - Tracert路径追踪
tracert - 重启防火墙
reboot - 恢复出厂设置
reset saved-configuration
reboot - 查看CPU/内存利用率
display cpu-usage
display memory-usage - 配置DHCP服务
dhcp enable
dhcp select interface
注意事项
- 命令上下文:大部分配置需在system-view下执行。
- 版本差异:不同版本的防火墙OS可能略有差异,建议参考官方文档。
- 备份配置:修改前使用save保存配置,重大变更前建议备份。