首页 > 代码库 > openstack虚拟机修改IP地址
openstack虚拟机修改IP地址
1)、查找虚拟机的网络端口
mysql> use neutron;
mysql> select * from ports where device_id="3ab73261-82ce-4b9a-9a1c-519624e19dc2";
+----------------------------------+--------------------------------------+------+--------------------------------------+-------------------+----------------+--------+--------------------------------------+--------------+
| tenant_id | id | name | network_id | mac_address | admin_state_up | status | device_id | device_owner |
+----------------------------------+--------------------------------------+------+--------------------------------------+-------------------+----------------+--------+--------------------------------------+--------------+
| 5855410282d54e0cac49f05b40282500 | eccd3444-bb81-4d3b-ae13-58040847da4a | | ed547aa7-af32-495a-8173-5a04be9c37c1 | fa:16:3e:a8:bd:e4 | 1 | DOWN | 3ab73261-82ce-4b9a-9a1c-519624e19dc2 | compute:nova |
+----------------------------------+--------------------------------------+------+--------------------------------------+-------------------+----------------+--------+--------------------------------------+--------------+
1 row in set (0.01 sec)
mysql>
2)、查找虚拟机网络端口的IP地址
mysql> select * from ipallocations where port_id="eccd3444-bb81-4d3b-ae13-58040847da4a";
+--------------------------------------+--------------+--------------------------------------+--------------------------------------+
| port_id | ip_address | subnet_id | network_id |
+--------------------------------------+--------------+--------------------------------------+--------------------------------------+
| eccd3444-bb81-4d3b-ae13-58040847da4a | 10.40.211.28 | e6e73775-ddbc-461a-92ff-b13202c23540 | ed547aa7-af32-495a-8173-5a04be9c37c1 |
+--------------------------------------+--------------+--------------------------------------+--------------------------------------+
1 row in set (0.00 sec)
3)、修改虚拟机的端口的IP地址
mysql> update ipallocations set ip_address="10.40.211.29" where port_id="eccd3444-bb81-4d3b-ae13-58040847da4a";
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select * from ipallocations where port_id="eccd3444-bb81-4d3b-ae13-58040847da4a";
+--------------------------------------+--------------+--------------------------------------+--------------------------------------+
| port_id | ip_address | subnet_id | network_id |
+--------------------------------------+--------------+--------------------------------------+--------------------------------------+
| eccd3444-bb81-4d3b-ae13-58040847da4a | 10.40.211.29 | e6e73775-ddbc-461a-92ff-b13202c23540 | ed547aa7-af32-495a-8173-5a04be9c37c1 |
+--------------------------------------+--------------+--------------------------------------+--------------------------------------+
1 row in set (0.01 sec)
本文出自 “zhanguo1110” 博客,请务必保留此出处http://zhanguo1110.blog.51cto.com/5750817/1543155