[Howto] dhcpd and DDNS Update without hostname: expression to create a hostname

posted in: computer | 0

ISC dhcpd 4.3.6

ISC bind 9.10.6-p1

 

Problem:

dhcpd requires a client-hostname to update the DNS zone dynamically (=DDNS). If the client doesn’t send a hostname (or the hostname is empty), dhcpd can’t add an DNS entry dynamically in the zone-file. If there is no DNS entry for the client in the zone-file, the user can’t access the client via a domain-name.

 

Solution:

if there is no hostname, dhcpd must create an alternative hostname itself, e.g. it can use the client-mac-adress as hostname.

 

Code (dhcpd.conf):

this code try’s at first the FQDN. If FQDN is empty, it try’s the hostname field. If it’s empty too, it creates a mac-address-hostname like “aa-bb-cc-dd-ee-ff”

 option server.ddns-hostname = pick-first-value (
    option fqdn.hostname,
    option host-name,
    concat (
       suffix (concat ("0", binary-to-ascii (16, 8, "", substring (hardware, 1, 1))),2),
       "-",
       suffix (concat ("0", binary-to-ascii (16, 8, "", substring (hardware, 2, 1))),2),
       "-",
       suffix (concat ("0", binary-to-ascii (16, 8, "", substring (hardware, 3, 1))),2),
       "-",
       suffix (concat ("0", binary-to-ascii (16, 8, "", substring (hardware, 4, 1))),2),
       "-",
       suffix (concat ("0", binary-to-ascii (16, 8, "", substring (hardware, 5, 1))),2),
       "-",
       suffix (concat ("0", binary-to-ascii (16, 8, "", substring (hardware, 6, 1))),2)
   )
 );