A port in Neutron is a logical connection of a virtual network interface to a subnet. Ports can be associated with virtual machine instances, DHCP servers, routers, firewalls, load balancers, and more. Ports can even be created simply to reserve IP addresses from a subnet. Neutron stores port relationships in the Neutron database and uses this information to build switching connections at the physical or virtual switch layer through the networking plugin and agent.
To retrieve a list of all Neutron ports, use the Neutron port-list
command, as shown in the following screenshot:
Use the Neutron port-show
command to see the details of a particular port:
The port pictured in Figure 5.27 is owned by an interface used within a DHCP namespace. The network_id
field reveals the network to be 3282acdf-85d1-47ea-b734-f5625cfca027
, otherwise known as the MyFlatNetwork
network, which was created earlier in this chapter.
Use the ip netns exec
command to execute ip addr
within the DHCP namespace to list its interfaces and their details:
In the DHCP namespace, the interface's MAC address corresponds to the port's mac_address
field, while the name of the interface corresponds to the first 10 characters of the Neutron port UUID:
By creating a Neutron port manually, users have the ability to specify a particular fixed IP address, MAC address, security group, and more.
To create a port, use the Neutron port-create
command, as follows:
usage: neutron port-create [--tenant-id TENANT_ID] [--name NAME] [--fixed-ip subnet_id=SUBNET,ip_address=IP_ADDR] [--device-id DEVICE_ID] [--device-owner DEVICE_OWNER] [--admin-state-down] [--mac-address MAC_ADDRESS] [--security-group SECURITY_GROUP | --no-security-groups] [--extra-dhcp-opt EXTRA_DHCP_OPTS] NETWORK
Once created, the port can then be associated with a virtual machine instance or other virtual network device or can simply be used to reserve an IP address in a subnet.