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

List Virtual Router Interfaces

GET /v2.0/ports

Lists ports to which the user has access.

Use this call to find port IDs of a virtual router with the specified ID. Filter with device_id={router_id}. You may also filter by device_owner=network:router_interface for internal interfaces or device_owner=network:router_gateway for the external gateway interface.

Default policy settings return only those ports that are owned by the project of the user who submits the request, unless the request is submitted by a user with administrative rights.

If the ip-substring-filtering extension is enabled, the Networking API supports IP address substring filtering on the fixed_ips attribute. If you specify an IP address substring (ip_address_substr) in an entry of the fixed_ips attribute, the API lists all ports that have an IP address matching the substring.

info

Source: list-ports

Request

Parameters

NameInTypeDescription
admin_state_up (Optional)querybooleanFilter by administrative state: up (true) or down (false).
binding:host_id (Optional)querystringFilter by the ID of the host where the port resides.
description (Optional)querystringFilter by the human-readable description of the port.
device_id (Optional)querystringFilter by the ID of the device that uses this port (for example, a server instance or a logical router ID).
device_owner (Optional)querystringFilter by the entity type that uses this port (for example, compute:nova, network:dhcp, network:router_interface).
fixed_ips (Optional)queryarrayFilter by IP addresses for the port. Each entry can include ip_address, ip_address_substr, and/or subnet_id.
id (Optional)querystringFilter by the ID of the port.
ip_allocation (Optional)querystringFilter ports using deferred, immediate, or no IP allocation (none).
mac_address (Optional)querystringFilter by the MAC address of the port.
name (Optional)querystringFilter by the human-readable name of the port.
network_id (Optional)querystringFilter by the ID of the attached network.
project_id (Optional)querystringFilter by the ID of the project that owns the resource.
revision_number (Optional)queryintegerFilter by the revision number of the resource.
sort_dir (Optional)querystringSort direction, asc or desc. Multiple sort_key/sort_dir pairs allowed.
sort_key (Optional)querystringSort by a port attribute. Allowed keys: admin_state_up, device_id, device_owner, id, ip_allocation, mac_address, name, network_id, project_id, status, tenant_id.
status (Optional)querystringFilter by port status: ACTIVE, DOWN, BUILD, ERROR.
tenant_id (Optional)querystringFilter by the ID of the project that owns the resource.
tags (Optional)querystringReturn resources that match all specified tags (comma-separated).
tags-any (Optional)querystringReturn resources that match any of the specified tags (comma-separated).
not-tags (Optional)querystringExclude resources that match all specified tags (comma-separated).
not-tags-any (Optional)querystringExclude resources that match any of the specified tags (comma-separated).
fields (Optional)querystringLimit returned fields. Can be specified multiple times, e.g. fields=id&fields=name.
mac_learning_enabled (Optional)querybooleanFilter by mac learning state: enabled (true) or disabled (false).

Sample Request

Using curl

curl -ks -H 'Content-Type: application/json' -H 'X-Auth-Token: gAAAAA<...>' \
https://api.vietnix.cloud:9696/v2.0/ports?device_id=66fa6a3b-4b3a-485f-819d-c671765eb915

Using HTTP request

GET https://api.vietnix.cloud:9696/v2.0/ports?device_id={router_id}
X-Auth-Token: gAAAAA<...>

Response

Response Parameters

NameInTypeDescription
portsbodyarrayA list of port objects.
admin_state_upbodybooleanAdministrative state: up (true) or down (false).
allowed_address_pairsbodyarrayZero or more allowed address pair objects (ip_address, mac_address).
binding:host_idbodystringID of the host where the port resides.
binding:profilebodyobjectHost/driver specific VIF binding information.
binding:vif_detailsbodyobjectAdditional information on the port (for example, port_filter, ovs_hybrid_plug).
binding:vif_typebodystringMechanism type used for the port (for example, ovs, bridge, vhostuser). Includes special values: unbound, binding_failed.
binding:vnic_typebodystringvNIC type to which the port should be attached (normal, direct, etc.).
created_atbodystringISO 8601 creation timestamp.
data_plane_statusbodystringStatus of the underlying data plane of a port.
descriptionbodystringHuman-readable description for the port.
device_idbodystringID of the device using the port (for example, server instance or logical router ID).
device_ownerbodystringEntity type that uses the port (for example, network:router_interface).
dns_assignmentbodyobjectNetworking internal DNS assignment for the port.
dns_domainbodystringDNS domain.
dns_namebodystringDNS name.
extra_dhcp_optsbodyarrayExtra DHCP option pairs.
fixed_ipsbodyarrayOne or more fixed IPs (ip_address, subnet_id).
idbodystringPort ID.
ip_allocationbodystringWhen IPs are allocated: deferred, immediate, or none.
mac_addressbodystringPort MAC address.
namebodystringPort name.
network_idbodystringAttached network ID.
port_security_enabledbodybooleanWhether port security is enabled.
project_idbodystringProject ID.
qos_network_policy_idbodystringQoS policy ID of the network where the port is plugged.
qos_policy_idbodystringQoS policy ID associated with the port.
revision_numberbodyintegerRevision number.
resource_request (Optional)bodyobjectPlacement resources and traits requested by the port.
security_groupsbodyarraySecurity group IDs applied to the port.
statusbodystringPort status (ACTIVE, DOWN, BUILD, ERROR).
tenant_idbodystringProject ID.
tagsbodyarrayList of tags on the resource.
updated_atbodystringISO 8601 update timestamp or null.
propagate_uplink_statusbodybooleanUplink status propagation (true/false).
mac_learning_enabled (Optional)bodybooleanWhether MAC Learning is enabled on the port.

Sample Response

{
"ports": [
{
"id": "a60d084b-5bac-489c-b549-7e651b577e36",
"name": "",
"network_id": "36a3666a-8ed4-48bf-9528-15f573c4a4f0",
"tenant_id": "f33507157a634f1cac71e06a70fb558e",
"mac_address": "fa:16:3e:8a:27:15",
"admin_state_up": true,
"status": "ACTIVE",
"device_id": "66fa6a3b-4b3a-485f-819d-c671765eb915",
"device_owner": "network:router_interface_distributed",
"fixed_ips": [
{
"subnet_id": "b367fdf4-d111-4c4c-b8c2-ea5d484ac0fb",
"ip_address": "192.168.10.1"
}
],
"allowed_address_pairs": [],
"extra_dhcp_opts": [],
"security_groups": [],
"description": "",
"binding:vnic_type": "normal",
"port_security_enabled": false,
"qos_policy_id": null,
"qos_network_policy_id": "dfc42ced-02c8-4b1f-bbe6-14cc014f259d",
"tags": [],
"created_at": "2025-09-23T16:01:32Z",
"updated_at": "2025-09-24T05:07:52Z",
"revision_number": 18,
"project_id": "f33507157a634f1cac71e06a70fb558e"
},
{
"id": "f43d2167-fcaf-4ac7-b8ab-8d96ef896f59",
"name": "",
"network_id": "36a3666a-8ed4-48bf-9528-15f573c4a4f0",
"tenant_id": "",
"mac_address": "fa:16:3e:c9:34:38",
"admin_state_up": true,
"status": "ACTIVE",
"device_id": "66fa6a3b-4b3a-485f-819d-c671765eb915",
"device_owner": "network:router_centralized_snat",
"fixed_ips": [
{
"subnet_id": "b367fdf4-d111-4c4c-b8c2-ea5d484ac0fb",
"ip_address": "192.168.10.242"
}
],
"allowed_address_pairs": [],
"extra_dhcp_opts": [],
"security_groups": [],
"description": "",
"binding:vnic_type": "normal",
"port_security_enabled": false,
"qos_policy_id": null,
"qos_network_policy_id": "dfc42ced-02c8-4b1f-bbe6-14cc014f259d",
"tags": [],
"created_at": "2025-09-23T16:01:32Z",
"updated_at": "2025-09-24T05:07:50Z",
"revision_number": 12,
"project_id": ""
}
]
}

Status Codes

Success

Status CodeDescription
200 - OKRequest was successful.

Error

Status CodeDescription
401 - UnauthorizedUser must authenticate before making a request.