Skip to main content

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_id or port_id must 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.

Request

Parameters

NameInTypeDescription
router_idpathstringThe ID of the router.
subnet_id (Optional)bodystringThe ID of the subnet. One of subnet_id or port_id must be specified.
port_id (Optional)bodystringThe ID of the port. One of subnet_id or port_id must be specified.
ip_address (Optional)bodystringCustom 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

NameInTypeDescription
idbodystringThe ID of the router.
subnet_idbodystringThe ID of the subnet that the router interface belongs to.
subnet_idsbodyarrayA list with the ID of the subnet that the router interface belongs to. Contains only one member.
network_idbodystringThe ID of the attached network.
port_idbodystringThe ID of the port that represents the router interface.
project_idbodystringThe ID of the project.
tenant_idbodystringThe ID of the project.
tagsbodyarrayThe 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 CodeDescription
200 - OKRequest was successful.

Error

Status CodeDescription
400 - Bad RequestSome content in the request was invalid.
401 - UnauthorizedUser must authenticate before making a request.
404 - Not FoundThe requested resource could not be found.
409 - ConflictThis operation conflicted with another operation on this resource.