[prev in list] [next in list] [prev in thread] [next in thread] 

List:       dhcp-users
Subject:    Re: setting and changing values for ddns-hostname and host-name
From:       btb () bitrate ! net
Date:       2013-03-15 2:06:35
Message-ID: FB7416BE-CA55-4813-9D8B-1EBB0E79D3BE () bitrate ! net
[Download RAW message or body]

On Mar 14, 2013, at 09.32, Peter Rathlev <peter@rathlev.dk> wrote:

> On Wed, 2013-03-13 at 23:26 -0400, btb@bitrate.net wrote:
> > On Mar 13, 2013, at 17.12, Peter Rathlev <peter@rathlev.dk> wrote:
> > > 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?
> 
> Yes, in this example it will.
> > 
> > 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.
> 
> If you always want to use fqdn.hostname (even if that would be invalid)
> you could refactor it thus:
> 
> if (exists fqdn.hostname) {
> ddns-hostname = option fqdn.hostname;
> } elsif (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;
> } elsif (exists host-name) {
> ddns-hostname = option host-name;
> }
> 
> I'm not entirely sure the last claus is needed but have only had the
> time to syntax check this.
> > 
> > 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.
> 
> It's actually "pick-first-value" (man dhcp-eval), which dhcpd apparently
> lets you shorten down to whatever is still unambigous.

thank you for this guidance.  you've prompted me to think a bit more about what i'm \
actually trying to do here in terms of each of these values and the potential that \
one or more of them is invalid.  i'll spend some time with this and maybe reformulate \
my question in another thread, depending on how it goes.

-ben

_______________________________________________
dhcp-users mailing list
dhcp-users@lists.isc.org
https://lists.isc.org/mailman/listinfo/dhcp-users


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic