華為云計算 云知識 創(chuàng)建子網(wǎng)NeutronCreateSubnet
創(chuàng)建子網(wǎng)NeutronCreateSubnet

 

功能介紹

創(chuàng)建子網(wǎng)。

調(diào)試

您可以在API Explorer中調(diào)試該接口。

約束與限制

  • 網(wǎng)絡(luò)下存在IPv4子網(wǎng)的情況下,才可以創(chuàng)建IPv6子網(wǎng)。
  • VXLAN類型網(wǎng)絡(luò)下只能有一個IPv4的子網(wǎng)和一個IPv6的子網(wǎng)。

URI

POST /v2.0/subnets

請求參數(shù)

表1 請求參數(shù)

參數(shù)名稱

類型

必選

說明

subnet

subnet object

subnet對象,參見表2。

表2 subnet對象

屬性

是否必選

類型

說明

name

String

子網(wǎng)的名稱

ip_version

Integer

IP版本

【使用說明】支持IPv4、IPv6

ipv6_address_mode

String

IPv6尋址模式

【使用說明】僅支持dhcpv6-stateful

ipv6_ra_mode

String

IPv6路由廣播模式

【使用說明】僅支持dhcpv6-stateful

network_id

String

所屬網(wǎng)絡(luò)的id

cidr

String

CIDR格式

【使用說明】IPV4只支持10.0.0.0/8,172.16.0.0/12,192.168.0.0/16三個網(wǎng)段內(nèi)的地址,掩碼長度不能大于28。

IPV6掩碼長度不能大于128。

gateway_ip

String

網(wǎng)關(guān)IP不允許和allocation_pools地址塊沖突。

【使用說明】不支持修改。

allocation_pools

Array of allocation_pool objects

可用的IP池,allocation_pool對象參見表3

例如:[ { "start": "10.0.0.2", "end": "10.0.0.251"} ]

每個子網(wǎng)的第1個和最后3個IP地址為系統(tǒng)保留地址。以192.168.1.0/24為例,192.168.1.0、 192.168.1.253、192.168.1.254和192.168.1.255這些地址是系統(tǒng)保留地址。

[{"start": "2001:db8:a583:9::2", "end": "2001:db8:a583:9:ffff:ffff:ffff:fffc"}]

ipv6子網(wǎng)以2001:db8:a583:9::/64為例,2001:db8:a583:9::1和2001:db8:a583:9:ffff:ffff:ffff:fffd、2001:db8:a583:9:ffff:ffff:ffff:fffe、2001:db8:a583:9:ffff:ffff:ffff:ffff這些地址是系統(tǒng)保留地址。

系統(tǒng)預(yù)留地址默認(rèn)不在allocation_pool范圍內(nèi)。

約束:更新時allocation_pool范圍不能包含網(wǎng)關(guān)和廣播地址的所有IP。

dns_nameservers

Array of strings

dns服務(wù)器

【使用說明】

例如:"dns_nameservers": ["8.xx.xx.8","8.xx.xx.4"]

最大為5個

不填時,默認(rèn)為空

內(nèi)網(wǎng) DNS地址 請參見華為云提供的內(nèi)網(wǎng)DNS地址是多少?

host_routes

Array of host_route objects

虛擬機靜態(tài)路由,參見表4

【使用說明】不支持,忽略輸入信息

enable_dhcp

Boolean

是否啟動dhcp,false表示不提供dhcp服務(wù)的能力

【使用說明】只支持true

表3 allocation_pool對象

參數(shù)名

是否必選

參數(shù)類型

說明

start

String

網(wǎng)絡(luò)池起始IP

end

String

網(wǎng)絡(luò)池結(jié)束IP

表4 host_route對象

參數(shù)名

是否必選

參數(shù)類型

說明

destination

String

路由目的子網(wǎng)

nexthop

String

路由下一跳IP

請求示例

創(chuàng)建子網(wǎng),所在network為0133cd73-34d4-4d4c-bf1f-e65b24603206,指定cidr為172.16.2.0/24,命名為subnet-test。

POST https://{Endpoint}/v2.0/subnets 

{
    "subnet": {
           "name": "subnet-test",
           "network_id": "0133cd73-34d4-4d4c-bf1f-e65b24603206",
           "cidr": "172.16.2.0/24",
           "enable_dhcp": true
    }
}

響應(yīng)參數(shù)

表5 響應(yīng)參數(shù)

參數(shù)名稱

類型

說明

subnet

subnet object

subnet對象,參見表6。

表6 subnet對象

屬性

類型

說明

id

String

子網(wǎng)的id

【使用說明】在查詢子網(wǎng)列表時非必選

name

String

子網(wǎng)的名稱

ip_version

Integer

IP版本

【使用說明】支持IPv4、IPv6

ipv6_address_mode

String

IPv6尋址模式

【使用說明】僅支持dhcpv6-stateful

ipv6_ra_mode

String

IPv6路由廣播模式

【使用說明】僅支持dhcpv6-stateful

network_id

String

所屬網(wǎng)絡(luò)的id

cidr

String

CIDR格式

【使用說明】只支持10.0.0.0/8,172.16.0.0/12,192.168.0.0/16三個網(wǎng)段內(nèi)的地址,掩碼長度不能大于28。

gateway_ip

String

網(wǎng)關(guān)IP不允許和allocation_pools地址塊沖突。

【使用說明】不支持修改。

allocation_pools

Array of allocation_pool objects

可用的IP池,allocation_pool對象參見

表7

例如:[ { "start": "10.0.0.2", "end": "10.0.0.251"} ]

每個子網(wǎng)的第1個和最后3個IP地址為系統(tǒng)保留地址。以192.168.1.0/24為例,192.168.1.0、 192.168.1.253、192.168.1.254和192.168.1.255這些地址是系統(tǒng)保留地址。系統(tǒng)預(yù)留地址默認(rèn)不在allocation_pool范圍內(nèi)。

約束:更新時allocation_pool范圍不能包含網(wǎng)關(guān)和廣播地址的所有IP。

dns_nameservers

Array of strings

dns服務(wù)器

例如:"dns_nameservers": ["8.xx.xx.8","8.xx.xx.4"]

host_routes

Array of host_route objects

虛擬機靜態(tài)路由,參見表8

【使用說明】不支持,忽略輸入信息

tenant_id

String

項目ID

enable_dhcp

Boolean

是否啟動dhcp,false表示不提供dhcp服務(wù)的能力

【使用說明】只支持true

subnetpool_id

String

子網(wǎng)池id

【使用說明】目前IPv4不支持,IPv6支持

project_id

String

項目ID,請參見獲取項目ID。

created_at

String

資源創(chuàng)建時間,UTC時間

格式:yyyy-MM-ddTHH:mm:ss

updated_at

String

資源更新時間,UTC時間

格式:yyyy-MM-ddTHH:mm:ss

表7 allocation_pool對象

參數(shù)名

參數(shù)類型

備注

start

String

網(wǎng)絡(luò)池起始IP

end

String

網(wǎng)絡(luò)池結(jié)束IP

表8 host_route對象

參數(shù)名

參數(shù)類型

備注

destination

String

路由目的子網(wǎng)

nexthop

String

路由下一跳IP

響應(yīng)示例

{
    "subnet": {
        "name": "subnet-test",
        "cidr": "172.16.2.0/24",
        "id": "98bac90c-0ba7-4a63-8995-097da9bead1c",
        "enable_dhcp": true,
        "network_id": "0133cd73-34d4-4d4c-bf1f-e65b24603206",
        "tenant_id": "bbfe8c41dd034a07bebd592bf03b4b0c",
        "project_id": "bbfe8c41dd034a07bebd592bf03b4b0c",
        "dns_nameservers": [],
        "allocation_pools": [
            {
                "start": "172.16.2.2",
                "end": "172.16.2.251"
            }
        ],
        "host_routes": [],
        "ip_version": 4,
        "gateway_ip": "172.16.2.1",
        "created_at": "2018-09-20T02:02:16",
        "updated_at": "2018-09-20T02:02:16"
    }
}

狀態(tài)碼

請參見狀態(tài)碼。

錯誤碼

請參見錯誤碼