Question on pick-first-value and valid FQDN

Jim Glassford jmglass at iup.edu
Tue Oct 16 18:59:25 UTC 2012


On 10/14/2012 11:35 PM, Glenn Satchell wrote:
> On Sat, October 13, 2012 2:09 am, Jim Glassford wrote:
>> Hi,
>>
>> Running DHCP Server 4.1.1-P1 and had a question on pick-first-value with
>> dynamic dns updates. All working great doing ddns, using the ethernet
>> address for wireless and student machines FQDN.
>>
>>
>> subnet 10.10.118.0 netmask 255.255.254.0 {
>>    option routers 10.10.118.1;
>>     pool {
>>     range 10.10.118.50 10.10.119.254;
>>     default-lease-time 3600; max-lease-time 3600;
>>     ignore client-updates;
>>     ddns-updates on;
>>     ddns-rev-domainname "in-addr.arpa.";
>>     ddns-hostname =  binary-to-ascii (16, 8, "-",substring (hardware, 1,
>> 6));
>>     ddns-domainname "vcl.iup.edu";
>>     }
>> }
>>
>>
>> Starting a VMware VDI scope and want to start creating the FQDN with the
>> host name supplied by the VM clients. Considering the following, if host
>> name supplied, use it, if not create one using the ethernet address.
>> Same as above, just changed the ddns-hostname line to:
>>
>> ddns-hostname = pick-first-value ((option host-name), (binary-to-ascii
>> (16, 8, "-",substring (hardware, 1, 6))));
>>
>>
>>
>> If invalid host name supplied, underscore, slash, etc, should I do more
>> conditional evaluation of the supplied name or would an invalid supplied
>> host name fail the evaluation, be considered a null value then move to
>> the second choice?
>>
>> thanks!
>> jim
>>
>
> pick-first-value() is not that smart. It returns the first non-null
> option. SO as long as option host-name returns *anything* then that is
> what will be returned. If you want to check for underscores or other
> patterns then you'd need to check specifically for that.
>
> Current versions can do regexp matching, so looking for an underscore is
> not too hard.
>
> Those type of operations are covered in the dhcp-eval man page.
>
> regards,
> -glenn
>
>
> _______________________________________________
> dhcp-users mailing list
> dhcp-users at lists.isc.org
> https://lists.isc.org/mailman/listinfo/dhcp-users
>


Thanks Glenn!

I am no coder, more the campus cable dog. I think I am going to end up 
with something similar to the following.


        if option host-name ~~ "[_$#]+" {
          ddns-hostname =  binary-to-ascii (16, 8, "-",substring 
(hardware, 1, 6));
         } elsif option host-name ~~ "[a-z0-9-]+" {
          ddns-hostname = (lcase (option host-name)) ;
         } else {
          ddns-hostname =  binary-to-ascii (16, 8, "-",substring 
(hardware, 1, 6));
         }


Thanks to your hint on regexp matching, I found this link below helpful 
but I had no luck on using the "exists". I am sure it was just me. :-)

<https://lists.isc.org/pipermail/dhcp-users/2011-August/013942.html>

thanks!
jim




More information about the dhcp-users mailing list