4

I just installed a pxe server, and i'm installing debian with pxe . completely unattended with preseeding.

Now, all my installations come with the same hostname, how I can change the hostname to something different?

Thanks.

2 Answers 2

5

One simple way that comes to mind without setting up things in DHCP.

Assuming there is a web site you can add files to. Place the hostname inside a file based on the Mac. Then retrieve it with wget.

e.g.:

mac=`ifconfig eth0 | grep HWaddr | sed 's/^.*HWaddr //; s/://g'`
wget -O hostname.txt http://www.example.com/$mac
hostname `cat hostname.txt`

The mac file name would be in lower case with no colon (:) characters.

1

Yeah, setting the hostname on preseeded installs is a bit of a pest, because even when you preseed the hostname on the kernel command line, the DNS reverse lookup during DHCP configuration overwrites it and you're stuck with it.

The way I handle it is by building a custom initrd with a local udeb I whipped up, that provides a question you can preseed to the FQDN of the machine.

Alternately, after the install's done just change /etc/hostname and /etc/hosts to the name of the new host and reboot. That's all that's required to effect a name change on a minimal install.

1
  • I do not understant the way you do it, but looks very interesting, can you explain it a little further? And on the second sugestion you just gave me, i understant that i should launch a script at the end of preseed to change the hostname. For example the script goes to a public html where can relate its mac address with a name and set the name on hostname and hosts. Very easy, i like it. Thanks
    – Marc Riera
    Nov 3, 2009 at 12:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .