How to change IP address after OpenStack installation via devstack

Last updated on January 14, 2016 by Dan Nanni

After you have installed Openstack via devstack, what if you need to change the IP address of OpenStack's controller/compute nodes for whatever reason?

OpenStack deployment via devstack is stateless or ephemeral by design. As such, all OpenStack configuration files and databases are re-generated from scratch every time you run stack.sh. Therefore, when the IP address of any OpenStack node changes, you just need to redefine HOST_IP and SERVICE_HOST environment variables in localrc. All relevant OpenStack configuration files will then automatically be re-generated by stack.sh.

In your OpenStack development environment, if the IP address of an OpenStack node changes often, it is useful to define HOST_IP environment variable in localrc as follows, instead of defining it statically (e.g., 192.168.1.10).

HOST_IP=`ifconfig eth0 | sed -ne 's/.*inet addr:([^ ]*).*/1/p'`

One caveat: there is one more configuration file (besides localrc) that you need to manually update when the IP address of the controller node changes. stack.sh generates a user-specific MySQL configuration file in ~/.my.cnf, and includes the IP address of MySQL server there. If the MySQL configuration file already exists, stack.sh does not overwrite the file. Thus, you need to update the IP address manually, or comment out if-clause in stack.sh, as follows.

#    if [[ ! -e $HOME/.my.cnf ]]; then
         cat <$HOME/.my.cnf
[client]
user=$MYSQL_USER
password=$MYSQL_PASSWORD
host=$MYSQL_HOST
EOF
         chmod 0600 $HOME/.my.cnf
#     fi

Without this change, you may encounter a MySQL connection timeout error on OpenStack controller node while running stack.sh, because it attempts to access MySQL server at an old IP address.

Support Xmodulo

This website is made possible by minimal ads and your gracious donation via PayPal or credit card

Please note that this article is published by Xmodulo.com under a Creative Commons Attribution-ShareAlike 3.0 Unported License. If you would like to use the whole or any part of this article, you need to cite this web page at Xmodulo.com as the original source.

Xmodulo © 2021 ‒ AboutWrite for UsFeed ‒ Powered by DigitalOcean