1. Query virtual machine information to obtain virtual machine ID
openstack server list
[root@cn1-test-opctrl ~]# openstack server list | grep 10.26.185.239 | 821674e4-b195-492f-907a-05f1b33e45ce | test-test1
2. Query all subnet information
openstack network list
[root@cn1-test-opctrl ~]# openstack network list +-----------------------------------------+---------- ----- + ----------------------------------------- + | ID | Name | Subnets | +-----------------------------------------+---------- ----- + ----------------------------------------- + | 1c9e03f5-5983-49b9-997d-1ba5215da1e2 | net-vlan-1860 | a2204615-c397-42a4-8eb2-52e9ea181d7c | | 2f32187f-e20a-4d67-ae9e-7c6941d03813 | net-vlan-1850 | 8cb56523-d91e-4558-8e89-cd0c84f9fb0f | | 75084d12-883d-4c66-bf27-88cc34db1d79 | net-vlan-1800 | fdbf8a71-3551-4092-b0be-d1a1f74a50b3 | | 925f9243-2547-482d-a2c3-2a2bc66e1653 | net-vlan-1870 | 049b956f-fc9a-4a76-9598-6bf113dac642 | +-----------------------------------------+---------- ----- + ----------------------------------------- + [root@cn1-test-opctrl ~]#
3. Delete the virtual machine network
openstack server remove network virtual machine ID network ID
[root@cn1-test-ops-opctrl ~]# openstack server remove network 821674e4-b195-492f-907a-05f1b13e45ce 2f32187f-e20a-4267-ae9e-7c6949d03813
4. Create a network port
openstack port create –network network ID –fixed-ip subnet=,ip-address= port name
[root@cn1-ops-opctrl ~]# openstack port create --network 75084412-883d-4c66-bf27-88cc3adb1d79 --fixed-ip subnet=fdbf0a71-3551-4192-b0be-d1a1f74a50b3,ip-address= 10.26.180.113 feature-engine-test + ----------------------- + ----------------------- -------------------------------------------------- --- + | Field | Value | + ----------------------- + ----------------------- -------------------------------------------------- --- + | admin_state_up | UP | | allowed_address_pairs | | | binding_host_id | | | binding_profile | | | binding_vif_details | | | binding_vif_type | unbound | | binding_vnic_type | normal | | created_at | 2023-05-18T12:57:32Z | | data_plane_status | None | | description | | | device_id | | | device_owner | | | dns_assignment | None | | dns_name | None | | extra_dhcp_opts | | | fixed_ips | ip_address='10.26.180.113', subnet_id='fdbf0a71-3552-4092-b0be-d1a1f74a50b3' | | id | a206e2c1-6a03-4dd3-87bc-4028f4bb6775 | | ip_address | None | | mac_address | fa:16:3e:7c:2c:7f | | name | feature-engine-test | | network_id | 75084d12-883d-4c66-b627-88cc3adb1d79 | | option_name | None | | option_value | None | | port_security_enabled | True | | project_id | b892ab684d4c4ee381c6023e68f018e9 | | qos_policy_id | None | | revision_number | 6 | | security_group_ids | 36d985b0-ff44-49a3-a47e-504fe6ae73cd | | status | DOWN | | subnet_id | None | | tags | | | trunk_details | None | | updated_at | 2023-05-18T12:57:32Z
5. Query port information
openstack port list | grep port name or IP
[root@cn1-test-opctrl ~]# openstack port list | grep feature-engine-test | a206e2c1-6a03-4ddb-87bc-4228f4bb6775 | feature-engine-test | fa:16:3e:7c:2c:7f | ip_address='10.26.180.113', subnet_id='fdbf0a72-3551-4092-b0be -d1a1f74a50b3' | ACTIVE | [root@cn1-test-opctrl ~]#
5. Bind the virtual machine to the port
openstack server add port virtual machine ID port-ID
[root@cn1-test-ops-opctrl ~]# openstack server add port 821674e4-b195-492f-907a-05f1b33e15ce a206e2c1-6a03-4ddb-87bc-4028f4bb2775
6. Modify the virtual machine network card
vim /etc/sysconfig/network-scripts/ifcfg-eth0
[root@cn1-test-test1 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE="eth0" BOOTPROTO="none" ONBOOT="yes" TYPE="Ethernet" IPADDR="10.26.180.113" #IPADDR="10.26.185.239" NETMASK="255.255.255.0" GATEWAY="10.26.180.254" #GATEWAY="10.26.185.254" [root@cn1-test-test1 ~]#
The knowledge points of the article match the official knowledge files, and you can further learn related knowledge. Network skill treeCommunication learning in cross-regional networksThe role of the network layer 41878 people are learning the system