专有云计算

  • 专有云计算 > API 文档 > 创建安全组规则

    创建安全组规则

    最近更新时间: 2023-03-09 17:45:22

    请求路径

    POST /api/rio/v1/compute/security_group/:id/rule

    请求参数

    名称 类型 位置 必须 描述
    x-rio-zone-id string header 地域 ID
    id string path 安全组 ID
    direction string body 流量方向:
    • all : 全部
    • ingress : 入方向
    • egress : 出方向
    type string body 安全组授权类型:
    • 1 : 安全组
    • 2 : Ipv4地址
    remote_security_group_id []string body 远端安全组 ID 列表,安全组授权类型为安全组时必传
    cidr []string body CIDR 列表,安全组授权类型为Ipv4地址时必传
    protocol string body IP协议类型:
    • all : 全部
    • tcp : TCP
    • udp : UDP
    • icmp : ICMP
    • gre : GRE
    port_range []string body 目的端安全组开放的传输层协议相关的端口范围数组。取值范围:
    • TCP/UDP协议:取值范围为1~65535。使用斜线(/)隔开起始端口和终止端口。例如:1/200
    • ICMP协议:-1/-1
    • GRE协议:-1/-1
    • IpProtocol取值为all:-1/-1
    description string body 安全组描述信息

    返回值

    名称 类型 描述
    request_id string 请求 ID
    data SecurityGroupRule 安全组对规则象

    SecurityGroupRule 安全组规则对象

    名称 类型 描述
    security_group_rule_id string 安全组规则 ID
    protocol string IP协议类型:
    • all : 全部
    • tcp : TCP
    • udp : UDP
    • icmp : ICMP
    • gre : GRE
    direction string 流量方向:
    • all : 全部
    • ingress : 入方向
    • egress : 出方向
    remote_security_group_id string 远端安全组ID
    from_port integer 最小端口号
    to_port integer 最大端口号
    cidr string CIDR
    type string 安全组授权类型:
    • 1 : 安全组
    • 2 : Ipv4地址
    created_at integer 安全组规则创建时间

    请求示例

    {
        "direction": "all",
        "protocol": "tcp",
        "port_range": [
            "80/80",
            "1433/1433"
        ],
        "type": 2,
        "cidr": [
            "0.0.0.0/0"
        ]
    }
    

    返回值示例

    {
        "request_id": "HtPfEovdw3k898sW",
        "data": [
            {
                "security_group_rule_id": "75a8d1c5-bfb8-47e6-97e2-c7309244524e",
                "direction": "ingress",
                "type": 2,
                "remote_security_group_id": null,
                "cidr": "0.0.0.0/0",
                "protocol": "",
                "from_port": 80,
                "to_port": 80,
                "description": "",
                "created_at": 0
            },
            {
                "security_group_rule_id": "6137f4a1-d391-4cc4-a26e-6640b7161053",
                "direction": "egress",
                "type": 2,
                "remote_security_group_id": null,
                "cidr": "0.0.0.0/0",
                "protocol": "",
                "from_port": 80,
                "to_port": 80,
                "description": "",
                "created_at": 0
            },
            {
                "security_group_rule_id": "b72d95e2-f676-4dc6-997e-8eb15f2eeeed",
                "direction": "ingress",
                "type": 2,
                "remote_security_group_id": null,
                "cidr": "0.0.0.0/0",
                "protocol": "",
                "from_port": 1433,
                "to_port": 1433,
                "description": "",
                "created_at": 0
            },
            {
                "security_group_rule_id": "803ae933-ca47-4e97-81cc-cabd82d65012",
                "direction": "egress",
                "type": 2,
                "remote_security_group_id": null,
                "cidr": "0.0.0.0/0",
                "protocol": "",
                "from_port": 1433,
                "to_port": 1433,
                "description": "",
                "created_at": 0
            }
        ]
    }
    
    以上内容是否对您有帮助?
  • Close