Attach Interface to Virtual Router
PUT /v2.0/routers/{router_id}/add_router_interface
Adds an internal interface to a virtual router by attaching a specified subnet or port.
- If you specify a subnet, the subnet's gateway IP is used as the interface IP by default. You may pass a custom IP within the subnet via
ip_address. - If you specify a port, the port's fixed IP is used as the interface IP.
- Only one of
subnet_idorport_idmust be provided.
When an IPv6 subnet is specified, it is added to an existing internal port on the same network, or a new port is created if none exists. A port can have multiple IPv6 subnets that share the same network, but only one IPv4 subnet per port is allowed.
info
Source: add-interface-to-router
Request
Parameters
| Name | In | Type | Description |
|---|---|---|---|
| router_id | path | string | The ID of the router. |
| subnet_id (Optional) | body | string | The ID of the subnet. One of subnet_id or port_id must be specified. |
| port_id (Optional) | body | string | The ID of the port. One of subnet_id or port_id must be specified. |
| ip_address (Optional) | body | string | Custom IP address from the subnet to use for the router interface. Only valid when subnet_id is specified. |
Sample Request
Using curl
curl -ks -X PUT -H 'Content-Type: application/json' -H 'X-Auth-Token: gAAAAA<...>' -d '{
"subnet_id": "86c2b30c-8ee2-4a0c-828f-c7218dfa522c"
}' https://api.vietnix.cloud:9696/v2.0/routers/02542148-44cb-470d-a551-58f370c47b83/add_router_interface
Using HTTP request
PUT https://api.vietnix.cloud:9696/v2.0/routers/02542148-44cb-470d-a551-58f370c47b83/add_router_interface
Content-Type: application/json
X-Auth-Token: gAAAAA<...>
{
"subnet_id": "86c2b30c-8ee2-4a0c-828f-c7218dfa522c",
}
Response
Response Parameters
| Name | In | Type | Description |
|---|---|---|---|
| id | body | string | The ID of the router. |
| subnet_id | body | string | The ID of the subnet that the router interface belongs to. |
| subnet_ids | body | array | A list with the ID of the subnet that the router interface belongs to. Contains only one member. |
| network_id | body | string | The ID of the attached network. |
| port_id | body | string | The ID of the port that represents the router interface. |
| project_id | body | string | The ID of the project. |
| tenant_id | body | string | The ID of the project. |
| tags | body | array | The list of tags on the resource. |
Sample Response
{
"id": "66d0c3df-8b49-45ee-b153-54817fa62be2",
"tenant_id": "f33507157a634f1cac71e06a70fb558e",
"port_id": "ce3ed34b-ecb4-4e9a-958c-374054ed0e5c",
"network_id": "4ca57e10-f17f-4609-b8e4-ece4193f0a4b",
"subnet_id": "86c2b30c-8ee2-4a0c-828f-c7218dfa522c",
"subnet_ids": [
"86c2b30c-8ee2-4a0c-828f-c7218dfa522c"
]
}
Status Codes
Success
| Status Code | Description |
|---|---|
| 200 - OK | Request was successful. |
Error
| Status Code | Description |
|---|---|
| 400 - Bad Request | Some content in the request was invalid. |
| 401 - Unauthorized | User must authenticate before making a request. |
| 404 - Not Found | The requested resource could not be found. |
| 409 - Conflict | This operation conflicted with another operation on this resource. |