Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

up vote 3 down vote accepted

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.

share|improve this answer

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.

share|improve this answer
    
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 '09 at 12:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.