Specify Node Hostname

This is an optional step, which details how to specify the node hostname


DescriptionCommand
1

Update the /etc/hosts file

    • Replace the default hostname with your desired hostname
      • The default hostname typically follows "127.0.1.1", DO NOT REPLACE "localhost"
      • See example in bold
      • You may need to disable "manage_etc_hosts" like in the example
    • Save and exit with CTRL+x, then type y and hit enter.


NOTE: In the example I use "node01" as my hostname. I'm using the same hostname as my example FQDN:

node01.zentest.win

sudo nano /etc/hosts


Example Output

# Your system has configured 'manage_etc_hosts' as True.
# As a result, if you wish for changes to this file to persist
# then you will need to either
# a.) make changes to the master file in /etc/cloud/templates/hosts.tmpl
# b.) change or remove the value of 'manage_etc_hosts' in
#......./etc/cloud/cloud.cfg or cloud-config from user-data

127.0.1.1 node01
127.0.0.1 localhost

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

2

Update the /etc/hostname file

  • Replace the existing hostname with your desired hostname
sudo nano /etc/hostname


Example Output

node01

3Use systemd services to set the hostname, replacing <HOSTNAME> with your desired hostname
sudo hostnamectl set-hostname <HOSTNAME>


Example Output

zenops@vps421337:~$ sudo hostnamectl set-hostname node01

4

Reboot the node and log back in as your non-root user to test that the host name has changed

  • You will see the new hostname at your terminal prompt
sudo reboot


Example Output

zenops@node01:~$



© 2020 Horizen. All rights reserved.