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

btb at btb at
Thu Mar 14 03:26:59 UTC 2013

On Mar 13, 2013, at 17.12, Peter Rathlev <peter at> wrote:

> 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.

sorry, i think semantics might have gotten in the way here a bit.

> Is it because you want your "ddns-hostname = pick ..." (to use the new
> hostname?

right, more or less.  i don't want to change what the client sends [as you state, that's obviously a silly notion] - but rather if what the client sends isn't valid, i want to generate an alternate value "in it's place", so to speak.

> 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));
> }

in this example, if a client sends both fqdn.hostname and host-name, but host-name is not "valid", then won't new_host-name take precedence over fqdn.hostname?

my goal is to only use host-name [or new_host-name if host-name isn't valid] if the client has not sent fqdn.hostname, and to only use dhcp-client-identifier is the client has sent neither fqdn.hostname nor host-name.

sort of on that note, i wanted to go back and read again what "pick" does, but i had trouble finding reference to it in the documentation.  i looked in dhcpd(8), dhcpd.conf(5), dhcp-options(5), and dhcp-eval(5).  i did find pick-first-name in dhcp-eval(5) and wondered if pick were simply shorthand for that, but couldn't find a confirmation of this.

> 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
>  en_US.UTF-8
>  $ echo "asdf" | egrep "^[a-z]+$"
>  asdf
>  $ 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.)

thanks, i hadn't considered this.  i'll keep an eye on it.


More information about the dhcp-users mailing list