On my DHCP static reserves I generally supply the hostname option in the reservation to ensure getting the value that I want.  I would love to have all the other machines that pull leases but do not have a reserve to use this generated hostname based on IP address.  I have many machines on my campus that have bad hostnames, either because of bad characters or gibberish entries.  Will the ddns-hostname setting trump the hostname option specified in my reserves?<br>

<br>-Kevin<br><br><div class="gmail_quote">On Sun, May 16, 2010 at 2:09 AM, Glenn Satchell <span dir="ltr"><<a href="mailto:glenn.satchell@uniq.com.au">glenn.satchell@uniq.com.au</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

<div><div></div><div class="h5">On 05/16/10 16:03, dhcp wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
} -----Original Message-----<br>
} From: dhcp-users-bounces+dhcp=<a href="http://watkins-home.com" target="_blank">watkins-home.com</a>@<a href="http://lists.isc.org" target="_blank">lists.isc.org</a> [mailto:<a href="mailto:dhcp-" target="_blank">dhcp-</a><br>


} users-bounces+dhcp=<a href="http://watkins-home.com" target="_blank">watkins-home.com</a>@<a href="http://lists.isc.org" target="_blank">lists.isc.org</a>] On Behalf Of Glenn<br>
} Satchell<br>
} Sent: Sunday, May 16, 2010 12:28 AM<br>
} To: Users of ISC DHCP<br>
} Subject: Re: ddns using client's hostname<br>
}<br>
} On 05/16/10 09:20, dhcp wrote:<br>
}>  Hi,<br>
}><br>
}>  I have dhcpd working with ddns to my bind9 server. However, I want<br>
}>  usable hostnames and some system don't send a hostname. I want is to use<br>
}>  the clients hostname if one exist (from the client) or make one up if<br>
}>  none exists. I just can't figure out how to do this.<br>
}><br>
}>  I can make one up using this:<br>
}><br>
}>  ddns-hostname = concat("dhcp-", binary-to-ascii(10, 8, "-",<br>
}>  leased-address));<br>
}><br>
}>  But as I said, if the client supplies a hostname I want to use that.<br>
}><br>
}>  I know the client's hostname is in the DHCP DHCPDISCOVER message, here<br>
}>  is an example where the hostname is H36372437:<br>
}><br>
}>  May 15 19:18:16 linux dhcpd: DHCPDISCOVER from 00:12:f0:ec:e7:c4 via<br>
} eth0<br>
}><br>
}>  May 15 19:18:17 linux dhcpd: DHCPOFFER on 192.168.0.203 to<br>
}>  00:12:f0:ec:e7:c4 (H36372437) via eth0<br>
}><br>
}>  May 15 19:18:17 linux dhcpd: Added new forward map from<br>
}>  <a href="http://dhcp-192-168-0-203.watkins-home.com" target="_blank">dhcp-192-168-0-203.watkins-home.com</a> to 192.168.0.203<br>
}><br>
}>  May 15 19:18:17 linux dhcpd: added reverse map from<br>
}>  203.0.168.192.in-addr.arpa. to <a href="http://dhcp-192-168-0-203.watkins-home.com" target="_blank">dhcp-192-168-0-203.watkins-home.com</a><br>
}><br>
}>  May 15 19:18:17 linux dhcpd: DHCPREQUEST for 192.168.0.203 (192.168.0.2)<br>
}>  from 00:12:f0:ec:e7:c4 (H36372437) via eth0<br>
}><br>
}>  May 15 19:18:17 linux dhcpd: DHCPACK on 192.168.0.203 to<br>
}>  00:12:f0:ec:e7:c4 (H36372437) via eth0<br>
}><br>
}>  Thanks for any help.<br>
}><br>
}>  Guy<br>
}<br>
} You could try pick-first-value(), described in the dhcp-eval man page.<br>
} option fqdn.hostname and option hostname are described in dhcp-options<br>
} man page. The dhcpd.conf man page describes the algorithm used by the<br>
} interim DNS update scheme, which uses options fqdn.hostname and hostname.<br>
}<br>
} Perhaps something like this:<br>
}<br>
} ddns-hostname = pick-first-value(<br>
}       option fqdn.hostname,<br>
}       option hostname,<br>
}       concat("dhcp-", binary-to-ascii(10, 8, "-", leased-address))<br>
} );<br>
}<br>
} --<br>
} regards,<br>
} -glenn<br>
} --<br>
} Glenn Satchell                            |  Miss 9: What do you<br>
} Uniq Advances Pty Ltd, Sydney Australia   |  do at work Dad?<br>
} mailto:<a href="mailto:glenn.satchell@uniq.com.au" target="_blank">glenn.satchell@uniq.com.au</a>         |  Miss 6: He just<br>
} <a href="http://www.uniq.com.au" target="_blank">http://www.uniq.com.au</a> tel:0409-458-580   |  types random stuff.<br>
<br>
Thanks Glenn,<br>
        I did find a solution and was about to answer my own email when I<br>
saw your solution.  I came up with this:<br>
<br>
if exists host-name<br>
    {<br>
      ddns-hostname = lcase (option host-name);<br>
    }<br>
else<br>
    {<br>
      ddns-hostname = concat("dhcp-", binary-to-ascii(10, 8, "-",<br>
leased-address));<br>
    }<br>
<br>
I tried to use fqdn.hostname and got errors.  Not sure why.  I think I will<br>
use your solution and use pick-first-value and try fqdn.hostname again.  The<br>
only thing you missed was lcase.  :)  I hate upper case hostnames for some<br>
reason.<br>
<br>
Thanks,<br>
Guy<br>
<br>
</blockquote>
<br></div></div>
Oh well, if fqdn.hostname doesn't work for some reason you can leave that line out.<br>
<br>
There was no previous mention of lcase() but I was trying to keep the example as simple as possible. FWIW I prefer all lower case hostnames too :)<br>
<br>
-- <br>
regards,<br><font color="#888888">
-glenn</font><div><div></div><div class="h5"><br>
<br>
_______________________________________________<br>
dhcp-users mailing list<br>
<a href="mailto:dhcp-users@lists.isc.org" target="_blank">dhcp-users@lists.isc.org</a><br>
<a href="https://lists.isc.org/mailman/listinfo/dhcp-users" target="_blank">https://lists.isc.org/mailman/listinfo/dhcp-users</a><br>
</div></div></blockquote></div><br>