aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore4
-rw-r--r--tools/dhcpns/README.md2
-rw-r--r--tools/dhcpns/config/__init__.py0
-rw-r--r--tools/dhcpns/config/ddns.py44
-rw-r--r--tools/dhcpns/config/dhcp4.py268
-rw-r--r--tools/dhcpns/config/dhcp6.py75
-rw-r--r--tools/dhcpns/main.py115
-rw-r--r--tools/dhcpns/pdns.py116
-rw-r--r--tools/dhcpns/poetry.lock184
-rw-r--r--tools/dhcpns/pyproject.toml17
10 files changed, 825 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index eb8312b..4b6c965 100644
--- a/.gitignore
+++ b/.gitignore
@@ -24,3 +24,7 @@ desktop.ini
.metadata
*.iml
*.ipr
+.env
+
+# Python crap
+__pycache__ \ No newline at end of file
diff --git a/tools/dhcpns/README.md b/tools/dhcpns/README.md
new file mode 100644
index 0000000..ecc63ab
--- /dev/null
+++ b/tools/dhcpns/README.md
@@ -0,0 +1,2 @@
+# tgmanage-dhcp-dns
+Configure KEA-DHCP and PowerDNS with data from Netbox \ No newline at end of file
diff --git a/tools/dhcpns/config/__init__.py b/tools/dhcpns/config/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tools/dhcpns/config/__init__.py
diff --git a/tools/dhcpns/config/ddns.py b/tools/dhcpns/config/ddns.py
new file mode 100644
index 0000000..531fc34
--- /dev/null
+++ b/tools/dhcpns/config/ddns.py
@@ -0,0 +1,44 @@
+import os
+
+def base(ddns_domains = [], ddns_reverse_domains = []):
+ return {
+ "ip-address": "::1",
+ "port": 53001,
+ "control-socket": {
+ "socket-type": "unix",
+ "socket-name": "/tmp/kea-ddns-ctrl-socket"
+ },
+ "tsig-keys": [],
+ "forward-ddns": {
+ "ddns-domains": ddns_domains
+ },
+ "reverse-ddns": {
+ "ddns-domains": ddns_reverse_domains
+ },
+ "loggers": [
+ {
+ "name": "kea-dhcp-ddns",
+ "output_options": [
+ {
+ "output": "stdout",
+ "pattern": "%-5p %m\n"
+ }
+ ],
+ "severity": "INFO",
+ "debuglevel": 0
+ }
+ ]
+ }
+
+
+def ddns_domain(domain_name):
+ return {
+ "name": f"{domain_name}.",
+ "key-name": os.environ['KEA_DDNS_KEY_NAME'],
+ "dns-servers": [
+ {
+ "ip-address": os.environ['NS1_V6'],
+ "port": 53
+ }
+ ]
+ } \ No newline at end of file
diff --git a/tools/dhcpns/config/dhcp4.py b/tools/dhcpns/config/dhcp4.py
new file mode 100644
index 0000000..a70365d
--- /dev/null
+++ b/tools/dhcpns/config/dhcp4.py
@@ -0,0 +1,268 @@
+import os
+import ipaddress
+
+
+def base(subnet4):
+ return {
+ "hooks-libraries": [
+ {
+ "library": "/usr/lib/x86_64-linux-gnu/kea/hooks/libdhcp_flex_option.so",
+ "parameters": {
+ "options": [
+ {
+ "name": "vendor-encapsulated-options",
+ "client-class": "fap-class",
+ "sub-options": [
+ {
+ "name": "config-file-name",
+ "space": "vendor-encapsulated-options-space",
+ "supersede": "ifelse(option[82].option[1].exists,concat('api/templates/magic.conf/a=', option[82].option[1].hex),'')"
+ }
+ ]
+ },
+ {
+ "name": "host-name",
+ "client-class": "fap-class",
+ "remove": "option[12].exists"
+ }
+ ]
+ }
+ },
+ {
+ "library": "/usr/lib/x86_64-linux-gnu/kea/hooks/libdhcp_run_script.so",
+ "parameters": {
+ "name": "/etc/kea/gondul.sh",
+ "sync": False
+ }
+ }
+ ],
+ "interfaces-config": {
+ "interfaces": [
+ os.environ.get('DHCP_INTERFACE', 'eth0')
+ ],
+ "dhcp-socket-type": "udp"
+ },
+ "control-socket": {
+ "socket-type": "unix",
+ "socket-name": "/tmp/kea4-ctrl-socket"
+ },
+ "lease-database": {
+ "type": "postgresql",
+ "name": "kea",
+ "user": "kea",
+ "password": os.environ['DHCP_LEASE_DB_PASSWORD']
+ },
+ "expired-leases-processing": {
+ "reclaim-timer-wait-time": 10,
+ "flush-reclaimed-timer-wait-time": 25,
+ "hold-reclaimed-time": 3600,
+ "max-reclaim-leases": 100,
+ "max-reclaim-time": 250,
+ "unwarned-reclaim-cycles": 5
+ },
+ "authoritative": True,
+ "renew-timer": 900,
+ "rebind-timer": 1800,
+ "valid-lifetime": 3600,
+ "option-def": [
+ {
+ "name": "image-file-name",
+ "code": 0,
+ "space": "vendor-encapsulated-options-space",
+ "type": "string",
+ "array": False
+ },
+ {
+ "name": "config-file-name",
+ "code": 1,
+ "space": "vendor-encapsulated-options-space",
+ "type": "string",
+ "array": False
+ },
+ {
+ "name": "image-file-type",
+ "code": 2,
+ "space": "vendor-encapsulated-options-space",
+ "type": "string",
+ "array": False
+ },
+ {
+ "name": "transfer-mode",
+ "code": 3,
+ "space": "vendor-encapsulated-options-space",
+ "type": "string",
+ "array": False
+ },
+ {
+ "code": 150,
+ "name": "tftp-server-address",
+ "space": "dhcp4",
+ "type": "ipv4-address",
+ "array": True
+ }
+ ],
+ "option-data": [
+ {
+ "name": "domain-name-servers",
+ "data": os.environ['DOMAIN_NAME_SERVERS_V4']
+ },
+ {
+ "name": "domain-name",
+ "data": os.environ['DOMAIN_NAME']
+ },
+ {
+ "name": "domain-search",
+ "data": os.environ['DOMAIN_SEARCH']
+ }
+ ],
+ "client-classes": [
+ {
+ "name": "client-juniper-vendor",
+ "test": "substring(option[vendor-class-identifier].hex,0,10) == 'Juniper-ex'"
+ },
+ {
+ "name": "client-juniper-mac",
+ "test": "substring(pkt4.mac, 0, 2) == '0x44f477' or substring(pkt4.mac, 0, 2) == '0xf01c2d'"
+ },
+ {
+ "name": "fap-class",
+ "test": "member('client-juniper-vendor') or member('client-juniper-mac')",
+ "option-data": [
+ {
+ "name": "vendor-encapsulated-options",
+ "always-send": True
+ },
+ {
+ "name": "transfer-mode",
+ "space": "vendor-encapsulated-options-space",
+ "data": "http",
+ "always-send": True
+ },
+ {
+ "name": "tftp-server-address",
+ "data": os.environ['FAP_V4'],
+ "always-send": True
+ }
+ ]
+ },
+ {
+ "name": "Cisco-Phone",
+ "test": "substring(option[60].hex,0,28) == 'Cisco Systems, Inc. IP Phone'",
+ "option-data": [
+ {
+ "name": "tftp-server-address",
+ "data": os.environ['VOIP_V4'],
+ "always-send": True
+ },
+ ],
+ },
+ {
+ "name": "PXE-XClient_iPXE",
+ "test": "substring(option[77].hex,0,4) == 'iPXE'",
+ "boot-file-name": "https://{}/menu.ipxe".format(os.environ['NETBOOT_V4'])
+ },
+ {
+ "name": "PXE-UEFI-32-1",
+ "test": "substring(option[60].hex,0,20) == 'PXEClient:Arch:00006'",
+ "next-server": os.environ['NETBOOT_V4'],
+ "boot-file-name": "netboot.xyz.efi"
+ },
+ {
+ "name": "PXE-UEFI-32-2",
+ "test": "substring(option[60].hex,0,20) == 'PXEClient:Arch:00002'",
+ "next-server": os.environ['NETBOOT_V4'],
+ "boot-file-name": "netboot.xyz.efi"
+ },
+ {
+ "name": "PXE-UEFI-64-1",
+ "test": "substring(option[60].hex,0,20) == 'PXEClient:Arch:00007'",
+ "next-server": os.environ['NETBOOT_V4'],
+ "boot-file-name": "netboot.xyz.efi"
+ },
+ {
+ "name": "PXE-UEFI-64-2",
+ "test": "substring(option[60].hex,0,20) == 'PXEClient:Arch:00008'",
+ "next-server": os.environ['NETBOOT_V4'],
+ "boot-file-name": "netboot.xyz.efi"
+ },
+ {
+ "name": "PXE-UEFI-64-3",
+ "test": "substring(option[60].hex,0,20) == 'PXEClient:Arch:00009'",
+ "next-server": os.environ['NETBOOT_V4'],
+ "boot-file-name": "netboot.xyz.efi"
+ },
+ {
+ "name": "PXE-Legacy",
+ "test": "substring(option[60].hex,0,20) == 'PXEClient:Arch:00000'",
+ "next-server": os.environ['NETBOOT_V4'],
+ "boot-file-name": "netboot.xyz-undionly.kpxe"
+ }
+ ],
+ "subnet4": 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,
+ "pools": [
+ {
+ "pool": f"{start_ip} - {end_ip}"
+ }
+ ],
+ "option-data": [
+ {
+ "name": "routers",
+ "data": f"{gw}"
+ },
+ {
+ "name": "domain-name",
+ "data": f"{vlan_domain_name}, {domain_name}"
+ },
+ {
+ "name": "domain-search",
+ "data": f"{vlan_domain_name}, {domain_name}"
+ }
+ ],
+ "user-context": {
+ "name": vlan.name,
+ "type": "clients"
+ }
+ }
+
+
+def fap(vlan, prefix, domain_name, vlan_domain_name):
+ network = ipaddress.ip_network(prefix.prefix)
+ gw, start_ip, end_ip = network[1], network[len(network) / 2], network[-2]
+ return {
+ "id": prefix.id,
+ "client-class": "fap-class",
+ "subnet": prefix.prefix,
+ "pools": [
+ {
+ "pool": f"{start_ip} - {end_ip}"
+ }
+ ],
+ "option-data": [
+ {
+ "name": "routers",
+ "data": f"{gw}"
+ },
+ {
+ "name": "domain-name",
+ "data": f"{vlan_domain_name}, {domain_name}"
+ },
+ {
+ "name": "domain-search",
+ "data": f"{vlan_domain_name}, {domain_name}"
+ }
+ ],
+ "user-context": {
+ "name": vlan.name,
+ "type": "fap"
+ }
+ }
diff --git a/tools/dhcpns/config/dhcp6.py b/tools/dhcpns/config/dhcp6.py
new file mode 100644
index 0000000..5efdba3
--- /dev/null
+++ b/tools/dhcpns/config/dhcp6.py
@@ -0,0 +1,75 @@
+import os
+import ipaddress
+
+
+def base(subnet6):
+ return {
+ "hooks-libraries": [
+ ],
+ "interfaces-config": {
+ "interfaces": [
+ "{}/{}".format(os.environ.get('DHCP_INTERFACE', 'eth0'), os.environ.get('DHCP_INTERFACE_V6'))
+ ]
+ },
+ "control-socket": {
+ "socket-type": "unix",
+ "socket-name": "/tmp/kea6-ctrl-socket"
+ },
+ "lease-database": {
+ "type": "postgresql",
+ "name": "kea",
+ "user": "kea",
+ "password": os.environ['DHCP_LEASE_DB_PASSWORD']
+ },
+ "expired-leases-processing": {
+ "reclaim-timer-wait-time": 10,
+ "flush-reclaimed-timer-wait-time": 25,
+ "hold-reclaimed-time": 3600,
+ "max-reclaim-leases": 100,
+ "max-reclaim-time": 250,
+ "unwarned-reclaim-cycles": 5
+ },
+ "renew-timer": 900,
+ "rebind-timer": 1800,
+ "preferred-lifetime": 3000,
+ "valid-lifetime": 3600,
+ "option-data": [
+ {
+ "name": "dns-servers",
+ "data": os.environ['DOMAIN_NAME_SERVERS_V6']
+ },
+ {
+ "name": "domain-search",
+ "data": os.environ['DOMAIN_SEARCH']
+ },
+ {
+ "name": "unicast",
+ "data": os.environ.get('DHCP_INTERFACE_V6')
+ }
+ ],
+ "subnet6": subnet6
+ }
+
+
+def subnet(vlan, prefix, domain_name, vlan_domain_name):
+ network = ipaddress.ip_network(prefix.prefix)
+ return {
+ "id": prefix.id,
+ "subnet": prefix.prefix,
+ "ddns-qualifying-suffix": vlan_domain_name,
+ "pools": [
+ {
+ "pool": f"{network[0]}10-{network[0]}ffff"
+ }
+ ],
+ "option-data": [
+ {
+ "name": "domain-search",
+ "data": f"{vlan_domain_name}, {domain_name}"
+ }
+ ],
+ "user-context": {
+ "name": vlan.name,
+ "type": "clients"
+ }
+ } \ No newline at end of file
diff --git a/tools/dhcpns/main.py b/tools/dhcpns/main.py
new file mode 100644
index 0000000..ef6eb25
--- /dev/null
+++ b/tools/dhcpns/main.py
@@ -0,0 +1,115 @@
+import pynetbox
+import os
+from dotenv import load_dotenv
+import json
+from pdns import PowerDNS
+
+from config.dhcp4 import base as dhcp4
+from config.dhcp6 import base as dhcp6
+from config.ddns import base as ddns
+from config.ddns import ddns_domain
+from config.dhcp4 import subnet as subnet4
+from config.dhcp6 import subnet as subnet6
+
+import ipaddress
+
+# Take environment variables from .env
+load_dotenv()
+
+DOMAIN_NAME = os.environ['DOMAIN_NAME']
+DOMAIN_SEARCH = os.environ['DOMAIN_SEARCH']
+NAMESERVERS = os.environ['NAMESERVERS'].strip().split(',')
+
+nb = pynetbox.api(
+ os.getenv('NETBOX_URL'),
+ token=os.getenv('NETBOX_API_KEY'),
+ threading=True,
+)
+
+# DNS
+pdns = PowerDNS(os.environ['PDNS_API_URL'], os.environ['PDNS_API_KEY'])
+
+# Load all zones to later check if a zone already exist
+zones = [ zone['name'] for zone in pdns.list_zones() ]
+
+rdns_zones = pdns.search("*.arpa", 2000, "zone")
+
+kea4_subnets = []
+kea6_subnets = []
+kea_ddns_domains = []
+kea_rddns_domains = []
+
+vlans = nb.ipam.vlans.filter(tag='dhcp')
+for vlan in vlans:
+ vlan_domain_name = f"{vlan.name}.{DOMAIN_NAME}"
+ prefixes4 = []
+ prefixes6 = []
+ kea_ddns_domains.append(ddns_domain(vlan_domain_name))
+
+ for prefix in nb.ipam.prefixes.filter(vlan_id=vlan.id, family=4):
+ kea4_subnets.append(
+ subnet4(vlan, prefix, DOMAIN_NAME, vlan_domain_name))
+ #prefixes4.append(prefix)
+
+ for prefix in nb.ipam.prefixes.filter(vlan_id=vlan.id, family=6):
+ kea6_subnets.append(
+ subnet6(vlan, prefix, DOMAIN_NAME, vlan_domain_name))
+ #prefixes6.append(prefix)
+
+ if vlan_domain_name not in zones and len(prefixes4) >= 1:
+ pdns.create_zone(vlan_domain_name, NAMESERVERS)
+ pdns.create_zone_metadata(
+ vlan_domain_name, 'TSIG-ALLOW-DNSUPDATE', 'dhcp_updater')
+
+ zone_rrsets = []
+
+ for prefix in prefixes4:
+ network = ipaddress.ip_network(prefix)
+
+ # Network ID
+ zone_rrsets.append({'name': f'net-{network[0]}.{vlan_domain_name}', 'changetype': 'replace', 'type': 'A', 'records': [
+ {'content': str(network[0]), 'disabled': False, 'type':'A'}], 'ttl': 900})
+
+ # Gateway
+ zone_rrsets.append({'name': f'gw-{network[1]}.{vlan_domain_name}', 'changetype': 'replace', 'type': 'A', 'records': [
+ {'content': str(network[1]), 'disabled': False, 'type':'A'}], 'ttl': 900})
+
+ # Broadcast
+ zone_rrsets.append({'name': f'broadcast-{network[-1]}.{vlan_domain_name}', 'changetype': 'replace', 'type': 'A', 'records': [
+ {'content': str(network[-1]), 'disabled': False, 'type':'A'}], 'ttl': 900})
+
+ rdns_zone = pdns.get_rdns_zone_from_ip(network[0])
+ rdns_rrsets = []
+ if rdns_zone is None:
+ print(f"Failed to find RDNS Zone for IP {network[0]}")
+
+ # Network ID
+ rdns_rrsets.append({"name": network[0].reverse_pointer + '.', "changetype": "replace", "type": "PTR", "records": [
+ {"content": f'net-{network[0]}.{vlan_domain_name}', "disabled": False, "type": "PTR"}], "ttl": 900})
+
+ # Gateway
+ rdns_rrsets.append({"name": network[1].reverse_pointer + '.', "changetype": "replace", "type": "PTR", "records": [
+ {"content": f'gw-{network[1]}.{vlan_domain_name}', "disabled": False, "type": "PTR"}], "ttl": 900})
+
+ # Broadcast
+ rdns_rrsets.append({"name": network[-1].reverse_pointer + '.', "changetype": "replace", "type": "PTR", "records": [
+ {"content": f'broadcast-{network[-1]}.{vlan_domain_name}', "disabled": False, "type": "PTR"}], "ttl": 900})
+
+
+for zone in rdns_zones:
+ kea_rddns_domains.append(ddns_domain(zone['name'][:-1]))
+
+# Write DDNS
+if os.environ['KEA_DDNS_FILE'] is not None:
+ with open(os.environ['KEA_DDNS_FILE'], "w") as outfile:
+ outfile.write(json.dumps({"DhcpDdns": ddns(kea_ddns_domains, kea_rddns_domains)}, indent=2))
+
+# Write DHCPv4
+if os.environ['KEA_DHCP4_FILE'] is not None:
+ with open(os.environ['KEA_DHCP4_FILE'], "w") as outfile:
+ outfile.write(json.dumps({"Dhcp4": dhcp4(kea4_subnets)}, indent=2))
+
+# Write DHCPv4
+if os.environ['KEA_DHCP6_FILE'] is not None:
+ with open(os.environ['KEA_DHCP6_FILE'], "w") as outfile:
+ outfile.write(json.dumps({"Dhcp6": dhcp4(kea6_subnets)}, indent=2))
diff --git a/tools/dhcpns/pdns.py b/tools/dhcpns/pdns.py
new file mode 100644
index 0000000..296a151
--- /dev/null
+++ b/tools/dhcpns/pdns.py
@@ -0,0 +1,116 @@
+import requests
+import ipaddress
+
+
+class PowerDNS:
+ def __init__(self, base_url, apikey, dryrun=False):
+ self.base_url = base_url
+ self.apikey = apikey
+ self.dryrun = dryrun
+ self._rdns_v4_zones = None
+ self._rdns_v6_zones = None
+
+
+ def _query(self, uri, method, kwargs={}):
+ if self.dryrun:
+ return None
+
+ headers = {
+ 'X-API-Key': self.apikey,
+ 'Accept': 'application/json'
+ }
+
+ if method == "GET":
+ request = requests.get(self.base_url + uri, headers=headers)
+ elif method == "POST":
+ request = requests.post(
+ self.base_url + uri,
+ headers=headers,
+ data=kwargs
+ )
+ elif method == "PUT":
+ request = requests.put(
+ self.base_url + uri,
+ headers=headers,
+ data=kwargs
+ )
+ elif method == "PATCH":
+ request = requests.patch(
+ self.base_url + uri, headers=headers, json=kwargs
+ )
+ elif method == "DELETE":
+ request = requests.delete(self.base_url + uri, headers=headers)
+
+ if request.headers.get('content-type') == 'application/json':
+ return request.json()
+ return None
+
+
+ def list_zones(self):
+ if self.dryrun:
+ return []
+ return self._query("/servers/localhost/zones", "GET")
+
+
+ def get_zone(self, domain):
+ return self._query("/servers/localhost/zones/%s." % domain, "GET")
+
+
+ def set_records(self, domain, rrsets):
+ return self._query("/servers/localhost/zones/%s" % domain, "PATCH", {
+ 'rrsets': rrsets
+ })
+
+
+ def search(self, q, max=100, object_type="all"):
+ if self.dryrun:
+ return []
+ return self._query(
+ "/servers/localhost/search-data?q={0}&max={1}&object_type={2}".format(
+ q, max, object_type), "GET")
+
+
+ def get_zone_metadata(self, domain):
+ return self._query("/servers/localhost/zones/%s/metadata" % (domain), "GET")
+
+
+ def create_zone_metadata(self, domain, kind, content):
+ return self._query("/servers/localhost/zones/%s/metadata" % (domain), "POST", {
+ 'kind': kind,
+ 'metadata': [content]
+ })
+
+
+ def create_zone(self, domain, nameservers, kind='Master'):
+ return self._query("/servers/localhost/zones", "POST", {
+ 'kind': kind,
+ 'nameservers': nameservers,
+ 'name': domain
+ })
+
+ def delete_zone(self, domain):
+ return self._query("/servers/localhost/zones/%s." % (domain), "DELETE")
+
+
+ def get_rdns_zone_from_ip(self, ip):
+ if self._rdns_v4_zones is None:
+ self._rdns_v4_zones = self.search("*.in-addr.arpa", 2000, "zone")
+ if self._rdns_v6_zones is None:
+ self._rdns_v6_zones = self.search("*.ip6.arpa", 2000, "zone")
+
+ address = ipaddress.ip_address(ip)
+ rdns_zones = self._rdns_v4_zones if address.version == 4 else self._rdns_v6_zones
+
+ ptr = address.reverse_pointer
+ rdns_zone = None
+ rdns_zone_accuracy = 30
+ for zone in [sub['name'] for sub in rdns_zones]:
+ test = str(ptr).split('.')
+ for i in range(len(test) - 3):
+ x = len(test) - i
+ if '.'.join(test[-x:]) + '.' in zone and rdns_zone_accuracy > i:
+ rdns_zone = zone
+ rdns_zone_accuracy = i
+ break
+
+ return rdns_zone
diff --git a/tools/dhcpns/poetry.lock b/tools/dhcpns/poetry.lock
new file mode 100644
index 0000000..ff010f1
--- /dev/null
+++ b/tools/dhcpns/poetry.lock
@@ -0,0 +1,184 @@
+# This file is automatically @generated by Poetry 1.4.1 and should not be changed by hand.
+
+[[package]]
+name = "certifi"
+version = "2022.12.7"
+description = "Python package for providing Mozilla's CA Bundle."
+category = "main"
+optional = false
+python-versions = ">=3.6"
+files = [
+ {file = "certifi-2022.12.7-py3-none-any.whl", hash = "sha256:4ad3232f5e926d6718ec31cfc1fcadfde020920e278684144551c91769c7bc18"},
+ {file = "certifi-2022.12.7.tar.gz", hash = "sha256:35824b4c3a97115964b408844d64aa14db1cc518f6562e8d7261699d1350a9e3"},
+]
+
+[[package]]
+name = "charset-normalizer"
+version = "3.1.0"
+description = "The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet."
+category = "main"
+optional = false
+python-versions = ">=3.7.0"
+files = [
+ {file = "charset-normalizer-3.1.0.tar.gz", hash = "sha256:34e0a2f9c370eb95597aae63bf85eb5e96826d81e3dcf88b8886012906f509b5"},
+ {file = "charset_normalizer-3.1.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:e0ac8959c929593fee38da1c2b64ee9778733cdf03c482c9ff1d508b6b593b2b"},
+ {file = "charset_normalizer-3.1.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d7fc3fca01da18fbabe4625d64bb612b533533ed10045a2ac3dd194bfa656b60"},
+ {file = "charset_normalizer-3.1.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:04eefcee095f58eaabe6dc3cc2262f3bcd776d2c67005880894f447b3f2cb9c1"},
+ {file = "charset_normalizer-3.1.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:20064ead0717cf9a73a6d1e779b23d149b53daf971169289ed2ed43a71e8d3b0"},
+ {file = "charset_normalizer-3.1.0-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:1435ae15108b1cb6fffbcea2af3d468683b7afed0169ad718451f8db5d1aff6f"},
+ {file = "charset_normalizer-3.1.0-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:c84132a54c750fda57729d1e2599bb598f5fa0344085dbde5003ba429a4798c0"},
+ {file = "charset_normalizer-3.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:75f2568b4189dda1c567339b48cba4ac7384accb9c2a7ed655cd86b04055c795"},
+ {file = "charset_normalizer-3.1.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:11d3bcb7be35e7b1bba2c23beedac81ee893ac9871d0ba79effc7fc01167db6c"},
+ {file = "charset_normalizer-3.1.0-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:891cf9b48776b5c61c700b55a598621fdb7b1e301a550365571e9624f270c203"},
+ {file = "charset_normalizer-3.1.0-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:5f008525e02908b20e04707a4f704cd286d94718f48bb33edddc7d7b584dddc1"},
+ {file = "charset_normalizer-3.1.0-cp310-cp310-musllinux_1_1_ppc64le.whl", hash = "sha256:b06f0d3bf045158d2fb8837c5785fe9ff9b8c93358be64461a1089f5da983137"},
+ {file = "charset_normalizer-3.1.0-cp310-cp310-musllinux_1_1_s390x.whl", hash = "sha256:49919f8400b5e49e961f320c735388ee686a62327e773fa5b3ce6721f7e785ce"},
+ {file = "charset_normalizer-3.1.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:22908891a380d50738e1f978667536f6c6b526a2064156203d418f4856d6e86a"},
+ {file = "charset_normalizer-3.1.0-cp310-cp310-win32.whl", hash = "sha256:12d1a39aa6b8c6f6248bb54550efcc1c38ce0d8096a146638fd4738e42284448"},
+ {file = "charset_normalizer-3.1.0-cp310-cp310-win_amd64.whl", hash = "sha256:65ed923f84a6844de5fd29726b888e58c62820e0769b76565480e1fdc3d062f8"},
+ {file = "charset_normalizer-3.1.0-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:9a3267620866c9d17b959a84dd0bd2d45719b817245e49371ead79ed4f710d19"},
+ {file = "charset_normalizer-3.1.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:6734e606355834f13445b6adc38b53c0fd45f1a56a9ba06c2058f86893ae8017"},
+ {file = "charset_normalizer-3.1.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:f8303414c7b03f794347ad062c0516cee0e15f7a612abd0ce1e25caf6ceb47df"},
+ {file = "charset_normalizer-3.1.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:aaf53a6cebad0eae578f062c7d462155eada9c172bd8c4d250b8c1d8eb7f916a"},
+ {file = "charset_normalizer-3.1.0-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3dc5b6a8ecfdc5748a7e429782598e4f17ef378e3e272eeb1340ea57c9109f41"},
+ {file = "charset_normalizer-3.1.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:e1b25e3ad6c909f398df8921780d6a3d120d8c09466720226fc621605b6f92b1"},
+ {file = "charset_normalizer-3.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0ca564606d2caafb0abe6d1b5311c2649e8071eb241b2d64e75a0d0065107e62"},
+ {file = "charset_normalizer-3.1.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b82fab78e0b1329e183a65260581de4375f619167478dddab510c6c6fb04d9b6"},
+ {file = "charset_normalizer-3.1.0-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:bd7163182133c0c7701b25e604cf1611c0d87712e56e88e7ee5d72deab3e76b5"},
+ {file = "charset_normalizer-3.1.0-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:11d117e6c63e8f495412d37e7dc2e2fff09c34b2d09dbe2bee3c6229577818be"},
+ {file = "charset_normalizer-3.1.0-cp311-cp311-musllinux_1_1_ppc64le.whl", hash = "sha256:cf6511efa4801b9b38dc5546d7547d5b5c6ef4b081c60b23e4d941d0eba9cbeb"},
+ {file = "charset_normalizer-3.1.0-cp311-cp311-musllinux_1_1_s390x.whl", hash = "sha256:abc1185d79f47c0a7aaf7e2412a0eb2c03b724581139193d2d82b3ad8cbb00ac"},
+ {file = "charset_normalizer-3.1.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:cb7b2ab0188829593b9de646545175547a70d9a6e2b63bf2cd87a0a391599324"},
+ {file = "charset_normalizer-3.1.0-cp311-cp311-win32.whl", hash = "sha256:c36bcbc0d5174a80d6cccf43a0ecaca44e81d25be4b7f90f0ed7bcfbb5a00909"},
+ {file = "charset_normalizer-3.1.0-cp311-cp311-win_amd64.whl", hash = "sha256:cca4def576f47a09a943666b8f829606bcb17e2bc2d5911a46c8f8da45f56755"},
+ {file = "charset_normalizer-3.1.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:0c95f12b74681e9ae127728f7e5409cbbef9cd914d5896ef238cc779b8152373"},
+ {file = "charset_normalizer-3.1.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:fca62a8301b605b954ad2e9c3666f9d97f63872aa4efcae5492baca2056b74ab"},
+ {file = "charset_normalizer-3.1.0-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:ac0aa6cd53ab9a31d397f8303f92c42f534693528fafbdb997c82bae6e477ad9"},
+ {file = "charset_normalizer-3.1.0-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:c3af8e0f07399d3176b179f2e2634c3ce9c1301379a6b8c9c9aeecd481da494f"},
+ {file = "charset_normalizer-3.1.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3a5fc78f9e3f501a1614a98f7c54d3969f3ad9bba8ba3d9b438c3bc5d047dd28"},
+ {file = "charset_normalizer-3.1.0-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:628c985afb2c7d27a4800bfb609e03985aaecb42f955049957814e0491d4006d"},
+ {file = "charset_normalizer-3.1.0-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:74db0052d985cf37fa111828d0dd230776ac99c740e1a758ad99094be4f1803d"},
+ {file = "charset_normalizer-3.1.0-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:1e8fcdd8f672a1c4fc8d0bd3a2b576b152d2a349782d1eb0f6b8e52e9954731d"},
+ {file = "charset_normalizer-3.1.0-cp37-cp37m-musllinux_1_1_ppc64le.whl", hash = "sha256:04afa6387e2b282cf78ff3dbce20f0cc071c12dc8f685bd40960cc68644cfea6"},
+ {file = "charset_normalizer-3.1.0-cp37-cp37m-musllinux_1_1_s390x.whl", hash = "sha256:dd5653e67b149503c68c4018bf07e42eeed6b4e956b24c00ccdf93ac79cdff84"},
+ {file = "charset_normalizer-3.1.0-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:d2686f91611f9e17f4548dbf050e75b079bbc2a82be565832bc8ea9047b61c8c"},
+ {file = "charset_normalizer-3.1.0-cp37-cp37m-win32.whl", hash = "sha256:4155b51ae05ed47199dc5b2a4e62abccb274cee6b01da5b895099b61b1982974"},
+ {file = "charset_normalizer-3.1.0-cp37-cp37m-win_amd64.whl", hash = "sha256:322102cdf1ab682ecc7d9b1c5eed4ec59657a65e1c146a0da342b78f4112db23"},
+ {file = "charset_normalizer-3.1.0-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:e633940f28c1e913615fd624fcdd72fdba807bf53ea6925d6a588e84e1151531"},
+ {file = "charset_normalizer-3.1.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:3a06f32c9634a8705f4ca9946d667609f52cf130d5548881401f1eb2c39b1e2c"},
+ {file = "charset_normalizer-3.1.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:7381c66e0561c5757ffe616af869b916c8b4e42b367ab29fedc98481d1e74e14"},
+ {file = "charset_normalizer-3.1.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3573d376454d956553c356df45bb824262c397c6e26ce43e8203c4c540ee0acb"},
+ {file = "charset_normalizer-3.1.0-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e89df2958e5159b811af9ff0f92614dabf4ff617c03a4c1c6ff53bf1c399e0e1"},
+ {file = "charset_normalizer-3.1.0-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:78cacd03e79d009d95635e7d6ff12c21eb89b894c354bd2b2ed0b4763373693b"},
+ {file = "charset_normalizer-3.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:de5695a6f1d8340b12a5d6d4484290ee74d61e467c39ff03b39e30df62cf83a0"},
+ {file = "charset_normalizer-3.1.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1c60b9c202d00052183c9be85e5eaf18a4ada0a47d188a83c8f5c5b23252f649"},
+ {file = "charset_normalizer-3.1.0-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:f645caaf0008bacf349875a974220f1f1da349c5dbe7c4ec93048cdc785a3326"},
+ {file = "charset_normalizer-3.1.0-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:ea9f9c6034ea2d93d9147818f17c2a0860d41b71c38b9ce4d55f21b6f9165a11"},
+ {file = "charset_normalizer-3.1.0-cp38-cp38-musllinux_1_1_ppc64le.whl", hash = "sha256:80d1543d58bd3d6c271b66abf454d437a438dff01c3e62fdbcd68f2a11310d4b"},
+ {file = "charset_normalizer-3.1.0-cp38-cp38-musllinux_1_1_s390x.whl", hash = "sha256:73dc03a6a7e30b7edc5b01b601e53e7fc924b04e1835e8e407c12c037e81adbd"},
+ {file = "charset_normalizer-3.1.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:6f5c2e7bc8a4bf7c426599765b1bd33217ec84023033672c1e9a8b35eaeaaaf8"},
+ {file = "charset_normalizer-3.1.0-cp38-cp38-win32.whl", hash = "sha256:12a2b561af122e3d94cdb97fe6fb2bb2b82cef0cdca131646fdb940a1eda04f0"},
+ {file = "charset_normalizer-3.1.0-cp38-cp38-win_amd64.whl", hash = "sha256:3160a0fd9754aab7d47f95a6b63ab355388d890163eb03b2d2b87ab0a30cfa59"},
+ {file = "charset_normalizer-3.1.0-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:38e812a197bf8e71a59fe55b757a84c1f946d0ac114acafaafaf21667a7e169e"},
+ {file = "charset_normalizer-3.1.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:6baf0baf0d5d265fa7944feb9f7451cc316bfe30e8df1a61b1bb08577c554f31"},
+ {file = "charset_normalizer-3.1.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:8f25e17ab3039b05f762b0a55ae0b3632b2e073d9c8fc88e89aca31a6198e88f"},
+ {file = "charset_normalizer-3.1.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3747443b6a904001473370d7810aa19c3a180ccd52a7157aacc264a5ac79265e"},
+ {file = "charset_normalizer-3.1.0-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:b116502087ce8a6b7a5f1814568ccbd0e9f6cfd99948aa59b0e241dc57cf739f"},
+ {file = "charset_normalizer-3.1.0-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:d16fd5252f883eb074ca55cb622bc0bee49b979ae4e8639fff6ca3ff44f9f854"},
+ {file = "charset_normalizer-3.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:21fa558996782fc226b529fdd2ed7866c2c6ec91cee82735c98a197fae39f706"},
+ {file = "charset_normalizer-3.1.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:6f6c7a8a57e9405cad7485f4c9d3172ae486cfef1344b5ddd8e5239582d7355e"},
+ {file = "charset_normalizer-3.1.0-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:ac3775e3311661d4adace3697a52ac0bab17edd166087d493b52d4f4f553f9f0"},
+ {file = "charset_normalizer-3.1.0-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:10c93628d7497c81686e8e5e557aafa78f230cd9e77dd0c40032ef90c18f2230"},
+ {file = "charset_normalizer-3.1.0-cp39-cp39-musllinux_1_1_ppc64le.whl", hash = "sha256:6f4f4668e1831850ebcc2fd0b1cd11721947b6dc7c00bf1c6bd3c929ae14f2c7"},
+ {file = "charset_normalizer-3.1.0-cp39-cp39-musllinux_1_1_s390x.whl", hash = "sha256:0be65ccf618c1e7ac9b849c315cc2e8a8751d9cfdaa43027d4f6624bd587ab7e"},
+ {file = "charset_normalizer-3.1.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:53d0a3fa5f8af98a1e261de6a3943ca631c526635eb5817a87a59d9a57ebf48f"},
+ {file = "charset_normalizer-3.1.0-cp39-cp39-win32.whl", hash = "sha256:a04f86f41a8916fe45ac5024ec477f41f886b3c435da2d4e3d2709b22ab02af1"},
+ {file = "charset_normalizer-3.1.0-cp39-cp39-win_amd64.whl", hash = "sha256:830d2948a5ec37c386d3170c483063798d7879037492540f10a475e3fd6f244b"},
+ {file = "charset_normalizer-3.1.0-py3-none-any.whl", hash = "sha256:3d9098b479e78c85080c98e1e35ff40b4a31d8953102bb0fd7d1b6f8a2111a3d"},
+]
+
+[[package]]
+name = "idna"
+version = "3.4"
+description = "Internationalized Domain Names in Applications (IDNA)"
+category = "main"
+optional = false
+python-versions = ">=3.5"
+files = [
+ {file = "idna-3.4-py3-none-any.whl", hash = "sha256:90b77e79eaa3eba6de819a0c442c0b4ceefc341a7a2ab77d7562bf49f425c5c2"},
+ {file = "idna-3.4.tar.gz", hash = "sha256:814f528e8dead7d329833b91c5faa87d60bf71824cd12a7530b5526063d02cb4"},
+]
+
+[[package]]
+name = "pynetbox"
+version = "7.0.1"
+description = "NetBox API client library"
+category = "main"
+optional = false
+python-versions = "*"
+files = [
+ {file = "pynetbox-7.0.1-py3-none-any.whl", hash = "sha256:712fecbf8a5c776eff4e0b16cd5ca49ee84327ff2bd1bf7fb1040b49f000e341"},
+ {file = "pynetbox-7.0.1.tar.gz", hash = "sha256:eba8b5153ca575bc45f39ade1119b9f0a218c83947f84c4bb2df7fc9de4ffa9a"},
+]
+
+[package.dependencies]
+requests = ">=2.20.0,<3.0"
+
+[[package]]
+name = "python-dotenv"
+version = "1.0.0"
+description = "Read key-value pairs from a .env file and set them as environment variables"
+category = "main"
+optional = false
+python-versions = ">=3.8"
+files = [
+ {file = "python-dotenv-1.0.0.tar.gz", hash = "sha256:a8df96034aae6d2d50a4ebe8216326c61c3eb64836776504fcca410e5937a3ba"},
+ {file = "python_dotenv-1.0.0-py3-none-any.whl", hash = "sha256:f5971a9226b701070a4bf2c38c89e5a3f0d64de8debda981d1db98583009122a"},
+]
+
+[package.extras]
+cli = ["click (>=5.0)"]
+
+[[package]]
+name = "requests"
+version = "2.28.2"
+description = "Python HTTP for Humans."
+category = "main"
+optional = false
+python-versions = ">=3.7, <4"
+files = [
+ {file = "requests-2.28.2-py3-none-any.whl", hash = "sha256:64299f4909223da747622c030b781c0d7811e359c37124b4bd368fb8c6518baa"},
+ {file = "requests-2.28.2.tar.gz", hash = "sha256:98b1b2782e3c6c4904938b84c0eb932721069dfdb9134313beff7c83c2df24bf"},
+]
+
+[package.dependencies]
+certifi = ">=2017.4.17"
+charset-normalizer = ">=2,<4"
+idna = ">=2.5,<4"
+urllib3 = ">=1.21.1,<1.27"
+
+[package.extras]
+socks = ["PySocks (>=1.5.6,!=1.5.7)"]
+use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"]
+
+[[package]]
+name = "urllib3"
+version = "1.26.15"
+description = "HTTP library with thread-safe connection pooling, file post, and more."
+category = "main"
+optional = false
+python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*"
+files = [
+ {file = "urllib3-1.26.15-py2.py3-none-any.whl", hash = "sha256:aa751d169e23c7479ce47a0cb0da579e3ede798f994f5816a74e4f4500dcea42"},
+ {file = "urllib3-1.26.15.tar.gz", hash = "sha256:8a388717b9476f934a21484e8c8e61875ab60644d29b9b39e11e4b9dc1c6b305"},
+]
+
+[package.extras]
+brotli = ["brotli (>=1.0.9)", "brotlicffi (>=0.8.0)", "brotlipy (>=0.6.0)"]
+secure = ["certifi", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "ipaddress", "pyOpenSSL (>=0.14)", "urllib3-secure-extra"]
+socks = ["PySocks (>=1.5.6,!=1.5.7,<2.0)"]
+
+[metadata]
+lock-version = "2.0"
+python-versions = "^3.11"
+content-hash = "4135825998043fdcea3674cc119324247b3de7379607a62979b5a8d392d615c4"
diff --git a/tools/dhcpns/pyproject.toml b/tools/dhcpns/pyproject.toml
new file mode 100644
index 0000000..5219168
--- /dev/null
+++ b/tools/dhcpns/pyproject.toml
@@ -0,0 +1,17 @@
+[tool.poetry]
+name = "dhcpns"
+version = "0.1.0"
+description = ""
+authors = ["Ole Mathias Heggem <olemathias.aa.heggem@gmail.com>"]
+readme = "README.md"
+
+[tool.poetry.dependencies]
+python = "^3.11"
+requests = "^2.28.2"
+pynetbox = "^7.0.1"
+python-dotenv = "^1.0.0"
+
+
+[build-system]
+requires = ["poetry-core"]
+build-backend = "poetry.core.masonry.api"