ddns using client's hostname

dhcp dhcp at watkins-home.com
Sun May 16 06:03:57 UTC 2010


} -----Original Message-----
} From: dhcp-users-bounces+dhcp=watkins-home.com at lists.isc.org [mailto:dhcp-
} users-bounces+dhcp=watkins-home.com at lists.isc.org] On Behalf Of Glenn
} Satchell
} Sent: Sunday, May 16, 2010 12:28 AM
} To: Users of ISC DHCP
} Subject: Re: ddns using client's hostname
} 
} 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.

Thanks Glenn,
	I did find a solution and was about to answer my own email when I
saw your solution.  I came up with this:

if exists host-name
   {
     ddns-hostname = lcase (option host-name);
   }
else
   {
     ddns-hostname = concat("dhcp-", binary-to-ascii(10, 8, "-",
leased-address));
   }

I tried to use fqdn.hostname and got errors.  Not sure why.  I think I will
use your solution and use pick-first-value and try fqdn.hostname again.  The
only thing you missed was lcase.  :)  I hate upper case hostnames for some
reason.

Thanks,
Guy




More information about the dhcp-users mailing list