06 Feb

Persist Azure Linux virtual machine’s hostname

Persist Azure Linux virtual machine’s hostname

To persist Azure Linux virtual machine’s hostname permanently for an Azure Linux Virtual Machine, you need to ensure that, you have an Azure Linux agent installed in this machine. To install WA Linux Agent in your virtual machine, please refer the link http://blog.admindiary.com/install-microsoft-azure-linux-agent-waagent/

Once the WA Linux Agent or WAAGENT is installed in your machine, you may need to modify the WAAGENT configuration to monitor hostname changes and update the network. To save or persist your hostname permanently, edit the file /etc/waagent.conf and modify the below line,

Provisioning.MonitorHostName=y

Once done, please proceed to restart the WAAGENT service.

For Ubuntu,please execute the below command,

For CoreOS, please execute the command,

If the above steps does not work, you may need to try to install the service by executing the below command,

Now you can change the hostname and it will be updated, both locally and and also at the Azure Portal.

You can execute the below command to change your machine’s hostname.

The command to change the hostname is mentioned in the doc – https://docs.microsoft.com/en-us/azure/virtual-machines/virtual-machines-linux-intro-on-azure?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json#hostnamechanges

Even after executing the above steps, if the hostname change is not persisting, you may need to edit the file /var/lib/waagent/ovf-env.xml and update the hostname.

Then look for the below line and change your hostname.

Sample File is pasted below ,

 

Leave a Reply

Your email address will not be published. Required fields are marked *

7 + 5 =