agentleFS
nanxiaoyaonanxiaoyao/network-huawei-skills/security-policy/SKILL.md

security-policy

Skill2 starsChanged 3 months agoMITView on GitHub

This skill should be used when the user asks to configure, inspect, or troubleshoot security policies on Huawei USG6000E series firewalls (USG6300E/6500E/6600E/6680E/6712E/6716E). Covers rule creation (source/destination zone, address, service, application, user), default action, policy groups, logging, content security profiles, and policy hit statistics. Applicable platforms USG6000E V600R007C20+ and USG6000/USG9500/NGFW Module V500R005C20+ (CLI syntax identical between versions).

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

Files
SKILL.md

华为 USG 安全策略配置技能 (security-policy)

适用平台: USG6000E 系列(USG6300E/6500E/6600E/6680E/6712E/6716E) 适用版本: V600R007C20 及以上 文档来源: HUAWEI USG6000E V600R007C20 产品文档

安全策略是 USG 防火墙的核心功能,控制不同安全区域间流量的转发或阻断。本技能覆盖安全策略的完整生命周期:创建、修改、移动、复制、删除、查看、排错。


触发场景

用户描述以下任一需求时加载此技能:

  • "配置安全策略" / "放通某个区域的流量"
  • "创建一条安全策略规则"
  • "安全策略默认动作" / "default action"
  • "查看安全策略命中"
  • "安全策略不生效" / "策略排错"
  • "策略组" / "policy group"
  • "基于用户/应用/地址的安全策略"

不适用: NAT 策略(→ nat-config/)、认证策略(→ auth-policy)、IPS/AV 内容安全配置(→ content-security/,但安全策略中引用 profile 属本技能)


核心概念

安全策略工作流

流量进入 → 匹配源安全区域 → 逐条匹配规则(从上到下)→ 命中 → 执行动作(permit/deny)
                                         → 未命中 → 执行默认动作(default action)

匹配要素(七元组)

要素命令说明
源安全区域source-zone流量进入的区域
目的安全区域destination-zone流量去往的区域
源地址source-address源 IP / 地址组 / 地址集
目的地址destination-address目的 IP / 地址组 / 地址集
服务service协议+端口(HTTP/DNS/自定义等)
应用application应用层识别(微信/钉钉等)
用户user / access-authentication基于用户或用户组的策略

规则匹配顺序

从上到下,先命中先生效。规则顺序至关重要。


命令参考

1. 进入安全策略视图

system-view
security-policy                    ← 进入安全策略视图
[sysname-policy-security]

2. 创建规则

security-policy
 rule name <rule-name>             ← 创建/进入规则
  source-zone <zone-name>          ← 源安全区域(可配多条)
  destination-zone <zone-name>     ← 目的安全区域
  source-address <ip> <mask>       ← 源地址(或地址组)
  source-address address-set <name>← 源地址集
  destination-address <ip> <mask>  ← 目的地址
  destination-address address-set <name>
  service <service-name>           ← 服务(可配多条)
  service protocol <tcp|udp> source-port <port> destination-port <port>
  application <app-name>           ← 应用识别
  action permit                    ← 动作:permit 或 deny
  description <text>               ← 规则描述(可选)
  profile <profile-name>           ← 引用内容安全 profile(可选)
  policy logging                   ← 开启命中日志
  enable                           ← 启用规则

3. 排除地址

 rule name <rule-name>
  source-address-exclude <ip> <mask>      ← 排除源地址
  destination-address-exclude <ip> <mask> ← 排除目的地址
  service-exclude <service-name>          ← 排除服务

4. 默认动作

security-policy
 default action permit              ← 未命中任何规则时允许(慎用)
 default action deny                ← 未命中任何规则时拒绝(推荐)
 default session logging            ← 默认动作的会话日志
 default policy logging             ← 默认动作的策略日志
 default traffic logging            ← 默认动作的流量日志

5. 策略组(批量管理)

security-policy
 group name <group-name>                  ← 创建策略组
  rule name <rule-name>                   ← 组内规则
  parent-group <group-name>               ← 规则归属组
 group name <group-name> from <n> to <m>  ← 调整组顺序
 group move <group-name> to <position>    ← 移动组
 group rename <old> <new>                 ← 重命名组

6. 规则操作

security-policy
 rule move <rule-name> to <position>     ← 移动规则顺序
 rule copy <src-rule> name <dst-rule>    ← 复制规则
 rule rename <old-name> <new-name>       ← 重命名

7. 查看命令(display)

命令用途
display security-policy rule all查看所有规则
display security-policy rule name <name>查看指定规则详情
display security-policy rule source-zone trust destination-zone untrust按区域过滤
display security-policy rule source <ip> destination <ip> protocol tcp destination-port 80按五元组过滤
display security-policy group查看策略组
display policy default-action查看默认动作
display security-policy statistic查看策略命中统计

8. 重置统计

reset security-policy counter        ← 重置命中计数
reset security-policy statistic      ← 重置统计

9. 全局开关

security-policy
 statistic enable                              ← 开启策略命中统计
 policy logging                                ← 全局策略日志
 security-policy accelerate delay <seconds>    ← 加速延迟

配置前必须遵守

  1. 进入 system-view 再操作
  2. 每条命令后读回显,检测 Error / Incomplete command
  3. 规则顺序:新规则默认添加到末尾,用 rule move 调整
  4. 默认动作:生产环境必须 default action deny,仅放通必要流量
  5. zone 必须存在:先确认安全区域已创建(display zone)

典型配置场景

场景 1:放通 Trust→Untrust 基础上网

system-view
security-policy
 rule name trust_to_untrust
  source-zone trust
  destination-zone untrust
  source-address 192.168.1.0 255.255.255.0
  action permit
  enable
 default action deny

场景 2:放通 DMZ 服务器的 HTTP/HTTPS

security-policy
 rule name allow_web_dmz
  source-zone untrust
  destination-zone dmz
  destination-address 10.1.1.100 255.255.255.255
  service http https
  action permit
  policy logging
  enable

场景 3:基于应用控制(仅允许邮件,阻断其他)

security-policy
 rule name allow_mail_only
  source-zone trust
  destination-zone untrust
  application pop3 smtp imap
  action permit
  enable
 rule name deny_other
  source-zone trust
  destination-zone untrust
  action deny
  enable

场景 4:策略中引用内容安全 Profile

security-policy
 rule name allow_with_ips
  source-zone trust
  destination-zone untrust
  action permit
  profile ips_default av_default url_default    ← 引用 IPS/AV/URL 过滤
  enable

场景 5:策略组批量管理

security-policy
 group name web_services
  rule name allow_http
   source-zone untrust destination-zone dmz service http action permit enable
  rule name allow_https
   source-zone untrust destination-zone dmz service https action permit enable
 group name web_services from 1 to 2          ← 整组调整到位置 1-2

排错指南

策略不生效排查

步骤命令检查点
1. 确认规则存在display security-policy rule all规则已创建且 enable
2. 确认规则顺序display security-policy rule all上方无 deny 规则先命中
3. 确认区域匹配display zone源/目的区域正确
4. 确认地址匹配display security-policy rule name <name>地址范围覆盖流量
5. 确认默认动作display policy default-action非预期流量是否被 deny
6. 查看命中统计display security-policy statistic规则是否有 hit count
7. 查看会话表display firewall session table流量是否建立会话

常见问题

问题原因修复
策略配了但不生效规则未 enable规则视图下 enable
规则生效但流量仍不通上方有更宽泛的 deny 规则rule move 调整顺序
特定 IP 不应放通但被放通地址范围过大用 source-address-exclude 排除
流量匹配了默认动作所有规则都未命中检查 zone/address/service 匹配条件
策略日志看不到未开 policy logging规则视图下 policy logging

与其他技能的关联

关联技能交互点
nat-config/安全策略放通后,NAT 策略决定地址转换
health-check/巡检时查看策略命中统计、默认动作
interface-config/接口加入安全区域(zone)
attack-defense/安全策略可引用攻击防范 profile
ipsec-vpn/VPN 流量需安全策略放通
ha-hrp/双机热备时策略自动同步

参考文档

  • references/security-policy-commands.md — 完整命令速查(含所有参数取值范围)
  • references/security-policy-inspection.md — 策略巡检与排错详细流程
  • 产品文档: /root/.openclaw/workspace-ops/refs/usg6000e-v600r007/cli/security-policy.html
  • 配置案例: /root/.openclaw/workspace-ops/refs/usg6000e-v600r007/case_firewall/sec_case_policy_0000.html

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.