ddns using client's hostname

Glenn Satchell glenn.satchell at uniq.com.au
Sun May 16 04:28:04 UTC 2010


On 05/16/10 09:20, dhcp wrote:
> Hi,
>
> I have dhcpd working with ddns to my bind9 server. However, I want
> usable hostnames and some system don’t send a hostname. I want is to use
> the clients hostname if one exist (from the client) or make one up if
> none exists. I just can’t figure out how to do this.
>
> I can make one up using this:
>
> ddns-hostname = concat("dhcp-", binary-to-ascii(10, 8, "-",
> leased-address));
>
> But as I said, if the client supplies a hostname I want to use that.
>
> I know the client’s hostname is in the DHCP DHCPDISCOVER message, here
> is an example where the hostname is H36372437:
>
> May 15 19:18:16 linux dhcpd: DHCPDISCOVER from 00:12:f0:ec:e7:c4 via eth0
>
> May 15 19:18:17 linux dhcpd: DHCPOFFER on 192.168.0.203 to
> 00:12:f0:ec:e7:c4 (H36372437) via eth0
>
> May 15 19:18:17 linux dhcpd: Added new forward map from
> dhcp-192-168-0-203.watkins-home.com to 192.168.0.203
>
> May 15 19:18:17 linux dhcpd: added reverse map from
> 203.0.168.192.in-addr.arpa. to dhcp-192-168-0-203.watkins-home.com
>
> May 15 19:18:17 linux dhcpd: DHCPREQUEST for 192.168.0.203 (192.168.0.2)
> from 00:12:f0:ec:e7:c4 (H36372437) via eth0
>
> May 15 19:18:17 linux dhcpd: DHCPACK on 192.168.0.203 to
> 00:12:f0:ec:e7:c4 (H36372437) via eth0
>
> Thanks for any help.
>
> Guy

You could try pick-first-value(), described in the dhcp-eval man page. 
option fqdn.hostname and option hostname are described in dhcp-options 
man page. The dhcpd.conf man page describes the algorithm used by the 
interim DNS update scheme, which uses options fqdn.hostname and hostname.

Perhaps something like this:

ddns-hostname = pick-first-value(
	option fqdn.hostname,
	option hostname,
	concat("dhcp-", binary-to-ascii(10, 8, "-", leased-address))
);

-- 
regards,
-glenn
--
Glenn Satchell                            |  Miss 9: What do you
Uniq Advances Pty Ltd, Sydney Australia   |  do at work Dad?
mailto:glenn.satchell at uniq.com.au         |  Miss 6: He just
http://www.uniq.com.au tel:0409-458-580   |  types random stuff.



More information about the dhcp-users mailing list