CloudStack OS

DHCP Hostname Updates for CloudStack Templates

The Working with Templates section from the CloudStack Administrators Guide describes in broad strokes how to create OS templates. In addition to the steps mentioned there, you might need an extra step to update the hostname settings during DHCP depending on the Linux distribution.

For Ubuntu 12.04 LTS templates, remove the file /etc/hostname before creating the template. On Debian 6/7 systems, create a new DHCP “exit hook” file /etc/dhcp/dhclient-exit-hooks.d/hostname as below:

# Update hostname from DHCP
if [ "$reason" != BOUND ] && [ "$reason" != RENEW ] && [ "$reason" != REBIND ] && [ "$reason" != REBOOT ]; then

hostname $new_host_name
echo $new_host_name > /etc/hostname

No extra steps were needed for FreeBSD, CentOS 6 and SuSE Enterprise Linux templates.

By Shanker Balan

Shanker Balan is a devops and infrastructure freelancer with over 14 years of industry experience in large scale Internet systems. He is available for both short term and long term projects on contract.

Please use the Contact Form for any enquiry.

Leave a Reply

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