Commit 7d38c21d authored by Dimitris Aragiorgis's avatar Dimitris Aragiorgis

Reapply option for serving domain

Signed-off-by: default avatarDimitris Aragiorgis <dimara@grnet.gr>
parent 2313c0be
......@@ -79,6 +79,7 @@ lease_renewal = integer(min=0, max=4294967295)
server_ip = ip_addr()
dhcp_queue = integer(min=0, max=65535)
nameservers = ip_addr_list(family=4)
domain = string(default=None)
[ipv6]
enable_ipv6 = boolean(default=True)
......@@ -279,12 +280,14 @@ class VMNetProxy(object): # pylint: disable=R0902
rs_queue_num=None, ns_queue_num=None,
dhcp_lease_lifetime=DEFAULT_LEASE_LIFETIME,
dhcp_lease_renewal=DEFAULT_LEASE_RENEWAL,
dhcp_domain='',
dhcp_server_ip=DHCP_DUMMY_SERVER_IP, dhcp_nameservers=None,
ra_period=DEFAULT_RA_PERIOD, ipv6_nameservers=None):
self.data_path = data_path
self.lease_lifetime = dhcp_lease_lifetime
self.lease_renewal = dhcp_lease_renewal
self.dhcp_domain = dhcp_domain
self.dhcp_server_ip = dhcp_server_ip
self.ra_period = ra_period
if dhcp_nameservers is None:
......@@ -519,6 +522,11 @@ class VMNetProxy(object): # pylint: disable=R0902
logging.info("%s from %s on %s", DHCP_TYPES.get(req_type, "UNKNOWN"),
binding.mac, binding.tap)
if self.dhcp_domain:
domainname = self.dhcp_domain
else:
domainname = binding.hostname.split('.', 1)[-1]
if req_type == DHCPREQUEST and requested_addr != binding.ip:
resp_type = DHCPNAK
logging.info("Sending DHCPNAK to %s on %s: requested %s"
......@@ -530,7 +538,7 @@ class VMNetProxy(object): # pylint: disable=R0902
resp.yiaddr = self.clients[mac].ip
dhcp_options += [
("hostname", binding.hostname),
("domain", binding.hostname.split('.', 1)[-1]),
("domain", domainname),
("broadcast_address", str(subnet.broadcast)),
("subnet_mask", str(subnet.netmask)),
("renewal_time", self.lease_renewal),
......@@ -544,7 +552,7 @@ class VMNetProxy(object): # pylint: disable=R0902
resp_type = DHCP_REQRESP[req_type]
dhcp_options += [
("hostname", binding.hostname),
("domain", binding.hostname.split('.', 1)[-1]),
("domain", domainname),
]
dhcp_options += [("name_server", x) for x in self.dhcp_nameservers]
......@@ -859,6 +867,7 @@ if __name__ == "__main__":
"dhcp_lease_renewal": config["dhcp"].as_int("lease_renewal"),
"dhcp_server_ip": config["dhcp"]["server_ip"],
"dhcp_nameservers": config["dhcp"]["nameservers"],
"dhcp_domain": config["dhcp"]["domain"],
})
if config["ipv6"].as_bool("enable_ipv6"):
......
......@@ -15,6 +15,8 @@ server_ip = 1.2.3.4
dhcp_queue = 42 # NFQUEUE number to listen on for DHCP requests
# IPv4 nameservers to include in DHCP responses
nameservers = 194.177.210.210, 194.177.210.10
# Optional domain to serve with the replies
#domain = example.com
## IPv6-related functionality
[ipv6]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment