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

Create Network Port

Create a network port on a specified network.

Default policy settings allow you to create ports only on networks that belong to your project (unless you have administrative privileges).

Request

POST /v2.0/ports

Body Structure

Top-level JSON object must contain a single port object with the attributes below.

Parameters

NameInTypeDescription
portbodyobjectA port object (container for all below attributes).
admin_state_up (Optional)bodybooleanAdministrative state of the port: up (true) or down (false). Default: true.
allowed_address_pairs (Optional)bodyarrayZero or more objects each with ip_address (required) and optional mac_address. ip_address may be a single IP or CIDR. If mac_address omitted it defaults to the port MAC. Enables a server to send packets with those source addresses.
binding:host_id (Optional)bodystringID of the host where the port should reside.
binding:profile (Optional)bodyobjectOpaque dict for backend-specific VIF information. Use device_mac_address when binding a direct-physical port to override MAC. Empty object {} by default.
binding:vnic_type (Optional)bodystringDesired vNIC type. One of: normal, macvtap, direct, baremetal, direct-physical, virtio-forwarder, smart-nic, remote-managed. Default: normal.
device_id (Optional)bodystringID of the device (e.g. server instance or router) that will use this port.
device_owner (Optional)bodystringEntity type using the port (e.g. compute:nova, network:dhcp, network:router_interface).
dns_domain (Optional)bodystringValid DNS domain to associate.
dns_name (Optional)bodystringValid DNS name (hostname) to associate.
extra_dhcp_opts (Optional)bodyarrayZero or more DHCP option objects (opt_name, opt_value).
fixed_ips (Optional)bodyarrayAssign specific IPs. Each entry may include subnet_id and/or ip_address. Logic: supply both to request a precise address; only subnet_id to auto-allocate from that subnet; only ip_address to allocate if valid on any subnet of the network.
hints (Optional)bodyobjectAdmin-only. Mechanism-driver keyed dict (e.g. {"openvswitch": {"other_config": {"tx-steering": "hash"}}}). Max length 4095 chars serialized.
mac_address (Optional)bodystringPort MAC address. Auto-generated if omitted.
name (Optional)bodystringHuman-readable name of the port.
network_idbodystringID of the network to attach the port to. (Required)
numa_affinity_policy (Optional)bodystringNUMA affinity policy: none, required, preferred, or legacy.
port_security_enabled (Optional)bodybooleanEnable (true) or disable (false) security group & anti-spoofing enforcement. Defaults to network setting.
project_id (Optional)bodystringProject ID that will own the port (admin / advsvc only if different from own).
qos_policy_id (Optional)bodystringQoS policy ID to apply.
security_groups (Optional)bodyarrayList of security group IDs. If omitted defaults to the network's configured default security groups (or none).
tenant_id (Optional)bodystringDeprecated alias of project_id.
propagate_uplink_status (Optional)bodybooleanWhether uplink status is propagated (true/false).
description (Optional)bodystringHuman-readable description. Default: empty string.
mac_learning_enabled (Optional)bodybooleanEnable MAC learning on the port.
port_trusted_vif (Optional)bodybooleanTrusted VIF status (true/false). Reflected inside binding:profile.

Example Request

curl -ks -H 'Content-Type: application/json' \
-H 'X-Auth-Token: gAAAAA<...>' \
-d '{
"port": {
"name": "private-port",
"network_id": "f858b8d1-e66b-4a48-bc2e-3f16483b1b58",
"fixed_ips": [
{
"subnet_id": "adffaac8-2261-43f7-9e4f-6044230f65f1",
"ip_address": "192.168.1.12"
}
]
}
}' \
https://<node_IP_addr>:9696/v2.0/ports

Response

Response Parameters

If successful the API returns a single port object containing the created resource.

NameInTypeDescription
portbodyobjectPort object.
admin_state_upbodybooleanAdministrative state (true or false).
allowed_address_pairsbodyarrayAllowed address pairs (see request).
binding:host_idbodystringID of host where the port resides.
binding:profilebodyobjectBackend-specific VIF info (empty {} if none).
binding:vif_detailsbodyobjectAdditional details (e.g. port_filter, ovs_hybrid_plug).
binding:vif_typebodystringMechanism driver type (ovs, bridge, macvtap, etc.) or unbound / binding_failed.
binding:vnic_typebodystringvNIC type requested / in effect.
created_atbodystringCreation timestamp (ISO 8601).
data_plane_statusbodystringUnderlying data plane status (deployment-specific).
device_idbodystringID of the attached device (empty if none yet).
device_ownerbodystringOwner entity type.
dns_assignmentbodyobjectInternal DNS assignment (hostname, ip_address, fqdn).
dns_domainbodystringDNS domain.
dns_namebodystringDNS name.
extra_dhcp_optsbodyarrayExtra DHCP options applied.
fixed_ipsbodyarrayAssigned IP addresses (list of {subnet_id, ip_address}).
hintsbodyobjectOVS Userspace Tx packet steering hints if provided.
idbodystringPort ID.
ip_allocationbodystringAllocation mode (immediate, deferred, or none).
mac_addressbodystringMAC address (may be overridden by binding for direct-physical).
namebodystringPort name.
network_idbodystringNetwork ID.
numa_affinity_policy (Optional)bodystringNUMA affinity policy.
port_security_enabledbodybooleanWhether port security is enabled.
project_idbodystringOwning project ID.
qos_network_policy_idbodystringQoS policy of the network (if any).
qos_policy_idbodystringQoS policy applied directly to the port (if any).
revision_numberbodyintegerRevision number.
resource_request (Optional)bodyobjectPlacement resource groups / traits requested.
security_groupsbodyarraySecurity group IDs on the port.
statusbodystringPort status: ACTIVE, DOWN, BUILD, or ERROR.
tenant_idbodystringProject ID (legacy field).
updated_atbodystringLast update timestamp (ISO 8601) or null.
propagate_uplink_statusbodybooleanUplink status propagation flag.
descriptionbodystringDescription.
mac_learning_enabled (Optional)bodybooleanWhether MAC learning is enabled.
port_trusted_vifbodybooleanTrusted VIF status.
tagsbodyarrayTag list.

Status Codes

Success

CodeReason
201 - CreatedResource was created and is ready to use.

Error

CodeReason
400 - Bad RequestSome content in the request was invalid.
401 - UnauthorizedUser must authenticate before making a request.
403 - ForbiddenPolicy does not allow current user to do this operation.
404 - Not FoundThe requested resource (e.g. network) could not be found.

Example Response

{
"port": {
"id": "2d74fa0c-3e43-4fd9-a234-cbb4996cc684",
"name": "private-port",
"network_id": "f858b8d1-e66b-4a48-bc2e-3f16483b1b58",
"tenant_id": "f33507157a634f1cac71e06a70fb558e",
"mac_address": "fa:16:3e:7f:ae:b2",
"admin_state_up": true,
"status": "DOWN",
"device_id": "",
"device_owner": "",
"fixed_ips": [
{
"subnet_id": "adffaac8-2261-43f7-9e4f-6044230f65f1",
"ip_address": "192.168.1.12"
}
],
"project_id": "f33507157a634f1cac71e06a70fb558e",
"port_security_enabled": true,
"qos_policy_id": null,
"security_groups": [
"e1c1aa83-7302-4493-9cf4-43c2407e8074"
],
"binding:vnic_type": "normal",
"allowed_address_pairs": [],
"extra_dhcp_opts": [],
"description": "",
"qos_network_policy_id": "dfc42ced-02c8-4b1f-bbe6-14cc014f259d",
"tags": [],
"created_at": "2025-10-08T08:05:12Z",
"updated_at": "2025-10-08T08:05:12Z",
"revision_number": 1
}
}

See Also