帮你快速理解、总结文档立即下载

修改NAT边界访问控制规则

最近更新时间:2026-07-27 01:26:10

我的收藏

1. 接口描述

接口请求域名: cfw.tencentcloudapi.com 。

修改一条 NAT边界访问控制规则。

默认接口请求频率限制:20次/秒。

推荐使用 API Explorer
点击调试
API Explorer 提供了在线调用、签名验证、SDK 代码生成和快速检索接口等能力。您可查看每次调用的请求内容和返回结果以及自动生成 SDK 调用示例。

2. 输入参数

以下请求参数列表仅列出了接口请求参数和部分公共参数,完整公共参数列表见 公共请求参数

参数名称 必选 类型 描述
Action String 公共参数,本接口取值:ModifyNatAcRule。
Version String 公共参数,本接口取值:2019-09-04。
Region String 公共参数,本接口不需要传递此参数。
Rules.N Array of CreateNatRuleItem

待修改的规则数组,必须恰好包含一条完整规则,不是局部更新。调用 DescribeCfwRules,传 RuleType=nat、目标 RuleUuid、ExpandNames=false 获取原规则。字段转换:uuid→Uuid,sequence→OrderIndex,src_ip→SourceContent,src_type→SourceType,dst_content→TargetContent,dst_type→TargetType,dst_port→Port,detail→Description;action 的 0、1、2 分别转换为 log、drop、accept,enabled 的布尔值转换为字符串 true、false;protocol、direction、scope、param_template_id 分别写入 Protocol、Direction、Scope、ParamTemplateId。src_type 和 dst_type 的 1、2、3、4/5、6、8、9、10、100、101、102 分别对应 net、url、domain、template、instance、tag、dnsparse、domainiptwoverify、group、location、vendor;仅当转换结果属于对应 SourceType 或 TargetType 的有效取值时才能提交。用户要求改为某地域时,调用 DescribeAclRegInfo,传 FwType=["NAT"],按用户地域名称匹配 Data[].RegionName,并将对应 Data[].RegionCode 写入 location 类型的 Content;不得使用 ap-guangzhou 等云资源地域、中文地域名称或自行拼接代码。vendor 类型的 Content 仅使用 tencent、aliyun、aws、huawei、azure 或 all,不使用“腾讯云”等展示名称。省略字段使用对应参数的默认值或空值,不继承旧值。地址模板和协议端口模板通过 DescribeAddressTemplateList 查询,资产实例通过 DescribeCfwAssets 查询,资源组和标签通过 DescribeResourceGroupNew 查询。

CfwAiAgentOperationSource String

AI操作来源

枚举值:

  • console: 控制台来源值
  • wechat: 微信

示例值:console

3. 输出参数

参数名称 类型 描述
RuleUuid Array of Integer 修改后的规则 ID 列表,成功时包含请求规则的 Uuid。
示例值:[8888]
RequestId String 唯一请求 ID,由服务端生成,每次请求都会返回(若请求因其他原因未能抵达服务端,则该次请求不会获得 RequestId)。定位问题时需要提供该次请求的 RequestId。

4. 示例

示例1 修改一条NAT出站访问控制规则

将 Uuid 指定的 NAT 规则修改为放行。

输入示例

POST / HTTP/1.1
Host: cfw.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: ModifyNatAcRule

{
    "Rules": [
        {
            "SourceContent": "192.0.2.10/32",
            "SourceType": "net",
            "TargetContent": "198.51.100.20/32",
            "TargetType": "net",
            "Protocol": "TCP",
            "RuleAction": "accept",
            "Port": "443",
            "Direction": 0,
            "OrderIndex": 8,
            "Uuid": 90010001,
            "Enable": "true",
            "Description": "允许文档示例HTTPS流量",
            "ParamTemplateId": "",
            "Scope": "ALL"
        }
    ]
}

输出示例

{
    "Response": {
        "RuleUuid": [
            90010001
        ],
        "RequestId": "00000000-0000-4000-8000-000000000001"
    }
}

示例2 修改一条 NAT 入站访问控制规则

先查询并确认 Uuid 对应的入站规则,再按完整字段重建规则;示例保持入站方向并修改为观察动作。

输入示例

POST / HTTP/1.1
Host: cfw.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: ModifyNatAcRule

{
    "Rules": [
        {
            "SourceContent": "192.0.2.0/24",
            "SourceType": "net",
            "TargetContent": "198.51.100.30",
            "TargetType": "net",
            "Protocol": "TCP",
            "RuleAction": "log",
            "Port": "8443",
            "Direction": 1,
            "OrderIndex": 9,
            "Uuid": 90010002,
            "Enable": "true",
            "Description": "观察 NAT 入站示例流量",
            "ParamTemplateId": "",
            "Scope": "ALL"
        }
    ]
}

输出示例

{
    "Response": {
        "RuleUuid": [
            90010002
        ],
        "RequestId": "00000000-0000-4000-8000-000000000002"
    }
}

示例3 按用户要求将规则修改为观察访问腾讯云的出站流量

用户要求“将规则修改为观察访问腾讯云的出站流量”时,先调用 DescribeCfwRules 查询目标规则并完整携带其可写字段,再把出站目的改为 vendor 和协议值 tencent;不得把展示名称“腾讯云”写入 TargetContent。

输入示例

POST / HTTP/1.1
Host: cfw.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: ModifyNatAcRule

{
    "Rules": [
        {
            "SourceContent": "0.0.0.0/0",
            "SourceType": "net",
            "TargetContent": "tencent",
            "TargetType": "vendor",
            "Protocol": "ANY",
            "RuleAction": "log",
            "Port": "-1/-1",
            "Direction": 0,
            "OrderIndex": 10,
            "Uuid": 90010004,
            "Enable": "false",
            "Description": "观察访问腾讯云的出站流量",
            "ParamTemplateId": "",
            "Scope": "ALL"
        }
    ]
}

输出示例

{
    "Response": {
        "RuleUuid": [
            90010004
        ],
        "RequestId": "00000000-0000-4000-8000-000000000004"
    }
}

示例4 将 NAT 规则修改为地址模板规则

使用地址模板修改 Uuid 指定的 NAT 规则。

输入示例

POST / HTTP/1.1
Host: cfw.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: ModifyNatAcRule

{
    "Rules": [
        {
            "SourceContent": "192.0.2.120",
            "SourceType": "net",
            "TargetContent": "mb_xxxxx_xxxxx",
            "TargetType": "template",
            "Protocol": "TCP",
            "RuleAction": "log",
            "Port": "443",
            "Direction": 0,
            "OrderIndex": 1066,
            "Uuid": 90010003,
            "Enable": "false",
            "Description": "NAT 地址模板观察规则",
            "ParamTemplateId": "",
            "Scope": "ALL"
        }
    ]
}

输出示例

{
    "Response": {
        "RuleUuid": [
            90010003
        ],
        "RequestId": "00000000-0000-4000-8000-000000000003"
    }
}

5. 开发者资源

腾讯云 API 平台

腾讯云 API 平台 是综合 API 文档、错误码、API Explorer 及 SDK 等资源的统一查询平台,方便您从同一入口查询及使用腾讯云提供的所有 API 服务。

API Inspector

用户可通过 API Inspector 查看控制台每一步操作关联的 API 调用情况,并自动生成各语言版本的 API 代码,也可前往 API Explorer 进行在线调试。

SDK

云 API 3.0 提供了配套的开发工具集(SDK),支持多种编程语言,能更方便的调用 API。

命令行工具

6. 错误码

以下仅列出了接口业务逻辑相关的错误码,其他错误码详见 公共错误码

错误码 描述
FailedOperation 操作失败。
InvalidParameter 参数错误。
LimitExceeded 超过配额限制。
UnauthorizedOperation 未授权操作。
UnsupportedOperation 操作不支持。