You need to enable JavaScript to run this app.
导航

CreateDnatEntry

最近更新时间2024.01.11 10:24:03

首次发布时间2022.11.03 08:29:57

调用 CreateDnatEntry 接口,创建一条DNAT规则。

调用说明

前提条件

  • NAT网关已绑定了公网IP。若NAT网关未绑定公网IP,您可调用 AssociateEipAddress 为NAT网关绑定公网IP。
  • 云服务器实例未绑定公网IP。公网IP的优先级高于路由表,若云服务器实例绑定公网IP,其流量通过公网IP转发,无法使用NAT网关的功能。

使用限制

单个NAT网关默认最多可创建DNAT规则的数量为100条。若默认配额无法满足需求,请前往 配额中心 提升相应配额。

请求参数

参数名称
类型
是否必选
示例值
描述
ActionStringCreateDnatEntry要执行的操作,取值:CreateDnatEntry。
VersionString2020-04-01API的版本信息,当前版本为:2020-04-01。

NatGatewayId

String

ngw-2feq5xhimd88w59gp686****

DNAT规则所属的NAT网关ID。
您可以调用 DescribeNatGateways 接口,查询NAT网关的ID。

DnatEntryName

String

dnat-01

DNAT规则的名称。

  • 长度限制为1 ~ 128个字符。
  • 需要以字母、中文或数字开头,可包含点号(.)、下划线(_)和短划线(-)。
  • 不填默认是DNAT规则的ID。

Protocol

String

tcp

协议类型。

  • tcp:转发TCP协议的报文。
  • udp:转发UDP协议的报文。
InternalIpString192.XX.XX.88向公网提供服务的云服务器实例的私网IP。

InternalPort

String

12

云服务器实例向公网提供服务的端口或端口段。

  • 端口范围为1~65535。
  • 若传入端口段,则起止端口之间用短横线(-)分隔,例如20-25。

ExternalIp

String

12.XX.XX.34

NAT网关已绑定的公网IP。
您可以调用 DescribeEipAddresses 接口,查询公网IP的地址。

ExternalPort

String

34

接收来自公网的请求的端口或端口段。

  • 端口范围为1~65535。
  • InternalPort传入端口段,则ExternalPort也必须传入端口段,且二者的端口数量相同,起止端口之间用短横线(-)分隔,例如私网IP端口传入20-25,公网IP端口传入30-35。

返回数据

参数名称
类型
示例值
描述
RequestIdString2021062415303301022514515207C4****请求ID。
DnatEntryIdStringdnat-342abc3bc3****DNAT规则的ID。

请求示例

GET /?Action=CreateDnatEntry&Version=2020-04-01&NatGatewayId=ngw-2feq5xhimd88w59gp686****&DnatEntryName=dnat-01&Protocol=tcp&InternalIp=192.XX.XX.88&InternalPort=12&ExternalIp=12.XX.XX.34&ExternalPort=34 HTTP/1.1
Host: open.volcengineapi.com
ServiceName: natgateway
Region: cn-beijing

返回示例

{
    "ResponseMetadata": {
        "RequestId": "2021062415303301022514515207C4****",
        "Action": "CreateDnatEntry",
        "Version": "2020-04-01",
        "Service": "natgateway",
        "Region": "cn-beijing"
    },
    "Result":{
        "RequestId": "2021062415303301022514515207C4****",
        "DnatEntryId": "dnat-342abc3bc3****"
    }
}

错误码

公共错误码,请参见 公共错误码 。

HttpCode
错误码
错误信息
描述
400InvalidEip.InstanceIdMismatchThe specified elastic ip and instance mismatch.指定的公网IP和实例不匹配。
400InvalidEip.InvalidStatusThe specified elastic ip is not in the correct status for the request. The specified elastic ip is in freeze.指定的弹性公网IP或私有网络所处的状态无法响应该请求。当前弹性公网IP被冻结。
400InvalidIPAddress.MalformedThe specified IP address is malformed.指定的IP不合法。
400InvalidName.MalformedThe specified name is malformed.指定的名称格式不合法。请修复名称格式后重试。
400InvalidName.MalformedThe specified name is malformed. Ensure the maximum length of name is 128.指定的名称格式不合法。名称长度不能超过128个字符。
400InvalidNatGateway.InvalidStatusThe specified NAT gateway is not in the correct status for the request.指定的NAT网关所处的状态无法响应该请求。
400InvalidPort.MalformedThe specified port is malformed. Ensure that you've specified the port in right form and internal port and external port must have the same number of ports.指定的端口不合法。请确保指定的端口格式正确,且私网端口和公网端口数量必须一致。
400InvalidProtocol.MalformedThe specified protocol is malformed.指定的协议不合法。
400QuotaExceeded.DnatEntryYou've reached the limit on the number of DnatEntry that you can create.已达到可创建的DNAT规则数量上限。
404InvalidEip.NotFoundThe specified EIP does not exist.指定的EIP不存在。
404InvalidProject.NotFoundThe specified Project does not exist.指定的项目不存在。
404InvalidNatGateway.NotFoundThe specified NAT gateway does not exist.指定的NAT网关不存在。
409InvalidDnatEntry.ConflictThe specified DNAT entry conflicts with that of another DNAT entry in your NAT gateway.指定的DNAT规则与所属NAT网关下另一条规则冲突。
412InvalidNatGateway.ExpiredThe specified NAT gateway has expired.指定的NAT网关已到期。