How to set the hostname according to the DNS name on Ubuntu 9.10?

Posted by tangens on Super User See other posts from Super User or by tangens
Published on 2010-04-09T17:48:10Z Indexed on 2010/04/09 17:53 UTC
Read the original article Hit count: 405

Filed under:
|
|
|
|

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?

© Super User or respective owner

Related posts about ubuntu-9.10

Related posts about ubuntu