Add Interface to Router

Verb URI Description
PUT /routers/router_id/add_router_interface Adds an internal interface to a logical router.

Normal Response Code: 200

Error Response Codes: Unauthorized (401), Bad Request (400), Not Found (404), Conflict (409)

This operation attaches a subnet to an internal router interface. Either a subnet identifier or a port identifier must be passed in the request body. If both are specified, a 400 Bad Request error is returned.

When the subnet_id attribute is specified in the request body, the subnet's gateway ip address is used to create the router interface; otherwise, if port_id is specified, the IP address associated with the port is used for creating the router interface.

It is worth remarking that a 400 Bad Request error is returned if several IP addresses are associated with the specified port, or if no IP address is associated with the port; also a 409 Conflict is returned if the port is already used.

 

Example 4.22. Add Router Interface: JSON Request

PUT /v2.0/routers/8604a0de-7f6b-409a-a47c-a1cc7bc77b2e/add_router_interface
Accept: application/json

{"subnet_id": "a2f1f29d-571b-4533-907f-5803ab96ead1"}

 

Example 4.23. Add Router Interface: JSON Response

{
    "subnet_id": "a2f1f29d-571b-4533-907f-5803ab96ead1",
    "port_id": "3a44f4e5-1694-493a-a1fb-393881c673a4"
}

The port identifier returned by this operation can either be the same identifier passed in the request body or the identifier of a new port created by this operation to attach the subnet specified by subnet_id to the router.

It is also worth noting that after executing this operation, the device_id attribute of this port is set to the router's identifier, and the device_owner attribute is set to network:router_interface, as shown in the following example:

{
    "port":
    {
        "status": "ACTIVE",
        "name": "",
        "admin_state_up": true,
        "network_id": "5307648b-e836-4658-8f1a-ff7536870c64",
        "tenant_id": "6b96ff0cb17a4b859e1e575d221683d3",
        "device_owner": "network:router_interface",
        "mac_address": "fa:16:3e:f7:d1:9c",
        "fixed_ips":
        [{
            "subnet_id": "a2f1f29d-571b-4533-907f-5803ab96ead1",
            "ip_address": "10.1.1.1"
        }],
        "id": "3a44f4e5-1694-493a-a1fb-393881c673a4",
        "device_id": "7177abc4-5ae9-4bb7-b0d4-89e94a4abf3b"
    }
}
Questions? Discuss on ask.openstack.org
Found an error? Report a bug against this page


loading table of contents...