How to set the hostname according to the DNS name on Ubuntu 9.10?
- by tangens
Motivation
I have to manage a lot of virtual machines that I create by copying a template (VmWare image).
Problem
Now I have the problem that in the template the file /etc/hostname contains a given name that I want to change for each copy of the template.
Facts
The network interface is configured by DHCP. DNS entries exist. The system is a Ubuntu 9.10 server.
Question
I wonder if I can configure the template so that on startup it sets its hostname according to its DNS name.
I could create an init script that parses the IP address, makes a DNS lookup and sets the hostname accordingly.
But is there an easier way?