modified: README.md
This commit is contained in:
1 parent
86457cc858
commit
8c1e9502f4
1 file changed
+114
-39
@@ -1,30 +1,39 @@
|
|||||||
# Netbox Bind Provisioner
|
# Netbox Bind Provisioner
|
||||||
A Netbox Plugin that provides a minimal DNS Server for the automatic
|
A NetBox plugin that implements a lightweight DNS server to automate the
|
||||||
provisioning of a Bind9 Server from Netbox DNS data (netbox-plugin-dns).
|
provisioning and configuration of a BIND9 server based on DNS records
|
||||||
|
maintained in NetBox. (netbox-plugin-dns).
|
||||||
|
|
||||||
## Plugin configuration
|
## Plugin configuration
|
||||||
The plugin was re-worked; Instead of exporting zone files, it provides an
|
The plugin has been reworked: instead of exporting zone files, it now provides
|
||||||
entire (though minimal) DNS Server that is fed directly from Netbox's DNS data.
|
a minimal DNS server that is fed directly from NetBox’s DNS data. This server
|
||||||
The Server also provides specialized "catalog" zones that bind uses to
|
also exposes specialized catalog zones that BIND uses to automatically discover
|
||||||
automatically discover new zones and remove deleted ones. The plugin supports
|
newly created zones and remove deleted ones. The plugin supports BIND views and
|
||||||
view as well as basic dns security using TSIG.
|
basic DNS security via TSIG.
|
||||||
|
|
||||||
To work correctly, each view needs a tsig key installed and the
|
The plugin exposes one catalog zone per view. Each catalog zone is available
|
||||||
bind-transfer-endpoint needs to be running as its own service in the background
|
under the special zone name **"catz"** and can be queried through the built-in
|
||||||
via the `manage.py` command. Note that dnssec support will be implemented as
|
DNS server like any other zone.
|
||||||
soon as bind9 has a mechanism to allow configuration of such via the Catalog
|
|
||||||
Zones mechanism.
|
|
||||||
|
|
||||||
|
For proper operation, each view requires an installed TSIG key, and the
|
||||||
|
`bind-transfer-endpoint` must be running as a separate background service using
|
||||||
|
the `manage.py` command. Note that DNSSEC support will be added once BIND9
|
||||||
|
provides a mechanism to configure it through the Catalog Zones system.
|
||||||
|
|
||||||
|
To start the service:
|
||||||
```
|
```
|
||||||
manage.py bind-transfer-endpoint --port 5354
|
manage.py bind-transfer-endpoint --port 5354
|
||||||
```
|
```
|
||||||
|
|
||||||
The plugin also currently needs a file that tracks the current state of the
|
The plugin currently requires a file to track the SOA serial of the catalog zone.
|
||||||
catalog zone's SOA serial. The serial represents the catalog zone's SOA record
|
This serial represents the SOA record’s version number and allows downstream
|
||||||
serial number and is used by downstream DNS Servers to determine if the catalog
|
DNS servers to determine when the catalog zone has changed (for example,
|
||||||
zone was updated (e.g. if a zone is added/modified/removed from netbox).
|
when a zone is added, modified, or removed in NetBox). The file ensures the
|
||||||
The file is used to persist the SOA record's serial across service restarts.
|
serial persists across service restarts. It will be replaced with a
|
||||||
It will be replaced by a database entry once the plugin has its own models.
|
database-backed value once the plugin introduces its own models.
|
||||||
|
|
||||||
|
When configuring the plugin, you need to provide a path on the filesystem for
|
||||||
|
this file where the plugin can create and manage it. Please do not update it by
|
||||||
|
hand or remove it unless you know what you are doing.
|
||||||
|
|
||||||
### Service parameters
|
### Service parameters
|
||||||
Parameter | Description
|
Parameter | Description
|
||||||
@@ -38,44 +47,108 @@ Setting | Description
|
|||||||
catalog_serial_file | The catalog serial counter. The file needs to be writable.
|
catalog_serial_file | The catalog serial counter. The file needs to be writable.
|
||||||
tsig_keys | Maps a TSIG Key to be used for each view.
|
tsig_keys | Maps a TSIG Key to be used for each view.
|
||||||
|
|
||||||
### Plugin example configuration
|
## Installation guide
|
||||||
|
This setup provisions a BIND9 server directly with DNS data from NetBox.
|
||||||
|
BIND9 can optionally run on a separate server. If so, any reference to
|
||||||
|
127.0.0.1 in step 6 must be replaced with the IP address of the NetBox host.
|
||||||
|
TCP and UDP traffic from the BIND9 server to the NetBox host must be allowed on
|
||||||
|
port 5354 (or the port you have configured).
|
||||||
|
|
||||||
|
This guide assumes:
|
||||||
|
- Netbox has been installed under /opt/netbox
|
||||||
|
- Bind9 is installed on the same host as Netbox
|
||||||
|
- The Netbox DNS Plugin netbox-plugin-dns is installed
|
||||||
|
- The following dns views exist in Netbox DNS:
|
||||||
|
- `public` (the default)
|
||||||
|
- `private`
|
||||||
|
|
||||||
|
1. Preliminaries
|
||||||
|
- Install Bind9 on the same host that netbox is on.
|
||||||
|
- Generate a TSIG Key for the `public` and `private` dns views respectively.
|
||||||
|
|
||||||
|
2. Adding required package
|
||||||
|
```
|
||||||
|
cd netbox
|
||||||
|
echo netbox-plugin-bind-provisioner >> local_requirements.txt
|
||||||
|
. venv/bin/activate
|
||||||
|
pip install -r local_requirements.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Updating netbox plugin configuration (configuration.py)
|
||||||
|
Change following line from
|
||||||
|
```
|
||||||
|
PLUGINS = ['netbox_dns']
|
||||||
|
```
|
||||||
|
to
|
||||||
|
```
|
||||||
|
PLUGINS = ['netbox_dns', 'netbox_plugin_bind_provisioner']
|
||||||
|
```
|
||||||
|
|
||||||
|
Configure the Bind Exporter Plugin using the PLUGINS_CONFIG dictionary.
|
||||||
|
Change
|
||||||
|
```
|
||||||
|
PLUGINS_CONFIG = {}
|
||||||
|
```
|
||||||
|
to
|
||||||
```
|
```
|
||||||
PLUGINS_CONFIG = {
|
PLUGINS_CONFIG = {
|
||||||
"netbox_bind_provisioner": {
|
"netbox_bind_provisioner": {
|
||||||
"catalog_serial_file": "/opt/netbox/catalog-serial.txt",
|
"catalog_serial_file": "/opt/netbox/catalog-serial.txt",
|
||||||
"tsig_keys": {
|
"tsig_keys": {
|
||||||
"key1name": {
|
"public": {
|
||||||
"view": "public",
|
"keyname": "public_view_key",
|
||||||
"keyname": "view1key",
|
|
||||||
"algorithm": "hmac-sha256",
|
"algorithm": "hmac-sha256",
|
||||||
"secret": "base64-encoded-secret"
|
"secret": "base64-encoded-secret"
|
||||||
},
|
},
|
||||||
"key2name": {
|
"private": {
|
||||||
"view": "private",
|
"keyname": "private_view_key",
|
||||||
"keyname": "view2key",
|
|
||||||
"algorithm": "hmac-sha256",
|
"algorithm": "hmac-sha256",
|
||||||
"secret": "base64-encoded-secret"
|
"secret": "base64-encoded-secret"
|
||||||
}
|
}
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
Note that the tsig-key attributes keyname, algorithm and secret form a
|
||||||
|
dictionary in following python structure path:
|
||||||
|
```
|
||||||
|
PLUGINS_CONFIG.netbox_bind_provisioner.tsig_keys.<dns_view_name>
|
||||||
|
```
|
||||||
|
This allows the plugin to map requests to the right dns view using the tsig
|
||||||
|
signature from each request.
|
||||||
|
|
||||||
|
4. Run migrations (This step is not yet required. Just adding for completeness)
|
||||||
|
```
|
||||||
|
python3 netbox/manage.py migrate
|
||||||
```
|
```
|
||||||
|
|
||||||
## Bind example configuration
|
5. Start listener
|
||||||
|
This step runs the DNS endpoint used by bind to configure itself. You may want
|
||||||
|
to write a service wrapper that runs this in the background. Dont forget to
|
||||||
|
activate the venv if you do decide to run this service in the background.
|
||||||
|
Note that `--port 5354` is optional. The listener will bind this port
|
||||||
|
by default.
|
||||||
```
|
```
|
||||||
|
python3 netbox/manage.py bind-transfer-endpoint --port 5354
|
||||||
|
```
|
||||||
|
|
||||||
|
6. Configuring a Bind9 to interact with Netbox via the bind-transfer-endpoint
|
||||||
|
endpoint. Note that its not possible to give all the correct details of the
|
||||||
|
`options` block as it is heavily dependent on the Operating System used.
|
||||||
|
Please dont forget to adjust as required.
|
||||||
|
|
||||||
|
```
|
||||||
|
########## OPTIONS ##########
|
||||||
|
|
||||||
options {
|
options {
|
||||||
...
|
|
||||||
...
|
|
||||||
allow-update { none; };
|
allow-update { none; };
|
||||||
allow-query { any; };
|
allow-query { any; };
|
||||||
allow-recursion { none; };
|
allow-recursion { none; };
|
||||||
notify yes;
|
notify yes;
|
||||||
min-refresh-time 60;
|
min-refresh-time 60;
|
||||||
...
|
|
||||||
...
|
|
||||||
};
|
};
|
||||||
|
|
||||||
# ACLs
|
########## ACLs ##########
|
||||||
|
|
||||||
acl public {
|
acl public {
|
||||||
!10.0.0.0/8;
|
!10.0.0.0/8;
|
||||||
@@ -90,10 +163,10 @@ acl private {
|
|||||||
192.168.0.0/16;
|
192.168.0.0/16;
|
||||||
};
|
};
|
||||||
|
|
||||||
# Zone definitions
|
########## ZONES ##########
|
||||||
|
|
||||||
view "public" {
|
view "public" {
|
||||||
key "key1name" {
|
key "public_view_key" {
|
||||||
algorithm hmac-sha256;
|
algorithm hmac-sha256;
|
||||||
secret "base64-encoded-secret";
|
secret "base64-encoded-secret";
|
||||||
};
|
};
|
||||||
@@ -102,7 +175,7 @@ view "public" {
|
|||||||
|
|
||||||
catalog-zones {
|
catalog-zones {
|
||||||
zone "catz"
|
zone "catz"
|
||||||
default-masters { 127.0.0.1 port 5354 key "key1name"; }
|
default-masters { 127.0.0.1 port 5354 key "public_view_key"; }
|
||||||
zone-directory "/var/lib/bind/zones"
|
zone-directory "/var/lib/bind/zones"
|
||||||
min-update-interval 1;
|
min-update-interval 1;
|
||||||
};
|
};
|
||||||
@@ -110,13 +183,13 @@ view "public" {
|
|||||||
zone "catz" {
|
zone "catz" {
|
||||||
type slave;
|
type slave;
|
||||||
file "/var/lib/bind/zones/catz_public";
|
file "/var/lib/bind/zones/catz_public";
|
||||||
masters { 127.0.0.1 port 5354 key "key1name"; };
|
masters { 127.0.0.1 port 5354 key "public_view_key"; };
|
||||||
notify no;
|
notify no;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
view "private" {
|
view "private" {
|
||||||
key "key2name" {
|
key "private_view_key" {
|
||||||
algorithm hmac-sha256;
|
algorithm hmac-sha256;
|
||||||
secret "base64-encoded-secret";
|
secret "base64-encoded-secret";
|
||||||
};
|
};
|
||||||
@@ -125,7 +198,7 @@ view "private" {
|
|||||||
|
|
||||||
catalog-zones {
|
catalog-zones {
|
||||||
zone "catz"
|
zone "catz"
|
||||||
default-masters { 127.0.0.1 port 5354 key "key2name"; }
|
default-masters { 127.0.0.1 port 5354 key "private_view_key"; }
|
||||||
zone-directory "/var/lib/bind/zones"
|
zone-directory "/var/lib/bind/zones"
|
||||||
min-update-interval 1;
|
min-update-interval 1;
|
||||||
};
|
};
|
||||||
@@ -133,9 +206,11 @@ view "private" {
|
|||||||
zone "catz" {
|
zone "catz" {
|
||||||
type slave;
|
type slave;
|
||||||
file "/var/lib/bind/zones/catz_private";
|
file "/var/lib/bind/zones/catz_private";
|
||||||
masters { 127.0.0.1 port 5354 key "key2name"; };
|
masters { 127.0.0.1 port 5354 key "private_view_key"; };
|
||||||
notify no;
|
notify no;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
|
7. Restart bind - Done
|
||||||
|
|
||||||
Reference in new issue
Block a user