Ask Your Question

How to change the IP of a vm?

asked 2015-05-25 22:09:46 -0600

nethawk gravatar image

I created a vm, its IP is Now I want to change its IP to I used the command ifconfig on the vm,but afetr that I can not ping the new ip. How can I change the IP of opensatck vm?

edit retag flag offensive close merge delete


I will do it by editing network config and with static IP. If you are using DHCP then it will be tough.

SGPJ gravatar imageSGPJ ( 2015-05-26 02:12:37 -0600 )edit

I used DHCP.

nethawk gravatar imagenethawk ( 2015-05-26 02:53:53 -0600 )edit

2 answers

Sort by » oldest newest most voted

answered 2015-05-26 19:27:45 -0600

jdexter gravatar image

updated 2015-05-27 07:18:03 -0600

The only why to do this would be to create a new port, associated with the new IP you want. Then delete the port from your vm, and then attach the new port. This will cause the new NIC to increment by one in the OS as it will have a different MAC and the udev rules will make it increment.

The other option is to take note of the MAC address then remove the port and create and add it back.

To remove a nic from the VM.

$ nova interface-detach <server> <port-id>
$ neutron port-delete <port-id>

Create the port

$ neutron port-create [--mac-address MAC_ADDRESS] [--fixed-ip subnet_id=SUBNET,ip_address=IP_ADDR]

Attach the port

$ nova interface-attach --port-id <port_UUID>  <server>
edit flag offensive delete link more


How to delete a port from VM and how to attach the new port to VM?

nethawk gravatar imagenethawk ( 2015-05-27 01:24:07 -0600 )edit

answered 2015-06-07 21:11:13 -0600

nethawk gravatar image

After I completed the operations above,I can not ping the new ip from another vm in the same subnet. That's why? I did it like this:

neutron port-create --mac-address FA:16:3E:1F:E5:A1 --fixed-ip subnet_id=eb220a65-14ab-402d-b4d7-a4165cdb7816,ip_address= a75c49f4-5850-4e30-8c27-590a594b3e46

nova interface-attach --port-id 6ae52693-899d-4d27-a61b-27d56b322295 0731cdc5-4a31-4196-b2a1-6e7d058abbfe

I could not see the new IP on vm using ifconfig.

edit flag offensive delete link more


i believe you need to set the ip first onto the instance. or probably reboot will do as it will load metadata detail including the new ip.

senyapsudah gravatar imagesenyapsudah ( 2015-06-08 08:24:19 -0600 )edit

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower


Asked: 2015-05-25 22:09:46 -0600

Seen: 9,479 times

Last updated: Jun 07 '15