Chuyển tới nội dung chính

Create Virtual Router

POST /v2.0/routers

Creates a logical router.

This operation creates a logical router. The logical router does not have any internal interface and it is not associated with any subnet. You can optionally specify an external gateway for a router at create time. The external gateway for the router must be plugged into an external network. An external network has its router:external extended field set to true. To specify an external gateway, the ID of the external network must be passed in the network_id parameter of the external_gateway_info attribute in the request body.

info

Request

Parameters

NameInTypeDescription
routerbodyobjectA router object.
tenant_id (Optional)bodystringThe ID of the project that owns the resource. Only administrative and users with advsvc role can specify a project ID other than their own. You cannot change this value through authorization policies.
project_id (Optional)bodystringThe ID of the project that owns the resource. Only administrative and users with advsvc role can specify a project ID other than their own. You cannot change this value through authorization policies.
name (Optional)bodystringHuman-readable name of the resource. Default is an empty string.
description (Optional)bodystringA human-readable description for the resource. Default is an empty string.
admin_state_up (Optional)bodybooleanThe administrative state of the resource, which is up (true) or down (false). Default is true.
external_gateway_info (Optional)bodyobjectThe external gateway information of the router. If the router has an external gateway, this would be a dictionary of network_id, enable_snat and external_fixed_ips. Otherwise, this would be null.
network_idbodystringNetwork ID which the router gateway is connected to.
enable_snat (Optional)bodybooleanEnable Source NAT (SNAT) attribute. Default is true. To persist this attribute value, set the enable_snat_by_default option in the neutron.conf file. It is available when ext-gw-mode extension is enabled.
external_fixed_ips (Optional)bodyarrayIP address(es) of the external gateway interface of the router. Use ip_version to automatically allocate an IP address from any subnet of the specified type.
external_fixed_ips.ip_versionbodyintegerThe IP protocol version. Value is 4 or 6.
distributed (Optional)bodybooleantrue indicates a distributed router. It is available when dvr extension is enabled.
ha (Optional)bodybooleantrue indicates a highly-available router. It is available when l3-ha extension is enabled.
service_type_id (Optional)bodystringThe ID of the service type associated with the router.
flavor_id (Optional)bodystringThe ID of the flavor associated with the router.

Sample Request

Using curl

curl -ks -H 'Content-Type: application/json' -H 'X-Auth-Token: gAAAAA<...>' -d '{
"router": {
"name": "R01",
"external_gateway_info": {
"network_id": "79cab11a-122d-43a7-9427-3575d9512413",
"enable_snat": true,
"external_fixed_ips": [
{
"ip_version": 4
}
]
}
}
}' https://api.vietnix.cloud:9696/v2.0/routers

Using HTTP request

POST https://api.vietnix.cloud:9696/v2.0/routers
Content-Type: application/json
X-Auth-Token: gAAAAA<...>

{
"router": {
"name": "R01",
"external_gateway_info": {
"network_id": "79cab11a-122d-43a7-9427-3575d9512413",
"enable_snat": true,
"external_fixed_ips": [
{
"ip_version": 4
}
]
}
}
}

Response

Response Parameters

NameInTypeDescription
routerbodyobjectA router object.
idbodystringThe ID of the router.
tenant_idbodystringThe ID of the project.
project_idbodystringThe ID of the project.
namebodystringHuman-readable name of the resource.
descriptionbodystringA human-readable description for the resource.
admin_state_upbodybooleanThe administrative state of the resource, which is up (true) or down (false).
statusbodystringThe router status.
external_gateway_infobodyobjectThe external gateway information of the router. If the router has an external gateway, this would be a dictionary of network_id, enable_snat and external_fixed_ips. Otherwise, this would be null.
network_idbodystringNetwork ID which the router gateway is connected to.
enable_snatbodybooleanEnable Source NAT (SNAT) attribute. true means Network Address Translation (NAT) is enabled for traffic generated by subnets attached to the router when the traffic is sent to/received from the external network. false means no NAT is applied for traffic from/to the external network. It is available when ext-gw-mode extension is enabled.
external_fixed_ipsbodyarrayIP address(es) of the external gateway of the router. It is a list of IP addresses. Each element of the list is a dictionary of ip_address and subnet_id.
revision_numberbodyintegerThe revision number of the resource.
routesbodyarrayThe extra routes configuration for L3 router. A list of dictionaries with destination and nexthop parameters. It is available when extraroute extension is enabled.
destinationbodystringThe destination CIDR.
nexthopbodystringThe IP address of the next hop for the corresponding destination. The next hop IP address must be a part of one of the subnets to which the router interfaces are connected.
distributedbodybooleantrue indicates a distributed router. It is available when dvr extension is enabled.
habodybooleantrue indicates a highly-available router. It is available when l3-ha extension is enabled.
availability_zone_hintsbodyarrayThe availability zone candidates for the router. It is available when router_availability_zone extension is enabled. The current version of Virtuozzo Hybrid Infrastructure does not support availability zones. The response returns the default availability zone or null.
availability_zonesbodyarrayThe availability zone(s) for the router. It is available when router_availability_zone extension is enabled. The current version of Virtuozzo Hybrid Infrastructure does not support availability zones. The response returns the default availability zone or null.
service_type_idbodystringThe ID of the service type associated with the router.
flavor_idbodystringThe ID of the flavor associated with the router.
created_atbodystringThe date and time when the resource was created. The date and time stamp format is ISO 8601: CCYY-MM-DDThh:mm:ss±hh:mm. For example, 2015-08-27T09:49:58-05:00. The ±hh:mm value, if included, is the time zone as an offset from UTC. In this example, the offset value is -05:00.
updated_atbodystringThe date and time when the resource was updated. If the resource has not been updated, this field will be null. The date and time stamp format is ISO 8601: CCYY-MM-DDThh:mm:ss±hh:mm. For example, 2015-08-27T09:49:58-05:00. The ±hh:mm value, if included, is the time zone as an offset from UTC. In this example, the offset value is -05:00.
tagsbodyarrayThe list of tags on the router.
conntrack_helpersbodyarrayThe associated conntrack helper resources for the router. If the router has multiple conntrack helper resources, this field has multiple entries. Each entry consists of netfilter conntrack helper (helper), the network protocol (protocol), the network port (port).

Status Codes

Success

Status CodeDescription
201 - CreatedResource was created and is ready to use.

Error

Status CodeDescription
400 - Bad RequestSome content in the request was invalid.
401 - UnauthorizedUser must authenticate before making a request.

Sample Response

{
"router": {
"id": "a3b4012b-303d-404d-972f-ce7ad0ec6053",
"name": "R01",
"tenant_id": "f33507157a634f1cac71e06a70fb558e",
"admin_state_up": true,
"status": "ACTIVE",
"external_gateway_info": {
"network_id": "79cab11a-122d-43a7-9427-3575d9512413",
"external_fixed_ips": [
{
"subnet_id": "54ca4e27-7dfd-4504-a36b-8c47527f7a23",
"ip_address": "45.115.16.136"
}
],
"enable_snat": true
},
"description": "",
"availability_zones": [],
"availability_zone_hints": [],
"routes": [],
"flavor_id": null,
"tags": [],
"created_at": "2025-09-24T04:10:41Z",
"updated_at": "2025-09-24T04:10:42Z",
"revision_number": 3,
"project_id": "f33507157a634f1cac71e06a70fb558e"
}
}