创建 subnet neutron subnet-create public PUBLIC_NETWORK_CIDR --name public --allocation-pool start=START_IP_ADDRESS,end=END_IP_ADDRESS --dns-nameserver DNS_RESOLVER --gateway PUBLIC_NETWORK_GATEWAY
先查找tenant
[[email protected] ~]# openstack project list
+----------------------------------+---------+
| ID | Name |
+----------------------------------+---------+
| 3013fa8f600145108b836228236cb8f3 | demo |
| 4a930be69d0540d38d5529449d93f1d0 | service |
| a7d90c2bbe1b49a18a04482447a52aa9 | admin |
为demo tenant 创建 port 如果在 admin tenant 在 demo tenant 下是无法看到的
source admin-openrc.sh
[[email protected] ~]# neutron port-create --tenant-id 3013fa8f600145108b836228236cb8f3 --fixed-ip subnet_id=27539347-f509-4368-9ec1-36dcb07942da,ip_address=172.16.0.123 flat
显示 port 列表
[[email protected] ~]# neutron port-list
+--------------------------------------+------+-------------------+---------------------------------------------------------------------------------------+
| id | name | mac_address | fixed_ips |
+--------------------------------------+------+-------------------+---------------------------------------------------------------------------------------+
| 26130380-b1e9-491f-8232-65946c90a3b9 | | fa:16:3e:ee:55:ac | {"subnet_id": "d0440b1c-84ac-438a-be93-8e70f6416b3c", "ip_address": "192.168.26.122"} |
| 5e92c6fb-e869-4596-819b-d827b9264ce6 | | fa:16:3e:7d:c2:9c | {"subnet_id": "27539347-f509-4368-9ec1-36dcb07942da", "ip_address": "172.16.0.122"} |
| bbee04e8-9e21-4651-9c37-ea2372198f8b | | fa:16:3e:e7:7f:5e | {"subnet_id": "27539347-f509-4368-9ec1-36dcb07942da", "ip_address": "172.16.0.123"} |
| c22ca00f-48d5-494c-a602-f230443abc87 | | fa:16:3e:92:3d:1e | {"subnet_id": "d0440b1c-84ac-438a-be93-8e70f6416b3c", "ip_address": "192.168.26.123"} |
attach port 到虚拟机
nova interface-attach --port-id bbee04e8-9e21-4651-9c37-ea2372198f8b server-name