setting and changing values for ddns-hostname and host-name

Peter Rathlev peter at
Wed Mar 13 21:12:37 UTC 2013

On Wed, 2013-03-13 at 14:29 -0400, btb at wrote:
> what a i missing?  how can i change what the client sends in host-name to something else?

I don't understand. The server receives a packet that contains the
hostname. The client already sent it. You can't change what the client
alread has sent.

Is it because you want your "ddns-hostname = pick ..." (to use the new
hostname? Then just do like this:

if (not (option host-name ~~ "^[a-z0-9][a-z0-9\-]+[a-z0-9]$")) {
    set new_host-name = concat("host-", binary-to-ascii(16, 8, "", substring(hardware, 1, 6)));
    log(concat("invalid hostname: ", option host-name, " => ", new_host-name));
    ddns-hostname = new_host-name;
} else {
    ddns-hostname = pick (option fqdn.hostname, option host-name, substring (option dhcp-client-identifier, 1, 20));

We use something similar on some networks to make sure that all hosts
are registered with valid names and invalid names are flagged.

(By the way: I don't know how dhcpd handles locale, but the "[a-z]"
character class might be translated to match all kinds of characters.
Like this:

  $ echo $LANG
  $ echo "asdf" | egrep "^[a-z]+$"
  $ echo "æøå" | egrep "^[a-z]+$"
  $ export LANG=C
  $ echo "æøå" | egrep "^[a-z]+$"

I haven't tested it or looked at source, just thought I'd mention it.)


More information about the dhcp-users mailing list