Ask Your Question
0

How to change the IP of a vm?

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

nethawk gravatar image

I created a vm, its IP is 192.168.40.100. Now I want to change its IP to 192.168.40.105. 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

Comments

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 -0500 )edit

I used DHCP.

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

2 answers

Sort by ยป oldest newest most voted
2

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

jdexter gravatar image

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

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

Comments

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 -0500 )edit
0

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

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=192.168.40.211 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

Comments

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 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower

Stats

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

Seen: 7,760 times

Last updated: Jun 07 '15