全部产品
Search
文档中心

云服务器 ECS:ModifySecurityGroupEgressRule

更新时间:Sep 12, 2023

调用ModifySecurityGroupEgressRule修改出方向安全组规则。

接口说明

安全组相关的API文档中,入方向流量的发起端为源端(Source),数据传输的接收端为目的端(Dest)。

在您指定安全组规则ID修改安全组规则时,您需要注意以下使用限制:

  • 安全组规则的授权对象分为CIDR地址块(或IP地址)、安全组、前缀列表三种类型。您不能通过该接口修改已有安全组规则的授权对象类型。如原来授权对象类型为IP地址,您可以更改为另一个IP地址或CIDR地址块,但不能修改为安全组或前缀列表。
  • 安全组规则授权对象的IP地址族不支持修改。如原安全组规则授权对象CIDR地址块为IPv4,您不能将其修改为IPv6的CIDR地址块。又如规则的授权对象为一个IPv4地址族的前缀列表,您不能将其修改为一个IPv6地址族的前缀列表。
  • 修改后的安全组规则不能与已有其它规则相同。
  • 字段不支持从非空修改为空,如果需要修改建议先增加一条新规则,再删除当前规则。

调试

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

请求参数

名称

类型

是否必选

示例值

描述

Action String ModifySecurityGroupEgressRule

系统规定参数。取值:ModifySecurityGroupEgressRule

RegionId String cn-hangzhou

源端安全组所属地域ID。您可以调用DescribeRegions查看最新的阿里云地域列表。

ClientToken String 123e4567-e89b-12d3-a456-426655440000

保证请求幂等性。从您的客户端生成一个参数值,确保不同请求间该参数值唯一。ClientToken只支持ASCII字符,且不能超过64个字符。更多信息,请参见如何保证幂等性

SecurityGroupId String sg-bp67acfmxazb4p****

安全组ID。

SecurityGroupRuleId String sgr-bp67acfmxazb4q****

安全组规则ID。

根据安全组规则ID修改规则时,该参数必填。

Policy String accept

访问权限。取值范围:

  • accept:接受访问。
  • drop:拒绝访问,不返回拒绝信息。

默认值:accept。

Priority String 1

安全组规则优先级。取值范围:1~100。

默认值:1。

IpProtocol String tcp

传输层协议。不区分大小写。取值范围:

  • ICMP
  • GRE
  • TCP
  • UDP
  • ALL:支持所有协议。
DestCidrIp String 10.0.0.0/8

目的端IPv4 CIDR地址块。支持CIDR格式和IPv4格式的IP地址范围。

默认值:无。

Ipv6DestCidrIp String 2001:db8:1233:1a00::***

目的端IPv6 CIDR地址块。支持CIDR格式和IPv6格式的IP地址范围。

说明 仅支持VPC类型的IP地址,且该参数与DestCidrIp参数不可同时设置。

默认值:无。

DestGroupId String sg-bp67acfmxa123b****

需要设置访问权限的目的端安全组ID。至少设置一项DestGroupId或者DestCidrIp参数。

  • 至少设置DestGroupId、DestCidrIp、Ipv6DestCidrIp或DestPrefixListId参数中的一项。
  • 如果指定了DestGroupId没有指定参数DestCidrIp,则参数NicType取值只能为intranet。
  • 如果同时指定了DestGroupId和DestCidrIp,则默认以DestCidrIp为准。
DestPrefixListId String pl-x1j1k5ykzqlixdcy****

目的端前缀列表ID。您可以调用DescribePrefixLists查询可以使用的前缀列表ID。

当您指定了DestCidrIpIpv6DestCidrIp或者DestGroupId参数中的一个时,将忽略该参数。

PortRange String 80/80

目的端安全组开放的传输层协议相关的端口范围。取值范围:

  • TCP/UDP协议:取值范围为1~65535。使用斜线(/)隔开起始端口和终止端口。例如:1/200。
  • ICMP协议:-1/-1。
  • GRE协议:-1/-1。
  • ALL:-1/-1。
SourceCidrIp String 10.0.0.0/8

源端IPv4 CIDR地址块。支持CIDR格式和IPv4格式的IP地址范围。

默认值:无。

Ipv6SourceCidrIp String 2001:db8:1234:1a00::***

源端IPv6 CIDR地址块。支持CIDR格式和IPv6格式的IP地址范围。

说明 仅支持VPC类型的IP地址,且该参数与SourceCidrIp参数不可同时设置。

默认值:无。

SourcePortRange String 80/80

源端安全组开放的传输层协议相关的端口范围。取值范围:

  • TCP/UDP协议:取值范围为1~65535。使用斜线(/)隔开起始端口和终止端口。例如:1/200
  • ICMP协议:-1/-1。
  • GRE协议:-1/-1。
  • ALL:-1/-1。
DestGroupOwnerAccount String EcsforCloud@Alibaba.com

跨账户设置安全组规则时,目的端安全组所属的阿里云账户。

DestGroupOwnerId Long 1234567890

跨账户设置安全组规则时,目的端安全组所属的阿里云账户ID。

NicType String intranet

根据安全组规则ID修改规则时,不支持修改该参数。

如果需要修改,建议先增加一条新规则,再删除当前规则。

Description String This is a new securitygroup rule.

安全组规则的描述信息。长度为1~512个字符。

返回数据

名称

类型

示例值

描述

RequestId String 473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

请求ID。

示例

请求示例

https://ecs.aliyuncs.com/?Action=ModifySecurityGroupEgressRule
&SecurityGroupId=sg-bp67acfmxazb4p****
&SecurityGroupRuleId=sgr-dcd43def****
&SourcePrefixListId=pl-x1j1k5ykzqlixdew****
&<公共请求参数>

正常返回示例

XML格式

HTTP/1.1 200 OK
Content-Type:application/xml

<ModifySecurityGroupEgressRuleResponse>
    <RequestId>CEF72CEB-54B6-4AE8-B225-F876FF7BA984</RequestId>
</ModifySecurityGroupEgressRuleResponse>

JSON格式

HTTP/1.1 200 OK
Content-Type:application/json

{
  "RequestId" : "CEF72CEB-54B6-7AE8-B225-F876FF7BA984"
}

错误码

HttpCode

错误码

错误信息

描述

400 OperationDenied The specified IpProtocol does not exist or IpProtocol and PortRange do not match. 指定的 IP 协议不存在,或与端口范围不匹配。
400 InvalidIpProtocol.Malformed The specified parameter PortRange is not valid. IP 协议参数格式不正确,PortRange 参数不正确。
400 InvalidDestCidrIp.Malformed The specified parameter DestCidrIp is not valid. 指定的 DestCidrIp 无效,请您检查该参数是否正确。
400 InvalidPolicy.Malformed The specified parameter Policy is not valid. 指定的参数无效,请您检查该参数是否正确。
400 InvalidNicType.ValueNotSupported The specified NicType does not exist. 指定的网络类型不存在,请您检查网络类型是否正确。
400 InvalidNicType.Mismatch The specified NicType conflicts with the authorization record. 指定的网卡类型与已有规则不匹配。
400 InvalidDestGroupId.Mismatch Specified security group and destination group are not in the same VPC. 指定的安全组和目标组不在同一个 VPC 下。
400 InvalidDestGroup.NotFound Specified destination security group does not exist. 指定的出方向安全组不存在。
400 InvalidPriority.Malformed The specified parameter Priority is not valid. 安全组规则的优先级不合法,可选范围为 1-100。
400 InvalidPriority.ValueNotSupported The specified Priority is invalid. 您指定的优先级无效。
400 InvalidNicType.ValueNotSupported The specified NicType is not valid. 指定的网络类型不存在,请您检查网络类型是否正确。
400 InvalidSecurityGroupDiscription.Malformed The specified security group rule description is not valid. 指定的安全组规则描述不合法。
400 InvalidSecurityGroup.InvalidNetworkType The specified security group network type is not support this operation, please check the security group network types. For VPC security groups, ClassicLink must be enabled. 指定的安全组网络类型不支持此操作,请检查安全组网络类型。对于 VPC 安全组,必须启用 ClassicLink。
400 MissingParameter.Dest One of the parameters DestCidrIp, DestGroupId or DestPrefixListId must be specified. 至少需要指定参数DestCidrIp、DestGroupId或DestPrefixListId中的一个。
400 InvalidParam.PortRange The specified parameter %s is not valid. It should be two integers less than 65535 in ?/? format. 端口范围不合法,应为斜线分隔两个整数的格式。
400 InvalidPriority.ValueNotSupported The parameter Priority is invalid. 指定的参数 Priority 无效。
400 InvalidParam.SourceIp The Parameters SourceCidrIp and Ipv6SourceCidrIp in %s cannot be set at the same time. 参数SourceCidrIp和Ipv6SourceCidrIp不能被同时设置。
400 InvalidParam.DestIp The Parameters DestCidrIp and Ipv6DestCidrIp in %s cannot be set at the same time. 参数DestCidrIp和Ipv6DestCidrIp不能被同时设置。
400 InvalidParam.Ipv6DestCidrIp The specified parameter %s is not valid. 指定的参数Ipv6DestCidrIp不合法。
400 InvalidParam.Ipv6SourceCidrIp The specified parameter %s is not valid. 指定的参数Ipv6SourceCidrIp不合法。
400 InvalidParam.Ipv4ProtocolConflictWithIpv6Address IPv6 address cannot be specified for IPv4-specific protocol. IPv4协议不能指定IPv6地址。
400 InvalidParam.Ipv6ProtocolConflictWithIpv4Address IPv4 address cannot be specified for IPv6-specific protocol. IPv6协议不能指定IPv4地址。
400 InvalidParameter.Ipv6CidrIp The specified Ipv6CidrIp is not valid. 指定的Ipv6CidrIp参数不合法。
400 InvalidSourcePortRange.Malformed The specified parameter SourcePortRange is not valid. 指定的参数 SourcePortRange 无效。
400 InvalidParam.SourceCidrIp The specified param SourceCidrIp is not valid. 参数SourceCidrIp不合法。
400 InvalidParam.DestCidrIp The specified param DestCidrIp is not valid. 您指定的参数DestCidrIp不合法。
400 InvalidParameter.Conflict IPv6 and IPv4 addresses cannot exist at the same time. IPv6地址和IPv4地址不能同时指定。
400 InvalidParam.SecurityGroupRuleId The specified parameter SecurityGroupRuleId is not valid. 指定的参数SecurityGroupRuleId不合法。
400 InvalidOperation.ModifySgRuleEntityType The source or destination type of the rules cannot be modified. 规则的源或目的类型不能被修改。
400 AuthorizationLimitExceed The limit of authorization records in the security group reaches. 安全组授权规则数达到上限,请您检查授权规则是否合理。
400 InvalidPrefixListId.NotFound The specified prefix list was not found. 前缀列表不存在。
400 InvalidParam.ProtocolAndPortRangeMismatch The specified Protocol and PortRange do not match. 指定和协议和端口范围不匹配。
400 InvalidParam.ProtocolAndAddressFamilyMismatch The specified Protocol and address family do not match. 指定的协议和地址族不匹配。
400 InvalidParam.PrefixListAddressFamilyMismatch The address family of the prefix list does not match the rule. 前缀列表的地址族与规则不匹配。
400 InvalidParam.InvalidModifyRuleRequest The request parameters are illegal. 请求参数不合法。
400 InvalidOperation.ModifyNicType NicType is not allowed to modify. 不允许修改NicType。
400 InvalidParamter.Conflict The specified SourceCidrIp should be different from the DestCidrIp. 参数 SourceCidrIp 和 DestCidrIp 不能相同。
400 InvalidIpProtocol.ValueNotSupported The parameter %s must be specified with case insensitive TCP, UDP, ICMP, GRE or All. 协议Protocol字段不合法,应指定大小写不敏感的TCP,UDP,ICMP,GRE或All。
403 InvalidDestGroupId.Mismatch NicType is required or NicType expects intranet. 请指定 NicType,或使用内网模式。
403 MissingParameter The input parameter DestGroupId or DestCidrIp cannot be both blank. 参数 DestGroupId 和 DestCidrIp 不得为空。
403 InvalidParamter.Conflict The specified SecurityGroupId should be different from the SourceGroupId. 授权与被授权安全组必须不同。
403 InvalidNetworkType.Conflict The specified SecurityGroup network type should be same with SourceGroup network type (vpc or classic). 指定的 SecurityGroup 的网络类型必须与 SouceGroup 的网络类型一致。
403 InvalidSecurityGroup.IsSame The authorized SecurityGroupId should be different from the DestGroupId. 已授权的 SecurityGroupId 不能与 DestGroupId 相同。
403 InvalidOperation.ResourceManagedByCloudProduct %s 云产品托管的安全组不支持修改操作。
404 InvalidSecurityGroupId.NotFound The specified SecurityGroupId does not exist. 指定的安全组在该用户账号下不存在,请您检查安全组 ID 是否正确。
404 InvalidDestGroupId.NotFound The DestGroupId provided does not exist in our records. 指定的出方向安全组不存在。
404 SecurityGroupRule.NotFound The target security group rule do not exist. 指定的安全组规则不存在。
404 InvalidSecurityGroupRuleId.NotFound The specified SecurityGroupRuleId is not exists. 指定的SecurityGroupRuleId不存在。
500 InternalError The request processing has failed due to some unknown error. 内部错误,请重试。

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