{"id":37079645,"url":"https://github.com/francoismdj/netbox-kea-dhcp","last_synced_at":"2026-01-14T09:38:19.487Z","repository":{"id":152932587,"uuid":"625675375","full_name":"francoismdj/netbox-kea-dhcp","owner":"francoismdj","description":"Sync netbox to ISC Kea DHCP server","archived":false,"fork":false,"pushed_at":"2024-09-16T19:27:01.000Z","size":103,"stargazers_count":41,"open_issues_count":8,"forks_count":8,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-08-28T16:01:32.592Z","etag":null,"topics":["dhcp","dhcp-server","ipam","kea-dhcp","netbox","netbox-automation"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/francoismdj.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-09T20:50:12.000Z","updated_at":"2025-06-19T19:36:33.000Z","dependencies_parsed_at":null,"dependency_job_id":"f1f3c143-5981-447a-a044-dfadde78dcea","html_url":"https://github.com/francoismdj/netbox-kea-dhcp","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/francoismdj/netbox-kea-dhcp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francoismdj%2Fnetbox-kea-dhcp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francoismdj%2Fnetbox-kea-dhcp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francoismdj%2Fnetbox-kea-dhcp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francoismdj%2Fnetbox-kea-dhcp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/francoismdj","download_url":"https://codeload.github.com/francoismdj/netbox-kea-dhcp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francoismdj%2Fnetbox-kea-dhcp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28416120,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T08:38:59.149Z","status":"ssl_error","status_checked_at":"2026-01-14T08:38:43.588Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dhcp","dhcp-server","ipam","kea-dhcp","netbox","netbox-automation"],"created_at":"2026-01-14T09:38:18.932Z","updated_at":"2026-01-14T09:38:19.480Z","avatar_url":"https://github.com/francoismdj.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"netbox-kea-dhcp\n===============\n\n[![PyPI](https://img.shields.io/pypi/v/netbox-kea-dhcp)](https://pypi.org/project/netbox-kea-dhcp/)\n\nEnable use of [NetBox](https://github.com/netbox-community/netbox) as a subnet\nconfiguration source for [ISC Kea DHCP server](https://www.isc.org/kea/).\n\n`netbox-kea-dhcp` is a one-way sync daemon that exports NetBox prefixes, IP\nranges and IP addresses to respectively DHCP subnets, pools\nand host reservations. It listens for NetBox webhook events, and each time a\nchange occured, it queries NetBox for the full changed data and update Kea\nthrought its API.\n\nThe program has two modes of operation:\n\n- Full sync at program startup: overwrite current DHCP subnets with new ones\n  exported from NetBox.\n- Continuous event-driven sync: listen for NetBox webhook events and update\n  DHCP configuration accordingly.\n\nKey features\n------------\n\n- Automatic sync from Netbox to Kea DHCP with virtualy no delay.\n- Update Kea configuration throught its control agent API: no direct\n  configuration file overwrites, let’s the control agent manage the runtime\n  and permanent configuration.\n- Only use open source Kea API commands (no ISC paid subscription required).\n- Submit new exported configuration to Kea check before applying it to runtime\n  configuration.\n- Query NetBox only for the objects concerned by the event (incremental\n  sync).\n- Get all NetBox data throught the well maintained\n  [`pynetbox`](https://github.com/netbox-community/pynetbox) library: unique\n  interface, loose dependency with NetBox internals (only with its API),\n  reduced code to maintain.\n- Customizable NetBox query filters.\n- Customizable mapping between Netbox object attributes and DHCP settings.\n\nRequirements\n------------\n\nPython: \u003e= 3.8 (tested on 3.10 but may works down to 3.8).\n\nNetbox: validated on API version 3.4.\n\nISC Kea DHCP: validated on version 2.2.0.\n\nInstall\n-------\n\n### With pip\n\n`netbox-kea-dhcp` is available on\n[PyPi](https://pypi.org/project/netbox-kea-dhcp/) and can be installed\nwith `pip install netbox-kea-dhcp`.\n\n### With pipx\n\nA convenient way is to use [pipx](https://pypa.github.io/pipx/) to install the\napplication in an isolated environnement.\n\nInstall `pipx` (below is for Linux, see\n[pipx homepage](https://pypa.github.io/pipx/) for other systems):\n\n```sh\npython3 -m pip install --user pipx\npython3 -m pipx ensurepath\n```\n\nInstall `netbox-kea-dhcp` from PyPi in a isolated environnement:\n\n```sh\npipx install netbox-kea-dhcp\n```\n\nRun:\n\n```\nnetbox-kea-dhcp --help\n```\n\nQuick start\n-----------\n\nSync at startup then listen for netbox events:\n```sh\nnetbox-kea-dhcp --netbox-url http://netbox-host \\\n    --netbox-token 0123456789ABCDEF \\\n    --kea-url http://kea-api-host --sync-now --listen -v\n```\n\nThe default mapping between netbox and Kea is:\n\n- prefixes are exported to subnets.\n- IP ranges are exported to pools. Custom status value `dhcp` may have to be\n  created in netbox configuration file ([netbox-community/netbox#8054](https://github.com/netbox-community/netbox/issues/8054)):\n  ```python\n  FIELD_CHOICES = {\n    'ipam.IPRange.status+': (\n        ('dhcp', 'DHCP', 'red'),\n    )\n  }\n  ```\n   \n- IP Addresses are exported to reservations. Hardware address is mapped with IP\n  address custom field `dhcp_reservation_hw_address` if it exists and is non\n  null, otherwise it is mapped with the MAC address of the assigned object.\n\nAt least one Netbox webhook needs to be configured for event listening. It has\nto notify all actions on DHCP-relevant objects:\n\n- Content types:\n  * `IPAM`: `Prefix`, `IP Range`, `IP addresse`.\n  * `DCIM`: `Interface`, `Device`.\n  * `Virtualization`: `Interface`, `Virtual Machine`.\n- Events: `Creations`, `Updates`, `Deletions`.\n- HTTP Request:\n  * URL: `http://{netbox-connector-host}:{port}/event/{free-text}/`\n  * HTTP Method: `POST`.\n\nThe field `free-text` is necessary to define several webhooks with same events.\nThe connector only uses it in logs.\n\nMore help with `netbox-kea-dhcp --help` and in the configuration file example\nunder `examples/` (or under\n`~/.local/pipx/venvs/netbox-kea-dhcp/lib/python3.10/site-packages/examples/` if\napp was installed with pipx).\n\nRecommended Netbox webhooks\n---------------------------\n\nSysadmins should set several webhooks with conditions and restricted body\ntemplate, in order to filter events and avoid unecessary network and CPU load.\n\nBelow is a recommended webhook set-up. It assumes that DHCP hardware addresses\nare apped with netbox interface MAC addresses. If interfaces are not used\n(i.e. hardware addresses are only mapped with a custom field defined in netbox\nIP addresses), webhooks on (vm) interfaces, (virtual) devices are not needed.\n\nCommon to all webhooks:\n\n- HTTP Request:\n  * URL: `http://{netbox-connector-host}:{port}/event/{optional-free-text}/`\n  * HTTP Method: `POST`.\n- Body template:\n\n    ```json\n    { \"event\": \"{{ event }}\",\n      \"model\": \"{{ model }}\",\n      \"data\": { \"id\": {{ data[\"id\"] }} }\n    }\n    ```\n\nWebhook 1:\n\n- Content types: `IPAM \u003e Prefix`, `IPAM \u003e IP Range`, `IPAM \u003e IP Address`,\n  `DCIM \u003e Device`, `DCIM \u003e Interface`, `Virtualization \u003e Virtual Machine`,\n  `Virtualization \u003e Interface`.\n- Events: `Updates`\n- Conditions: none\n\nWebhook 2:\n\n- Content types: `IPAM \u003e IP Address`\n- Events: `Creations`, `Deletions`\n- Conditions:\n\n    ```json\n    { \"and\": [ { \"attr\": \"status.value\", \"value\": \"dhcp\" } ] }\n    ```\n\nWebhook 3:\n\n- Content types: `IPAM \u003e IP Range`\n- Events: `Creations`, `Deletions`\n- Conditions (note: you may have to customize status values to add `dhcp`):\n\n    ```json\n    { \"and\": [ { \"attr\": \"status.value\", \"value\": \"dhcp\"} ] }\n    ```\n\nWebhook 4:\n\n- Content types: `IPAM \u003e Prefix`\n- Events: `Creations`, `Deletions`\n- Conditions: none, or a custom field\n\n    ```json\n    { \"and\": [ { \"attr\": \"custom_fields.dhcp_enabled\", \"value\": true } ] }\n    ```\n\nIt’s also recommended to set a TLS-enabled reverse proxy in front of\n`netbox-kea-dhcp`.\n\nLimitations\n-----------\n\n- When a change occured, the whole DHCP configuration is gotten from Kea,\n  modified, and sent back. It may put some stress on the DHCP server in case of\n  frequent changes. This is a limitation of Kea open source commands. A better\n  update granularity would require an ISC paid subscription.\n- When Kea URI is of the form `file:///path/to/kea-config`, config is written\n  to the file in an unsafe manner: if the write fails, the file will be\n  inconsistent. This is because the file feature is intended for tests.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrancoismdj%2Fnetbox-kea-dhcp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffrancoismdj%2Fnetbox-kea-dhcp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrancoismdj%2Fnetbox-kea-dhcp/lists"}