openstack指定IP

晨光陈色發表於2024-06-13
 1 先建立 port,設定好 IP 地址。
 2 將該 port attach 到 instance。
 3 在 instance 中手工配置靜態 IP,如果設定dhcp。預設重啟reboot就好。
 4 
 5 
 6 
 7 [root@s16071-z2-controller01 ~]# source admin-openrc
 8 
 9 
10 
11 
12 [root@s16071-z2-controller01 ~]# nova list
13 +--------------------------------------+------------------------------+--------+------------+-------------+---------------------+
14 | ID | Name | Status | Task State | Power State | Networks |
15 +--------------------------------------+------------------------------+--------+------------+-------------+---------------------+
16 | 47289968-7943-487f-a910-59e1d1576a7f |mysql-01 | ACTIVE | - | Running | |
17 +--------------------------------------+------------------------------+--------+------------+-------------+---------------------+
  找到對應的Name ,此次用的是mysql-01 18 19 [root@s16071-z2-controller01 ~]# neutron subnet-list 20 neutron CLI is deprecated and will be removed in the future. Use openstack CLI instead. 21 +--------------------------------------+----------------+----------------------------------+--------------+-----------------------------------------------+ 22 | id | name | tenant_id | cidr | allocation_pools | 23 +--------------------------------------+----------------+----------------------------------+--------------+-----------------------------------------------+ 24 | 07518a92-ccd2-416b-a9be-1d85f386eab7 | vlan406-subnet | 2cc9c8a5b161407f9e7545998ef9dee8 | 10.96.6.0/24 | {"start": "10.96.6.10", "end": "10.96.6.200"} | 25 +--------------------------------------+----------------+----------------------------------+--------------+-----------------------------------------------+
   找到對應的ID 07518a92-ccd2-416b-a9be-1d85f386eab7 26 27 28 29 30 繫結subnet_id,指定IP,和vlan 31 [root@s16071-z2-controller01 ~]# neutron port-create --fixed-ip subnet_id=07518a92-ccd2-416b-a9be-1d85f386eab7,ip_address=10.96.6.27 vlan406

32 檢視port ID 72798877-8d7d-46fb-8560-df272cccddd67 33 [root@s16071-z2-controller01 ~]# neutron port-list 34 neutron CLI is deprecated and will be removed in the future. Use openstack CLI instead. 35 +--------------------------------------+------+----------------------------------+-------------------+------------------------------------------------------------------------------------+ 36 | id | name | tenant_id | mac_address | fixed_ips | 37 +--------------------------------------+------+----------------------------------+-------------------+------------------------------------------------------------------------------------+ 38 | 72798877-8d7d-46fb-8560-df272cccdd67 | | 2cc9c8a5b161407f9e7545998ef9dee8 | fa:16:3e:48:b2:75 | {"subnet_id": "07518a92-ccd2-416b-a9be-1d85f386eab7", "ip_address": "10.96.6.27"} | 39 +--------------------------------------+------+----------------------------------+-------------------+------------------------------------------------------------------------------------+ 40

  繫結port-id到例項Name 41 [root@s16071-z2-controller01 ~]# nova interface-attach --port-id 72798877-8d7d-46fb-8560-df272cccdd67 mysql-01 42 [root@s16071-z2-controller01 ~]# nova list 43 +--------------------------------------+------------------------------+--------+------------+-------------+---------------------+ 44 | ID | Name | Status | Task State | Power State | Networks | 45 +--------------------------------------+------------------------------+--------+------------+-------------+---------------------+ 46 | 47289968-7943-487f-a910-59e1d1576a7f | mysql-01 | ACTIVE | - | Running | vlan406=10.96.6.27 | 47 +--------------------------------------+------------------------------+--------+------------+-------------+---------------------+

繫結成功後,重啟例項mysql-01,配置完成

相關文章