• Bare Metal Server

bms
  1. Help Center
  2. Bare Metal Server
  3. User Guide
  4. FAQs
  5. OS FAQs
  6. How Can I Configure the Static Host Name of a BMS?

How Can 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.

Automatically Updating the Host Name (Recommended)

Change the host name of the BMS on the console and enable automatic host name synchronization in the BMS OS. In this way, after the BMS is restarted, it automatically synchronizes the host name from the console.

This method has the following restrictions:

  • The host name contains a maximum of 63 characters.
  • Special characters except hyphens (-) and underscores (_) are not supported.
  • Uppercase letters are not supported.
  • This method does not apply to Windows BMSs.
  1. Log in to the management console, click Bare Metal Server under Computing.
  2. Click the name of the BMS whose host name is to be changed.
  3. On the displayed page, click next to Name, enter a new host name that meets the preceding requirements, and click to save the change.
  4. Log in to the BMS OS and run the following command to enable automatic host name synchronization:

    vi /opt/huawei/network_config/bms-network-config.conf

    Set the value of auto_synchronize_hostname to True.

    auto_synchronize_hostname = True

    Press Esc and enter :wq to save and exit the file.

  5. Log in to the management console again, locate the row that contains the BMS, click More in the Operation column, and select Restart.

    After about 10 minutes, verify that the BMS is restarted and its host name is automatically updated.

    NOTE:

    If you set the value of auto_synchronize_hostname in step 4 to False, the host name configured during BMS creation will be retained.

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. Run the following command to edit the configuration script bms-network-config.conf:

      sudo vim /opt/huawei/network_config/bms-network-config.conf

    2. Set the value of enable_preserve_hostname to True.

      enable_preserve_hostname: True

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

      :wq

  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.