Debian – How to change the hostname at the end of pxe unattended installation on Debian

debianhostnamepxe-bootunattended

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.

Best Answer

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.