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

btb at bitrate.net btb at bitrate.net
Wed Mar 13 18:29:26 UTC 2013


hi-

i'm trying to adjust my configuration so that if the value a client sends in host-name is not a valid dns, the value is ignored and an alternative is generated based on mac address, and then subsequently setting the value of ddns-hostname to one of three things, in a preferred order.  the setting of ddns-hostname seems to be working as desired, but i'm having trouble changing the value of host-name.

# if the host-name value provided by the client is not a valid dns hostname, ignore it
# and generate a valid value based on the client's mac address
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));
    host-name = new_host-name;
}

# set the hostname to be used in dns
# prefer, in order:
# 1. fqdn.hostname value
# 2. host-name value
# 3. substring of dhcp-client-identifier
ddns-hostname = pick (option fqdn.hostname, option host-name, substring (option dhcp-client-identifier, 1, 20));

my problem seems to be in understanding what belongs in the last line of the if { .. } statement.  i've tried host-name = new_host-name;, which doesn't seem to work, and client-hostname, which returns:

>dhcpd -t
Internet Systems Consortium DHCP Server 4.2.4
Copyright 2004-2012 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
/etc/dhcp/dhcpd.conf line 47: right brace expected.
	client-hostname 
         ^
/etc/dhcp/dhcpd.conf line 47: expecting a declaration
	client-hostname = new_host-name;
                                        ^
Configuration file errors encountered -- exiting

what a i missing?  how can i change what the client sends in host-name to something else?

thanks
-ben


More information about the dhcp-users mailing list