How Do I Configure the Static Host Name of a BMS?

Symptom

The static host name of a Linux BMS is user-defined and injected on the console during the BMS creation. You can use the console or run the hostname command to change the host name of a BMS. However, if you restart the BMS, its host name will be automatically changed to the user-defined one injected on the console.

Manually Updating the Host Name

To make the changed host name take effect even after the BMS is stopped or restarted, save the changed name into configuration files.

For example, if the changed host name is new_hostname, perform the following steps:

  1. Modify the /etc/hostname configuration file.

    1. Run the following command to edit the /etc/hostname configuration file:

      sudo vim /etc/hostname

    2. Change the host name to new_hostname.

    3. Run the following command to save and exit the configuration file:

      :wq

  2. (Optional) For Red Hat Enterprise Linux, CentOS, and Fedora 6, modify the configuration file /etc/sysconfig/network.

    1. Run the following command to edit the /etc/sysconfig/network configuration file:

      sudo vim /etc/sysconfig/network

    2. Change the HOSTNAME value to new_hostname.

      HOSTNAME=new_hostname

    3. Run the following command to save and exit the configuration file:

      :wq

  3. Modify the /etc/cloud/cloud.cfg configuration file.

    1. Run the following command to edit the /etc/cloud/cloud.cfg configuration file:

      sudo vim /etc/cloud/cloud.cfg

    2. Use either of the following methods to modify the configuration file:

      • Method 1: Change the preserve_hostname parameter value or add the preserve_hostname parameter to the configuration file.

        If preserve_hostname: false is already available in the /etc/cloud/cloud.cfg configuration file, change it to preserve_hostname: true.

        If preserve_hostname: false is unavailable in the /etc/cloud/cloud.cfg configuration file, add preserve_hostname: true before cloud_init_modules.

      • Method 2: Delete or comment out the following content:

        update_hostname

    3. Run the following command to save and exit the configuration file:

      :wq

  4. Change the BMS network configuration script bms-network-config.conf.

    The value of parameter enable_preserve_hostname in the bms-network-config.conf file is False by default, indicating that the host name is updated each time the board resets. To disable this function, change its value to True.

    1. Change the value of enable_preserve_hostname in the bms-network-config.conf file to True:

      sed -i 's/enable_preserve_hostname.*/enable_preserve_hostname = True/g' `find / -name bms-network-config.conf

  5. (Optional) For SUSE, modify the configuration file /etc/sysconfig/network/dhcp.

    1. Run the following command to edit the /etc/sysconfig/network/dhcp configuration file:

      sudo vim /etc/sysconfig/network/dhcp

    2. Set the value of DHCLIENT_SET_HOSTNAME to no to ensure that DHCP does not automatically allocate host names.

      DHCLIENT_SET_HOSTNAME="no"

    3. Run the following command to save and exit the configuration file:

      :wq

  6. Run the following command to restart the BMS:

    sudo reboot

  7. Run the following command to check whether the static host name is changed:

    sudo hostname

    If the changed host name new_hostname is displayed in the command output, the host name is changed and the new name permanently takes effect.