Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?


share|improve this question
up vote 4 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.


mac=`ifconfig eth0 | grep HWaddr | sed 's/^.*HWaddr //; s/://g'`
wget -O hostname.txt$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


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.