You need to enable JavaScript to run this app.
文档中心
NAT网关

NAT网关

复制全文
下载 pdf
SNAT规则
CreateSnatEntry - 创建SNAT规则
复制全文
下载 pdf
CreateSnatEntry - 创建SNAT规则
调用 CreateSnatEntry 接口,创建一条SNAT规则。​
使用说明​
  • 单个NAT网关支持创建SNAT规则的数量为40条。​
  • 单条SNAT规则支持关联公网IP的数量上限为40个。​
  • 如果SNAT规则默认配额无法满足需要,请前往火山引擎配额中心提升相应配额。​
注意事项​
  • SNAT规则使用的公网IP,必须为SNAT规则所属NAT网关已绑定的公网IP。您可调用DescribeNatGateways查询NAT网关已绑定的公网IP。​
  • 若SNAT规则所属NAT网关未绑定公网IP,您可调用AssociateEipAddress为NAT网关绑定公网IP。​
  • 已绑定公网IP的云服务器实例配置了SNAT规则,访问公网时会优先使用公网IP。​
  • 当多条SNAT规则的范围有所重合时,SNAT规则对应的网段的网络掩码越长,优先级越高。​
调试​
API Explorer
您可以通过 API Explorer 在线发起调用,无需关注签名生成过程,快速获取调用结果。
​
请求参数​
下方仅列出该接口特有的请求参数和部分公共参数。更多信息请见公共参数。​
Action string 必选 示例值:CreateSnatEntry​
要执行的操作,取值:CreateSnatEntry。​
​
Version string 必选 示例值:2020-04-01​
API的版本,取值:2020-04-01。​
​
EipId string 可选 示例值:eip-2feaac9wtccn459gp67****​
公网NAT网关绑定公网IP的ID。多个公网IP的ID之间用英文逗号分隔。​
您可以调用 DescribeEipAddresses 接口,查询公网IP的ID。​
  • 传入单个IP,SNAT规则将关联该公网IP,业务连接都通过该公网IP访问公网。​
  • 传入多个公网IP,SNAT规则将关联多个公网IP,业务连接通过对其五元组哈希算法后分配到的公网IP访问公网。​
说明​
NatGatewayId 传入公网NAT网关时,此参数必选。​
  • 当SNAT规则关联多个公网IP时,建议将公网IP加入共享带宽包,避免业务因其中的单个公网IP带宽达到上限而导致流量丢包。​
​
SubnetId string 可选 示例值:subnet-2fe1vklp295a859gp6766****​
SNAT规则关联子网的ID。​
您可以调用 DescribeSubnets 接口,查询子网的ID。​
SubnetId 和SourceCidr 两个参数必须且只能传入一个。​
​
SnatEntryName string 可选 示例值:snat-01​
SNAT规则的名称。​
  • 需要以字母、中文或数字开头,可包含点号(.)、下划线(_)和短划线(-)。​
  • 长度限制为1 ~ 128个字符。不填默认是SNAT规则的ID。​
​
SourceCidr string 可选 示例值:192.XX.XX.0/20​
指定SNAT规则的网段。不同粒度对应不同的网段,具体说明如下:​
  • 私有网络粒度:指定NAT网关所在私有网络的网段。私有网络内所有未绑定公网IP的云服务器实例支持通过SNAT规则访问公网。​
  • 子网粒度:指定子网的网段(如192.XX.XX.0/24)。指定子网内所有未绑定公网IP的云服务器实例支持通过SNAT规则访问公网。​
  • 云服务器粒度:指定云服务器的网段(如192.XX.XX.20/32)。指定的未绑定公网IP的云服务器实例支持通过SNAT规则访问公网。​
  • 自定义网段粒度:指定自定义网段(如192.XX.XX.0/26),指定自定义网段内所有未绑定公网IP的云服务器实例支持通过SNAT规则访问公网。​
说明​
SubnetId和SourceCidr两个参数必须且只能传入一个。若传入SubnetId,则不能传入SourceCidr。若传入SourceCidr,则不能传入SubnetId。 指定的网段与已存在的SNAT规则的网段不能重复。​
​
NatIpId string 可选 示例值:vpcnatip-gw8y7q3cpk3fggs8****​
私网NAT网关的中转IP的ID。​
您可以调用 DescribeNatIps 接口,查询中转IP的ID。​
不填表示传入默认中转IP。​
​
NatGatewayId string 必选 示例值:ngw-2fedgzyvtzaio59gp675****​
SNAT规则所属的NAT网关ID。​
您可以调用 DescribeNatGateways 接口,查询NAT网关的ID。​
​
​
​
返回参数​
下方仅列出本接口特有的返回参数。更多信息请参见返回结构。​
RequestId string 示例值:2021062415303301022514515207C4****​
请求ID。​
​
SnatEntryId string 示例值:snat-2fedhzdlyknb459gp676o****​
SNAT规则的ID。​
​
​
​
请求示例​
​
GET /?Action=CreateSnatEntry&Version=2020-04-01&NatGatewayId=ngw-2fedgzyvtzaio59gp675****&SubnetId=subnet-2fe1vklp295a859gp6766****&EipId=eip-2feaac9wtccn459gp67****&SnatEntryName=snat-01 HTTP/1.1​
Host: natgateway.cn-beijing.volcengineapi.com​
Service: natgateway​
Region: cn-beijing​
​
返回示例​
​
{​
"ResponseMetadata": {​
"RequestId": "2021062415303301022514515207C4****",​
"Action": "CreateSnatEntry",​
"Version": "2020-04-01",​
"Service": "natgateway",​
"Region": "cn-beijing"​
},​
"Result":{​
"RequestId": "2021062415303301022514515207C4****",​
"SnatEntryId": "snat-2fedhzdlyknb459gp676o****"​
}​
}​
​
错误码​
下表为您列举了该接口与业务逻辑相关的错误码。公共错误码请参见公共错误码文档。​
​
状态码​
错误码​
错误信息​
说明​
400​
MissingParameter​
The request is missing a required parameter.​
该请求缺少必要参数。​
400​
InvalidEip.InvalidStatus​
The specified elastic ip is not in the correct status for the request. The specified elastic ip is in freeze.​
指定的公网IP或私有网络所处的状态无法响应该请求。当前公网IP被冻结。​
400​
InvalidParameter.SourceCidrConflict​
The specified source cidr and subnet conflict.​
指定的网段和子网参数冲突。​
400​
QuotaExceeded.SnatEntry​
SNAT entries number of the NAT gateway exceeded quota.​
已达到一个NAT网关可创建SNAT规则的数量上限。​
400​
LimitExceeded.EipsPerSnatEntry​
You've reached the limit on the number of EIPs per snat entry.​
已达到每条SNAT规则支持关联公网IP的数量上限。​
400​
InvalidSourceCidr.Malformed​
The specified source cidr is malformed.​
指定的网段格式不正确。​
400​
InvalidSnatEntry.VpcMismatch​
The specified subnet is not in the NAT gateway's VPC.​
指定的子网不在NAT网关的VPC中。​
400​
InvalidSnatEntry.Conflict​
The specified source cidr or subnet conflicts with that of a SNAT entry in your NAT gateway.​
指定的网段或子网网段与已经关联SNAT规则。​
400​
InvalidNatGateway.InvalidStatus​
The specified NAT gateway is not in the correct status for the request.​
指定的NAT网关所处的状态无法响应该请求。​
400​
InvalidEip.InstanceMismatch​
The specified elastic ip and instance mismatch.​
指定的公网IP和实例不匹配。​
400​
InvalidSnatEntry.EipNotSupported​
Can not create or modify SNAT entry with eip on the specified NAT gateway.​
不支持在指定的NAT网关上创建或修改使用EIP的SNAT规则。​
400​
InvalidSnatEntry.NatIpConflict​
The specified nat ip and eip conflict.​
指定的NAT IP和EIP参数冲突。​
400​
InvalidSnatEntry.NatIpNotSupported​
Can not create or modify SNAT entry with nat ip on the specified NAT gateway.​
不支持在指定的NAT网关上创建或修改使用NAT IP的SNAT规则。​
400​
InvalidEip.InUse​
The specified eip has been used by dnat entry of ip mapping.​
指定的EIP已被IP映射的DNAT规则使用。​
400​
InvalidName.Malformed​
The specified name is malformed.​
指定的名称格式不合法。请修复名称格式后重试。​
400​
InvalidName.Malformed​
The specified name is malformed.Ensure the maximum length of name is 128.​
指定的名称格式不合法。名称长度不能超过128个字符。​
404​
InvalidProject.NotFound​
The specified Project does not exist.​
指定的项目不存在。​
404​
InvalidSubnet.NotFound​
The specified subnet does not exist.​
指定的子网不存在。​
404​
InvalidNatGateway.NotFound​
The specified NAT gateway does not exist.​
指定的NAT网关不存在。​
404​
InvalidEip.NotFound​
The specified EIP does not exist.​
指定的EIP不存在。​
404​
InvalidNatIp.NotFound​
The specified nat ip does not exist.​
指定的NAT IP不存在。​
409​
InvalidSnatEntry.EipConflict​
The specified EIP conflicts with that of another EIP in the snat entry.​
SNAT规则中的EIP冲突。​
412​
InvalidNatGateway.Expired​
The specified NAT gateway has expired.​
指定的NAT网关已到期。​
500​
InternalError​
An internal error has occurred.​
发生内部错误。​
​
​
最近更新时间:2026.10.30 11:15:37
这个页面对您有帮助吗?
有用
有用
无用
无用