# NetBox PowerDNS sync plugin
A [Netbox](https://github.com/netbox-community/netbox) plugin to manage
DNS records in PowerDNS based on netbox IP Address and Device objects.
## Features
- Automatically generates A, AAAA & PTR records based on IP Address & Device
objects and DNS zone settings
- Can manage multiple DNS Zones across multiple PowerDNS servers
- Flexible rules to match netbox IP Addresses into DNS zones
- Multiple options how to generate DNS name from IP address or Device
- Option to schedule sync of DNS zones from netbox to PowerDNS
- Can add DNS records for new zones immediately
- Setup synchronization schedule for each zone individually
## Generating DNS names
Each zone can define tags on IPAddress, Interface/VMInterface, FGRPGroup
or Device/VirtualMachine that match that zone. You can also match on
device role. A zone can also be only used for IPs that are assigned to management
only interfaces.
When determining the zone to use for an IP Address, match rules are evaluated
as follows:
- check if IPAddress.dns_name matches any zone
- check if IPAddress is assigned to Device or VirtualMachine and if its name
matches any zone
- check if IPAddress is assigned to FHRPGroup and if its name matches any zone
If no match is found then it will try to match based on assigned tags in this
order: IPAddress.tags, Interface.tags, VMInterface.tags, Device.tags,
VirtualMachine.tags, Device.device_role, VM.role.
If there is still not matching zone found, default zone is used (if set).
When a zone is set for an IP address, the DNS name is generated by using
set methods set on the zone. The IP naming method is tried first, then the
device and lastly the FHRP group method.
## Compatibility
This plugin requires netbox version 3.5.x to work. Here is s compatibility table:
| NetBox Version | Plugin Version |
|----------------|----------------|
| 3.5.0-7 | 0.0.1 - 0.0.6 |
| 3.5.8 | 0.0.7 |
| 3.6.x | 0.8.0 |
## Installing
Review [official Netbox plugin documentation](https://docs.netbox.dev/en/stable/plugins/#installing-plugins) for installation instructions.
You install the plugin from pypi with pip. Make sure you activate Netbox's virtual
environment first:
```bash
$ source /opt/netbox/venv/bin/activate
(venv) $ pip install netbox-powerdns-sync
```
For adding to a NetBox Docker setup see
[the general instructions for using netbox-docker with plugins](https://github.com/netbox-community/netbox-docker/wiki/Using-Netbox-Plugins).
You can install a development version directly from GitHub:
```bash
pip install git+https://github.com/ArnesSI/netbox-powerdns-sync.git@master
```
or by adding to your `local_requirements.txt` or `plugin_requirements.txt` (netbox-docker):
```bash
git+https://github.com/ArnesSI/netbox-powerdns-sync.git@master
```
After installation, enable the plugin in `/opt/netbox/netbox/netbox/configuration.py`,
or if you use netbox-docker, your `/configuration/plugins.py` file :
```python
PLUGINS = [
'netbox_powerdns_sync'
]
PLUGINS_CONFIG = {
"netbox_powerdns_sync": {},
}
```
Available configuration settings you can use in `PLUGINS_CONFIG` are described
below under [settings](#settings).
The last step is to apply database migrations and update netbox search index:
```bash
(venv) $ cd /opt/netbox/netbox/
(venv) $ python3 manage.py migrate
(venv) $ python3 manage.py reindex --lazy
```
If you're running under netbox-docker, you can skip this as migrations and index updates are applied if needed automatically when you bring up the containers.
## Settings
If you want to override the defaults for the plugin, you can do so in your via `/opt/netbox/netbox/netbox/configuration.py`,
or if you use netbox-docker, your `/configuration/plugins.py` file :
```python
PLUGINS = [
'netbox_powerdns_sync'
]
PLUGINS_CONFIG = {
"netbox_powerdns_sync": {
# Example settings below, see "Available settings"
# in README.md for all possible settings
"ttl_custom_field": "",
"powerdns_managed_record_comment": None,
| "post_save_enabled": False,
},
}
```
### Available settings
| Setting | Default value | Description |
|---------|---------------|-------------|
| `ttl_custom_field` | `None`| Name of netbox Custom field applied to IP Address objects. See [Custom TTL field](#custom-ttl-field) below. |
| `powerdns_managed_record_comment` | `"netbox-powerdns-sync"`| Is set, the plugin will only touch records in PowerDNS API that have matching comment and ignore others. Set to `None` to make plugin manage all supported records. |
| `post_save_enabled` | `False`| When creating or updating an IP Address, Device or FHRP Group, immediately create its DNS records using `post_save` signals. |
#### Custom TTL field
Normaly TTL for records is set by Default TTL on each Zone. There is an option to
set TTL for each DNS record individually. You need to define a netbox
[Custom field](https://docs.netbox.dev/en/stable/customization/custom-fields/)
of type integer and apply it to IP Address objects. Then set plugin option
`ttl_custom_field` to the name of that field.
![TTL custom field](docs/img/ttl_custom_field.png)
Now you can set TTL on each IP Address and any corresponding DNS records will get
that TTL value.
## Screenshots
List of DNS zones:
![DNS Zone list](docs/img/netbox_powerdns_sync-zone_list.png)
DNS Zone details:
![DNS Zone details](docs/img/netbox_powerdns_sync-zone_details.png)
Scheduling Zone sync:
![Sync schedule](docs/img/netbox_powerdns_sync-sync_schedule.png)
Sync results for Zone:
![Sync result](docs/img/netbox_powerdns_sync-sync_result.png)
Raw data
{
"_id": null,
"home_page": "https://github.com/ArnesSI/netbox-powerdns-sync/",
"name": "netbox-powerdns-sync",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": "",
"keywords": "netbox,netbox-plugin,powerdns",
"author": "Matej Vadnjal",
"author_email": "matej.vadnjal@arnes.si",
"download_url": "https://files.pythonhosted.org/packages/f0/45/40d3a79609cd3500a4336556ee63f0c06360f161d9fffc07b7851655a43e/netbox_powerdns_sync-0.0.8.tar.gz",
"platform": null,
"description": "# NetBox PowerDNS sync plugin\n\nA [Netbox](https://github.com/netbox-community/netbox) plugin to manage\nDNS records in PowerDNS based on netbox IP Address and Device objects.\n\n## Features\n\n- Automatically generates A, AAAA & PTR records based on IP Address & Device\n objects and DNS zone settings\n- Can manage multiple DNS Zones across multiple PowerDNS servers\n- Flexible rules to match netbox IP Addresses into DNS zones\n- Multiple options how to generate DNS name from IP address or Device\n- Option to schedule sync of DNS zones from netbox to PowerDNS\n- Can add DNS records for new zones immediately\n- Setup synchronization schedule for each zone individually\n\n## Generating DNS names\n\nEach zone can define tags on IPAddress, Interface/VMInterface, FGRPGroup\nor Device/VirtualMachine that match that zone. You can also match on\ndevice role. A zone can also be only used for IPs that are assigned to management\nonly interfaces. \n\nWhen determining the zone to use for an IP Address, match rules are evaluated\nas follows:\n\n- check if IPAddress.dns_name matches any zone\n- check if IPAddress is assigned to Device or VirtualMachine and if its name\n matches any zone\n- check if IPAddress is assigned to FHRPGroup and if its name matches any zone\n\nIf no match is found then it will try to match based on assigned tags in this\norder: IPAddress.tags, Interface.tags, VMInterface.tags, Device.tags,\nVirtualMachine.tags, Device.device_role, VM.role.\n\nIf there is still not matching zone found, default zone is used (if set).\n\nWhen a zone is set for an IP address, the DNS name is generated by using\nset methods set on the zone. The IP naming method is tried first, then the\ndevice and lastly the FHRP group method.\n\n## Compatibility\n\nThis plugin requires netbox version 3.5.x to work. Here is s compatibility table:\n\n| NetBox Version | Plugin Version |\n|----------------|----------------|\n| 3.5.0-7 | 0.0.1 - 0.0.6 |\n| 3.5.8 | 0.0.7 |\n| 3.6.x | 0.8.0 |\n\n## Installing\n\nReview [official Netbox plugin documentation](https://docs.netbox.dev/en/stable/plugins/#installing-plugins) for installation instructions.\n\nYou install the plugin from pypi with pip. Make sure you activate Netbox's virtual\nenvironment first:\n\n```bash\n$ source /opt/netbox/venv/bin/activate\n(venv) $ pip install netbox-powerdns-sync\n```\n\nFor adding to a NetBox Docker setup see\n[the general instructions for using netbox-docker with plugins](https://github.com/netbox-community/netbox-docker/wiki/Using-Netbox-Plugins).\n\nYou can install a development version directly from GitHub:\n\n```bash\npip install git+https://github.com/ArnesSI/netbox-powerdns-sync.git@master\n```\n\nor by adding to your `local_requirements.txt` or `plugin_requirements.txt` (netbox-docker):\n\n```bash\ngit+https://github.com/ArnesSI/netbox-powerdns-sync.git@master\n```\n\nAfter installation, enable the plugin in `/opt/netbox/netbox/netbox/configuration.py`,\n or if you use netbox-docker, your `/configuration/plugins.py` file :\n\n```python\nPLUGINS = [\n 'netbox_powerdns_sync'\n]\n\nPLUGINS_CONFIG = {\n \"netbox_powerdns_sync\": {},\n}\n```\n\nAvailable configuration settings you can use in `PLUGINS_CONFIG` are described\nbelow under [settings](#settings).\n\nThe last step is to apply database migrations and update netbox search index:\n\n```bash\n(venv) $ cd /opt/netbox/netbox/\n(venv) $ python3 manage.py migrate\n(venv) $ python3 manage.py reindex --lazy\n```\n\nIf you're running under netbox-docker, you can skip this as migrations and index updates are applied if needed automatically when you bring up the containers.\n\n## Settings\n\nIf you want to override the defaults for the plugin, you can do so in your via `/opt/netbox/netbox/netbox/configuration.py`,\n or if you use netbox-docker, your `/configuration/plugins.py` file :\n\n```python\nPLUGINS = [\n 'netbox_powerdns_sync'\n]\n\nPLUGINS_CONFIG = {\n \"netbox_powerdns_sync\": {\n # Example settings below, see \"Available settings\"\n # in README.md for all possible settings\n \"ttl_custom_field\": \"\",\n \"powerdns_managed_record_comment\": None,\n| \"post_save_enabled\": False,\n },\n}\n```\n\n### Available settings\n\n| Setting | Default value | Description |\n|---------|---------------|-------------|\n| `ttl_custom_field` | `None`| Name of netbox Custom field applied to IP Address objects. See [Custom TTL field](#custom-ttl-field) below. |\n| `powerdns_managed_record_comment` | `\"netbox-powerdns-sync\"`| Is set, the plugin will only touch records in PowerDNS API that have matching comment and ignore others. Set to `None` to make plugin manage all supported records. |\n| `post_save_enabled` | `False`| When creating or updating an IP Address, Device or FHRP Group, immediately create its DNS records using `post_save` signals. |\n\n#### Custom TTL field\n\nNormaly TTL for records is set by Default TTL on each Zone. There is an option to\nset TTL for each DNS record individually. You need to define a netbox\n[Custom field](https://docs.netbox.dev/en/stable/customization/custom-fields/)\nof type integer and apply it to IP Address objects. Then set plugin option\n`ttl_custom_field` to the name of that field.\n\n![TTL custom field](docs/img/ttl_custom_field.png)\n\nNow you can set TTL on each IP Address and any corresponding DNS records will get\nthat TTL value.\n\n## Screenshots\n\nList of DNS zones:\n\n![DNS Zone list](docs/img/netbox_powerdns_sync-zone_list.png)\n\nDNS Zone details:\n\n![DNS Zone details](docs/img/netbox_powerdns_sync-zone_details.png)\n\nScheduling Zone sync:\n\n![Sync schedule](docs/img/netbox_powerdns_sync-sync_schedule.png)\n\nSync results for Zone:\n\n![Sync result](docs/img/netbox_powerdns_sync-sync_result.png)\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Sync DNS records in PowerDNS with NetBox",
"version": "0.0.8",
"project_urls": {
"Homepage": "https://github.com/ArnesSI/netbox-powerdns-sync/"
},
"split_keywords": [
"netbox",
"netbox-plugin",
"powerdns"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "7ea5f8a23f704f68f71bac9d1a4e3d0783616f4955553a47126e08488f15400c",
"md5": "478693e089e5ceb21fc3b143eb86035a",
"sha256": "fea1d6dd59ba56a03230456786ca169bf470a989ad753b374b3f9eaa9e2102a2"
},
"downloads": -1,
"filename": "netbox_powerdns_sync-0.0.8-py3-none-any.whl",
"has_sig": false,
"md5_digest": "478693e089e5ceb21fc3b143eb86035a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 36357,
"upload_time": "2023-10-24T07:18:29",
"upload_time_iso_8601": "2023-10-24T07:18:29.201088Z",
"url": "https://files.pythonhosted.org/packages/7e/a5/f8a23f704f68f71bac9d1a4e3d0783616f4955553a47126e08488f15400c/netbox_powerdns_sync-0.0.8-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "f04540d3a79609cd3500a4336556ee63f0c06360f161d9fffc07b7851655a43e",
"md5": "65d3c03e7733369131702c149c355586",
"sha256": "a56dabbc00c5fb9b1f31cb239db72f0e293e758b0591ccfcb0bf118ce9a9b55e"
},
"downloads": -1,
"filename": "netbox_powerdns_sync-0.0.8.tar.gz",
"has_sig": false,
"md5_digest": "65d3c03e7733369131702c149c355586",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 25561,
"upload_time": "2023-10-24T07:18:30",
"upload_time_iso_8601": "2023-10-24T07:18:30.637287Z",
"url": "https://files.pythonhosted.org/packages/f0/45/40d3a79609cd3500a4336556ee63f0c06360f161d9fffc07b7851655a43e/netbox_powerdns_sync-0.0.8.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-10-24 07:18:30",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ArnesSI",
"github_project": "netbox-powerdns-sync",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "netbox-powerdns-sync"
}