This is a very simple and quick way, to set unique linux hostname, when getting address from DHCP.It's based on the dhclient-exit-hooks, so all you need to do is to create a bash script in /etc/dhcp/dhclient-exit-hooks.d
In this case, hostname is a combination from a static word and last octet of the assigned IP address. If you are getting address 10.0.0.10 hostname will look like this: server-10
/etc/dhcp/dhclient-exit-hooks.d/hostname
#!/bin/bash
if [ "$reason" != BOUND ] && [ "$reason" != RENEW ] \
&& [ "$reason" != REBIND ] && [ "$reason" != REBOOT ]
then
return
fi
echo dhclient-exit-hooks.d/hostname: Dynamic IP address = $new_ip_address
hostname=server-$(echo $new_ip_address | cut -d '.' -f 4)
echo $hostname > /etc/hostname
hostname $hostnamey
echo dhclient-exit-hooks.d/hostname: Dynamic Hostname = $hostname
You can easyly put your own script, to change the hostname for random values, or something that will fit your needs. In this case I have a dedicated subnet range, for new machines with this hook.