文档

CreateForwardEntry - 在DNAT列表中添加DNAT条目

更新时间:

调用CreateForwardEntry接口在DNAT列表中添加DNAT条目。

接口说明

每条 DNAT 条目由五部分组成,包括 ExternalIpExternalPortIpProtocolInternalIpInternalPort。添加 DNAT 条目后,NAT 网关会将ExternalIp:ExternalPort上收到的指定协议的报文转发给InternalIp:InternalPort,并将回复消息原路返回。

调用本接口添加 DNAT 条目时,请注意:

  • CreateForwardEntry 接口属于异步接口,即系统会先返回一个 DNAT 条目 ID,但该 DNAT 条目并未添加完成,系统后台的添加任务仍在进行。您可以调用 DescribeForwardTableEntries 查询 DNAT 条目的状态:

    • 当 DNAT 条目处于 Pending 状态时,表示 DNAT 条目正在添加中,在该状态下,您只能执行查询操作,不能执行其他操作。

    • 当 DNAT 条目处于 Available 状态时,表示 DNAT 条目添加完成。

  • CreateForwardEntry 接口在同一个 NAT 网关内不支持并发添加 DNAT 条目。

  • 所有 DNAT 条目的 ExternalIpExternalPortIpProtocol 三个字段组成的组合必须互不重复,即不允许将同一个源 IP、同一个端口、同一个协议的消息转发到多个目标 ECS 实例。

  • 所有 DNAT 条目的 IpProtocolInternalIpInternalPort 三个字段组成的组合也必须互不重复。

  • 当 DNAT 表中有 DNAT 条目的状态处于 PendingModifying 状态时,无法添加 DNAT 条目。

  • 一个 DNAT 表最多可添加 100 条 DNAT 条目。

  • DNAT 条目中配置了 IP 映射方式的 IP(公网 NAT 网关使用的 EIP 或 VPC NAT 网关使用的 NAT IP 地址)不能再被其他 DNAT 条目或 SNAT 条目使用。

调试

您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。

授权信息

下表是API对应的授权信息,可以在RAM权限策略语句的Action元素中使用,用来给RAM用户或RAM角色授予调用此API的权限。具体说明如下:

  • 操作:是指具体的权限点。
  • 访问级别:是指每个操作的访问级别,取值为写入(Write)、读取(Read)或列出(List)。
  • 资源类型:是指操作中支持授权的资源类型。具体说明如下:
    • 对于必选的资源类型,用背景高亮的方式表示。
    • 对于不支持资源级授权的操作,用全部资源表示。
  • 条件关键字:是指云产品自身定义的条件关键字。
  • 关联操作:是指成功执行操作所需要的其他权限。操作者必须同时具备关联操作的权限,操作才能成功。
操作访问级别资源类型条件关键字关联操作
vpc:CreateForwardEntryWrite
  • ForwardTable
    acs:vpc:{#regionId}:{#accountId}:forwardtable/{#ForwardTableId}

请求参数

名称类型必填描述示例值
RegionIdstring

NAT 网关所在的地域 ID。

您可以通过调用 DescribeRegions 接口获取地域 ID。

cn-hangzhou
ForwardTableIdstring

DNAT 列表的 ID。

ftb-bp1mbjubq34hlcqpa****
ExternalIpstring
  • 当为公网 NAT 网关配置 DNAT 条目时,提供公网访问的弹性公网 IP 地址。
  • 当为 VPC NAT 网关配置 DNAT 条目时,提供外部网络访问的 NAT IP 地址。
116.28.XX.XX
ExternalPortstring
  • 当为公网 NAT 网关配置 DNAT 条目时, 需要进行端口转发的外部端口或端口段。

    • 输入的端口范围需要在 1~65535 之间。
    • 如果需要在端口段内转发,请在输入时以正斜线(/)隔开起始端口,例如10/20
    • 如果 ExternalPort 设置为端口段,则 InternalPort 也需要设置为端口段,且端口段的端口个数相同,例如 ExternalPort 设置为10/20InternalPort 设置为80/90
  • 当为 VPC NAT 网关配置 DNAT 条目时,NAT IP 地址被外部网络访问的端口,取值范围:1~65535

8080
InternalIpstring
  • 当为公网 NAT 网关配置 DNAT 条目时,需要进行公网通信的 ECS 实例的私网 IP 地址,该私网 IP 地址需满足以下条件:

    • 必须属于 NAT 网关所在的 VPC 的网段。

    • 必须被一个 ECS 实例使用且该实例没有绑定 EIP 时,DNAT 条目才生效。

  • 当为 VPC NAT 网关配置 DNAT 条目时,需要通过 DNAT 规则进行通信的私网 IP 地址。

192.168.XX.XX
InternalPortstring
  • 当为公网 NAT 网关配置 DNAT 条目时,需要进行端口转发的内部端口或端口段,取值范围:1~65535

  • 当为 VPC NAT 网关配置 DNAT 条目时,需要映射的目标 ECS 实例端口,取值范围:1~65535

80
IpProtocolstring

协议类型,取值:

  • TCP:转发 TCP 协议的报文。

  • UDP:转发 UDP 协议的报文。

  • Any:转发所有协议的报文。如果 IpProtocol 配置为 Any,则 ExternalPortInternalPort 也必须配置为 Any,实现 DNAT IP 映射。

TCP
ForwardEntryNamestring

DNAT 规则的名称。

长度为 2~128 个字符,必须以大小写字母或中文开头,但不能以http://https://开头。

ForwardEntry-1
ClientTokenstring

客户端 Token,用于保证请求的幂等性。

从您的客户端生成一个参数值,确保不同请求间该参数值唯一。ClientToken 只支持 ASCII 字符。

说明 若您未指定,则系统自动使用 API 请求的 RequestId 作为 ClientToken 标识。每次 API 请求的 RequestId 可能不一样。
0c593ea1-3bea-11e9-b96b-88e9fe6****
PortBreakboolean

是否开启端口突破,取值:

  • true:开启端口突破。

  • false(默认值):不开启端口突破。

说明 当 DNAT 条目和 SNAT 条目使用同一个公网 IP 地址时,如果您需要配置大于 1024 的端口号,您需要指定 PortBreaktrue
false

返回参数

名称类型描述示例值
object
ForwardEntryIdstring

DNAT 条目的 ID。

fwd-119smw5tkasdf****
RequestIdstring

请求 ID。

A4AEE536-A97A-40EB-9EBE-53A6948A6928

示例

正常返回示例

JSON格式

{
  "ForwardEntryId": "fwd-119smw5tkasdf****",
  "RequestId": "A4AEE536-A97A-40EB-9EBE-53A6948A6928"
}

错误码

HTTP status code错误码错误信息描述
400UnsupportedFeature.PrivateLinkEnabledThe feature of PrivateLinkEnabled is not supported.-
400UnsupportedFeature.PortSegmentThe feature of PortSegment is not supported.-
400ExclusiveParam.%sAnd%sThe param of %s and %s are mutually exclusive.参数 %s 和 %s 相互排斥。
400DuplicatedParam.InternalPortThe param of %s is duplicated.%s的参数重复。
400DuplicatedParam.ExternalPortThe param of %s is duplicated.%s的参数重复。
400OperationFailed.AnyPortConfigOperation failed because any port correspondence any protocol操作失败,因为任何端口对应任何协议
400OperationUnsupported.ForwardEntryDuplicated destination ip port is unsupported.不支持重复的目标IP端口。
400InvalidIp.NotInNatgwThe specified Ip not belong to natgateway.该 IP 地址不属于该 NAT 网关。
400QuotaExceeded.ForwardEntryThe quota of %s is exceeded, usage %s/%s.-
400IncorrectStatus.NatIpThe status of %s [%s] is incorrect.NatIp当前状态不正确。
400Forbidden.IpHasBeenUsedInSnatThe source ip can't be used. Because it has been used in snat.-
400InvalidExternalIp.MalformedThe specified ExternalIp is not a valid IP address.该公网IP不合法。
400InvalidInternalIp.MalformedThe specified InternalIp is not a valid IP address.该目标私网IP不合法。
400InvalidExternalPort.MalformedThe specified ExternalPort is not a valid port.该公网端口不合法。
400InvalidInternalPort.MalformedThe specified InternalPort is not a valid port.该私网端口不合法。
400Forbidden.DestnationIpOutOfVpcCIDRThe specified Internal Ip is Out of VPC CIDR.该私网IP不在VPC的网段范围内,请您填写在VPC的网段范围内的私网IP。
400Forbidden.DestinationIpOutOfVswitchCIDRThe specified Internal Ip is Out of VSwitch CIDR.-
400InvalidProtocal.ValueNotSupportedThe specified IpProtocol does not support.该协议类型不支持。
400IncorretForwardEntryStatusSome Forward entry status blocked this operation..无法执行该操作。DNAT表中有DNAT条目的状态处于Pending或Modifying状态。
400QuotaExceeded.ForwardEntryForward entry quota exceeded in this route table.-
400ForwardEntry.DuplicatedThe specified ExternalIp, IpProtocol, ExternalPort,InternalIp, InternalPort is duplicated-
400Forbidden.ExternalIp.UsedInSnatTableThe specified ExternalIp is already used in SnatTable该公网IP已经被SNAT使用,请更换其他公网IP或将当前公网IP的SNAT规则删除。
400ForbinddenThe specified Instance already bind eip该实例已经绑定了 EIP,请将 ECS 实例与 EIP 解绑后再添加该端口转发规则。
400Forbidden.InternalIpOutOfVpcCIDRThe specified Internal Ip is Out of VPC CIDR.该私网IP不在VPC的网段范围内。
400Invalid.natgwNotExistThe specified natgateway not exist.该NAT网关不存在。
400MissingParameterMissing mandatory parameter缺少必要参数,请您检查必填参数是否都已填后再进行操作。
400AnyPort.PortMustBeZeroany port port must be zero.-
400InvalidParameter.Name.MalformedThe specified Name is not valid.该名称不合法,请您按照正确的格式书写名称。
400IncorrectStatus.ForwardEntryThe status of %s [%s] is incorrect.要删除的DNAT条目实例状态不对
400OperationFailed.AnyPortConfigOperation failed because any port correspondence any protocol.-
400Duplicated.DestinationPortThe specified param DestinationPort is duplicated.-
400OperationUnsupported.EipInBindingCreate snat entry with eip in associating status is unsupported.创建snat不可以使用绑定中的eip
400QuotaExceeded.ForwardEntrySessionManytoOneThe dnat session quota is exceed.dnat session 多对一的配额超限。
400TaskConflictThe operation is too frequent, please wait a moment and try again.操作过于频繁,请稍等一会再重试
400OperationFailed.DnatPortRangeLimitThe maximum number of port ranges that can be specified is exceeded.端口段数量超限。
400IncorrectStatus.NATGWNATGW status is invalid.NAT网关的状态不正确。
404ResourceNotFound.NatIpThe specified resource of %s is not found.NatIp资源找不到。
404InvalidRegionId.NotFoundThe specified RegionId does not exist in our records.指定的RegionId不存在。
404InvalidForwardTableId.NotFoundSpecified forward table does not exist.指定的 DNAT 表不存在,请您检查输入参数是否正确。
404InvalidExternalIp.NotFoundSpecified External Ip address does not found on the VRouter该公网IP不存在。
500System.ErrorERROR SYSTEM ERROR.-
500InternalErrorThe request processing has failed due to some unknown error.请求处理由于某些未知错误失败。

访问错误中心查看更多错误码。

变更历史

变更时间变更内容概要操作
2024-01-18OpenAPI 描述信息更新、OpenAPI 错误码发生变更看变更集
变更项变更内容
API 描述OpenAPI 描述信息更新
错误码OpenAPI 错误码发生变更
    错误码 400 变更
    删除错误码:404
    删除错误码:500
2023-06-14OpenAPI 错误码发生变更看变更集
变更项变更内容
错误码OpenAPI 错误码发生变更
    错误码 400 变更
    删除错误码:404
    删除错误码:500
2023-03-30OpenAPI 错误码发生变更看变更集
变更项变更内容
错误码OpenAPI 错误码发生变更
    错误码 400 变更
    删除错误码:404
    删除错误码:500
2023-03-01OpenAPI 错误码发生变更看变更集
变更项变更内容
错误码OpenAPI 错误码发生变更
    删除错误码:400
    删除错误码:404
    删除错误码:500
  • 本页导读 (1)
文档反馈