Revision 99915273

b/nfdhcpd
79 79
server_ip = ip_addr()
80 80
dhcp_queue = integer(min=0, max=65535)
81 81
nameservers = ip_addr_list(family=4)
82
domain = string(default=None)
83

  
82 84

  
83 85
[ipv6]
84 86
enable_ipv6 = boolean(default=True)
......
293 295
                 rs_queue_num=None, ns_queue_num=None,
294 296
                 dhcp_lease_lifetime=DEFAULT_LEASE_LIFETIME,
295 297
                 dhcp_lease_renewal=DEFAULT_LEASE_RENEWAL,
298
                 dhcp_domain='',
296 299
                 dhcp_server_ip=DHCP_DUMMY_SERVER_IP, dhcp_nameservers=None,
297 300
                 ra_period=DEFAULT_RA_PERIOD, ipv6_nameservers=None):
298 301

  
299 302
        self.data_path = data_path
300 303
        self.lease_lifetime = dhcp_lease_lifetime
301 304
        self.lease_renewal = dhcp_lease_renewal
305
        self.dhcp_domain = dhcp_domain
302 306
        self.dhcp_server_ip = dhcp_server_ip
303 307
        self.ra_period = ra_period
304 308
        if dhcp_nameservers is None:
......
558 562
        logging.info("%s from %s on %s", DHCP_TYPES.get(req_type, "UNKNOWN"),
559 563
                     binding.mac, iface)
560 564

  
565
        if self.dhcp_domain:
566
            domainname = self.dhcp_domain
567
        else:
568
            domainname = binding.hostname.split('.', 1)[-1]
569

  
561 570
        if req_type == DHCPREQUEST and requested_addr != binding.ip:
562 571
            resp_type = DHCPNAK
563 572
            logging.info("Sending DHCPNAK to %s on %s: requested %s"
......
569 578
            resp.yiaddr = self.clients[mac].ip
570 579
            dhcp_options += [
571 580
                 ("hostname", binding.hostname),
572
                 ("domain", binding.hostname.split('.', 1)[-1]),
581
                 ("domain", domainname),
573 582
                 ("router", subnet.gw),
574 583
                 ("broadcast_address", str(subnet.broadcast)),
575 584
                 ("subnet_mask", str(subnet.netmask)),
......
582 591
            resp_type = DHCP_REQRESP[req_type]
583 592
            dhcp_options += [
584 593
                 ("hostname", binding.hostname),
585
                 ("domain", binding.hostname.split('.', 1)[-1]),
594
                 ("domain", domainname),
595

  
586 596
            ]
587 597
            dhcp_options += [("name_server", x) for x in self.dhcp_nameservers]
588 598

  
......
883 893
            "dhcp_lease_renewal": config["dhcp"].as_int("lease_renewal"),
884 894
            "dhcp_server_ip": config["dhcp"]["server_ip"],
885 895
            "dhcp_nameservers": config["dhcp"]["nameservers"],
896
            "dhcp_domain": config["dhcp"]["domain"],
886 897
        })
887 898

  
888 899
    if config["ipv6"].as_bool("enable_ipv6"):
b/nfdhcpd.conf
15 15
dhcp_queue = 42 # NFQUEUE number to listen on for DHCP requests
16 16
# IPv4 nameservers to include in DHCP responses
17 17
nameservers = 192.0.2.2, 192.0.2.3
18
# Optional domain to serve with the replies
19
#domain = example.com
18 20

  
19 21
## IPv6-related functionality
20 22
[ipv6]

Also available in: Unified diff