diff options
Diffstat (limited to 'tools/dhcpns/config')
-rw-r--r-- | tools/dhcpns/config/ddns.py | 10 | ||||
-rw-r--r-- | tools/dhcpns/config/dhcp4.py | 16 |
2 files changed, 24 insertions, 2 deletions
diff --git a/tools/dhcpns/config/ddns.py b/tools/dhcpns/config/ddns.py index 531fc34..8490967 100644 --- a/tools/dhcpns/config/ddns.py +++ b/tools/dhcpns/config/ddns.py @@ -8,7 +8,13 @@ def base(ddns_domains = [], ddns_reverse_domains = []): "socket-type": "unix", "socket-name": "/tmp/kea-ddns-ctrl-socket" }, - "tsig-keys": [], + "tsig-keys": [ + { + "name": os.environ['KEA_DDNS_KEY_NAME'], + "algorithm": os.environ['KEA_DDNS_ALGORITHM'], + "secret": os.environ['KEA_DDNS_SECRET'] + } + ], "forward-ddns": { "ddns-domains": ddns_domains }, @@ -37,7 +43,7 @@ def ddns_domain(domain_name): "key-name": os.environ['KEA_DDNS_KEY_NAME'], "dns-servers": [ { - "ip-address": os.environ['NS1_V6'], + "ip-address": "::1", "port": 53 } ] diff --git a/tools/dhcpns/config/dhcp4.py b/tools/dhcpns/config/dhcp4.py index f9a9382..d1a779d 100644 --- a/tools/dhcpns/config/dhcp4.py +++ b/tools/dhcpns/config/dhcp4.py @@ -37,6 +37,17 @@ def base(subnet4): } } ], + "dhcp-ddns": { + "enable-updates": True, + "server-ip": "::1", + }, + "ddns-send-updates": True, + "ddns-override-no-update": False, + "ddns-override-client-update": False, + "ddns-replace-client-name": "always", + "ddns-generated-prefix": "dyn", + "ddns-update-on-renew": False, + "ddns-use-conflict-resolution": True, "interfaces-config": { "interfaces": [ os.environ.get('DHCP_INTERFACE', 'eth0') @@ -222,10 +233,14 @@ def base(subnet4): def subnet(vlan, prefix, domain_name, vlan_domain_name): network = ipaddress.ip_network(prefix.prefix) gw, start_ip, end_ip = network[1], network[2], network[-2] + return { "id": prefix.id, "subnet": prefix.prefix, "ddns-qualifying-suffix": vlan_domain_name, + # Check if the VLAN in netbox has dhcp-ddns. This will enable full ddns using client hostnames. + # Generate automatically using IP if not. + "ddns-replace-client-name": "always" if not any(t['slug'] == 'dhcp-ddns' for t in vlan.tags) else "when-not-present", "pools": [ { "pool": f"{start_ip} - {end_ip}" @@ -256,6 +271,7 @@ def fap(vlan, prefix): network = ipaddress.ip_network(prefix.prefix) gw, start_ip, end_ip = network[1], network[( math.ceil(network.num_addresses / 2))], network[-2] + return { "id": prefix.id, "client-class": "fap-class", |