agentsclimarketplace

Nat config

Skill nanxiaoyao/network-huawei-skills/nat-config

Huawei network device (USG firewall + S/CE switch) CLI skills pack for OpenClaw AI agent — also usable as a standalone cheatsheet.

Install
npx -y skills add nanxiaoyao/network-huawei-skills --skill nat-config

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

This skill should be used when the user asks to configure, inspect, or troubleshoot NAT on Huawei USG6000E series firewalls. Covers source NAT (NAT-policy / NAPT / Easy-IP), destination NAT (NAT Server), bidirectional NAT, NAT64/NAT46, and CGN scenarios. Applicable platforms USG6000E V600R007C20+ and USG6000/USG9500/NGFW Module V500R005C20+ (CLI syntax identical between versions).

SKILL.md

5.9 KB, ~1.9k tokens by cl100k_base, as published. Nobody here has run it

华为 USG NAT 配置技能 (nat-config)

适用平台 USG6000E 系列 适用版本 V600R007C20+ 文档来源 HUAWEI USG6000E V600R007C20 产品文档

USG 的 NAT 采用策略式 NAT-Policy 与目的 NAT Server 两套独立体系 与传统路由器的 ACL+NAT 模型完全不同 本技能覆盖源 NAT 目的 NAT 双向 NAT 配置与排错

触发场景

  • 配置源 NAT 内网访问外网
  • 配置 NAT Server 外网访问内网服务器
  • 配置 Easy-IP 出接口 NAT
  • NAT 不生效排错
  • 查看 NAT 会话/地址池/统计
  • CGN 大规模 NAT 场景
  • NAT64 IPv6 转 IPv4

核心概念

USG NAT 分两大类

  • 源 NAT source NAT 转换源 IP 通常内网到外网
  • 目的 NAT destination NAT 转换目的 IP 通常外网到内网服务器即 NAT Server

源 NAT 三种模式

  • NAPT 多对多带端口转换 最常用
  • No-PAT 多对多无端口转换
  • Easy-IP 转换为出接口 IP

地址池 nat address-group 是 NAT 的核心资源

命令体系

1 NAT 策略视图 源 NAT

进入策略视图 system-view nat-policy

创建规则 rule name <rule-name> source-zone <zone> destination-zone <zone> source-address <ip> <mask> destination-address <ip> <mask> service <name> action source-nat address-group <group-name> action source-nat easy-ip action no-nat enable

2 地址池

system-view nat address-group <group-name> [group-number] section <start-ip> <end-ip> mode pat mode no-pat local mode no-pat global mode full-cone global route enable quit

3 NAT Server 目的 NAT

基本语法 nat server [name] protocol <proto> global <pub-ip> <pub-port> inside <pri-ip> <pri-port>

举例 外网访问内部 web 服务器 nat server www_server protocol tcp global 1.1.1.10 80 inside 10.1.1.100 80 nat server zone untrust protocol tcp global interface GigabitEthernet1/0/1 8080 inside 10.1.1.100 80

4 查看命令

display nat-policy rule all display nat-policy rule name <name> display nat-policy rule source-zone <zone> destination-zone <zone> display nat address-group [name] display nat server [all-systems | name <name> | id <id> | global-ip <ip> | inside-ip <ip>] display nat statistics display nat_resource_usage_address-group display firewall session table | include NAT display nat_no-pat_statistics display nat_port_block_syslog_configuration display nat_static_mapping_global-ipv4 display nat_static_mapping_inside-ipv4 display nat64 all

5 重置

reset nat-policy counter reset nat-policy counter rule name <name>

典型配置场景

场景 1 内网用户访问 Internet NAPT

system-view nat address-group natpool1 mode pat section 0 1.1.1.10 1.1.1.20 route enable quit nat-policy rule name trust_to_untrust_napt source-zone trust destination-zone untrust source-address 192.168.1.0 mask 24 action source-nat address-group natpool1 enable

注意 还需安全策略放通 security-policy rule name trust_to_untrust source-zone trust destination-zone untrust source-address 192.168.1.0 mask 24 action permit enable

场景 2 Easy-IP 出接口 NAT

nat-policy rule name easy_ip source-zone trust destination-zone untrust source-address 192.168.1.0 mask 24 action source-nat easy-ip enable

场景 3 NAT Server 外网访问内部 Web

nat server www_pub protocol tcp global 1.1.1.10 80 inside 10.1.1.100 80 nat server ssh_pub protocol tcp global 1.1.1.10 2222 inside 10.1.1.100 22

放通安全策略 注意目的地址是私网 IP security-policy rule name untrust_to_dmz_web source-zone untrust destination-zone dmz destination-address 10.1.1.100 mask 32 service http action permit enable

场景 4 双向 NAT 源目同时转换

nat-policy rule name bidirectional source-zone untrust destination-zone dmz destination-address 1.1.1.10 mask 32 action source-nat address-group inside_pool enable nat server protocol tcp global 1.1.1.10 80 inside 10.1.1.100 80

场景 5 NAT No-PAT 一对一

nat address-group no_pat_pool mode no-pat global section 0 1.1.1.50 1.1.1.59 route enable quit nat-policy rule name no_pat_rule source-zone trust destination-zone untrust source-address 192.168.10.0 mask 24 action source-nat address-group no_pat_pool enable

排错指南

NAT 不生效

  1. 确认 NAT 策略命中 display nat-policy rule all
  2. 确认地址池可用 display nat address-group
  3. 确认安全策略已放通 display security-policy rule
  4. 查看会话 display firewall session table verbose
  5. 查看 NAT 统计 display nat statistics
  6. 路由确认 公网地址池要有去往出接口的路由 配置 route enable 或手工写回程路由

NAT Server 不生效

  1. display nat server 确认配置存在
  2. 安全策略目的地址是私网 IP 不是公网 IP 这是 USG 关键不同点
  3. 检查 ARP 代答 nat server 通常自动产生 arp 代答
  4. 服务器端默认网关指向 FW 内网接口

端口耗尽

display nat_resource_usage_address-group 报警 阈值 nat_alarm_ip-pool_port-number_threshold

常见错误

  • 安全策略目的写公网 IP 应写私网 IP
  • 地址池没 route enable 公网不知道地址池路由
  • NAPT 端口耗尽 需扩大地址池
  • ALG 协议如 FTP SIP 需开启 firewall interzone alg

与其他技能关联

  • security-policy 必须配合 NAT 流量先过策略后过 NAT
  • interface-config 接口加入安全区域 配置 IP
  • ha-hrp 双机时地址池要在主备同步

参考文档

  • references/nat-commands.md 完整命令清单
  • references/nat-inspection.md 巡检与排错
  • 产品文档 cli/nat-policy.html cli/nat_address-group.html cli/nat_server_policy.html cli/display_nat-policy.html

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.