Skip to content

Commit ba962df

Browse files
committed
Master
1 parent e8e5d3a commit ba962df

5 files changed

Lines changed: 440 additions & 121 deletions

File tree

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
etc/*
2+
var/*
3+
bindtool*.json
4+
5+
*.pem
6+
*.zip
7+
*.orig
8+
*.sublime-*

README.md

Lines changed: 92 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,69 @@ This greatly simplifies keeping DNS zones current when keys change as no zone fi
1212
Requires Python3.4+ and the py3dns package.
1313
py3dns can be installed via:
1414

15-
pip install py3dns
16-
17-
or if you have both Python2 and Python3 installed:
18-
19-
pip3 install py3dns
15+
sudo pip3 install -r requirements.txt
2016

2117
Clone this repository or download the `bindtool` file and install it on your master DNS server.
2218
Optionally copy the `bindtool.example.json` file to `bindtool.json` in the installed directory and edit the configuration options.
2319

2420

21+
### Configuration
22+
23+
The example configuration file lists all possible options and their defaults.
24+
Only values that are different from the defaults need to be present.
25+
26+
The configuration file `bindtool.json` may be placed in the current working directory,
27+
in /etc/bindtool,
28+
or in the same directory as the bindtool tool is installed in.
29+
A different configuration file name may be specified on the command line.
30+
If the specified file name is not an absolute path,
31+
it will be searched for in the same locations,
32+
e.g. `bindtool --config config.json` will load `./config.json`, `/etc/bindtool/config.json`, or `<install-dir>/config.json`.
33+
The file must adhere to standard JSON format.
34+
35+
#### Defaults
36+
37+
The `defaults` section specifies the default values for all of the arguments for the various record commands.
38+
39+
For example, to change the default `expire` value for SOA records::
40+
41+
"defaults": {
42+
"soa": {
43+
"expire": "7d",
44+
}
45+
},
46+
...
47+
48+
49+
#### Directories
50+
51+
The `directories` section specifies the directories to find various file types in.
52+
53+
Directory values may include Python format strings for variable substitution.
54+
All directory types accept the {name} field.
55+
Certificate and private key directories also accept the {key_type}, {suffix}, and {username} fields.
56+
The dkim directory accepts the {selector} and {domain} fields.
57+
58+
59+
#### Key Type Suffixes
60+
61+
Each certificate and key file will have a suffix, just before the file extension,
62+
indicating the type of key the file is for.
63+
64+
The default suffix used for each key type can be overridden in the `key_type_suffixes` section.
65+
If you are only using a single key type, or want to omit the suffix from one key type,
66+
set it to an empty string.
67+
Note that if using multiple key types the suffix must be unique or files will be overridden.
68+
69+
70+
#### File Names
71+
72+
All output file names can be overridden using standard Python format strings.
73+
All file name types accept the {name} field.
74+
Certificate and private key file names also accept the {key_type}, {suffix}, and {username} fields.
75+
The dkim file name accepts the {selector} and {domain} fields.
76+
77+
2578
## Usage
2679

2780
Run the command:
@@ -71,7 +124,7 @@ Additional source files can be included via the following syntax:
71124
{{include:file_path}}
72125

73126
The file found at `file_path` will be included in the output as though the contents of that file were included inline.
74-
The file path is relative to the path of the file containing the `include` command.
127+
The file path is relative to the path of the file containing the `include` command or the configured `include` directory.
75128
Include files can include additional files.
76129
Variables defined in an include file are available for use in the file containing the `include` command at any point after the `include`.
77130

@@ -133,21 +186,26 @@ Becomes:
133186

134187
SSHFP records are specified as follows:
135188

136-
{{sshfp:hostname:key_file:ttl}}
189+
{{sshfp:hostname:key_file:ttl:type}}
137190

138191
All arguments are optional.
139192

140193
* `hostname` is the host name for the SSHFP record.
141194
The default value is `@`.
142195
* `key_file` is the name of the file the SSH host key files.
143-
The default value is `ssh_host`, note that key file names do not include the key type or file extension.
144-
If an absolute path is not specified, the path will be relative to `/etc/ssh` (may be changed in the config file).
196+
Key file names may be absolute or relative paths.
197+
If the file name is an absolute path, it will be used verbatim,
198+
otherwise the file path will be relative to the configured `ssh` directory (`/etc/ssh` by default)
199+
and the file name will be passed into the `ssh` file name format string, adding the key type and extension.
200+
The default value is `ssh_host`.
201+
If using an absolute path, the `type` must also be specified.
145202
* `ttl` is the TTL value for the SSHFP record.
146203
The default value is empty.
204+
* `type` is blank or one of the following: `rsa`, `dsa`, `ecdsa`, `ed25519`.
205+
If `type` is blank, SSHFP records will be generated for all key types for which public key files can be found,
206+
otherwise records for only the specified key type will be generated.
147207

148-
The following key types are recognized: `rsa`, `dsa`, `ecdsa`, and `ed25519`.
149208
Two SSHFP records will be generated for each key file that is present, one with a SHA1 digest and one with a SHA256 digest.
150-
Note that the expected key files must be named: `<key_file>_<key_type>_key.pub`, e.g.: `ssh_host_ecdsa_key.pub`
151209

152210
Example:
153211

@@ -173,9 +231,11 @@ The `port` argument is required, all others are optional.
173231
* `host` is the host name for the service.
174232
The default value is `@`.
175233
* `cert_file` is the file name of the certificate or private key used to secure the service.
234+
If the file name is an absolute path, it will be used verbatim,
235+
otherwise the file path will be relative to the configured `certificate`, `private_key`, `backup_key`, or `previous_key` directory
236+
and the file name will be passed into the correspoding file name format string.
237+
Private keys will be searched for in each of the key directories.
176238
The default value is the name of the source zone file.
177-
For certificate files the `.pem` file extension is optional, for private key files the `.key` file extension is optional.
178-
If an absolute path is not specified, the path for certificate files will be relative to `/etc/ssl/certs` and the path for private key files will be realtive to `/etc/ssl/private` (may be changed in the config file).
179239
* `usage` is one of the following: `pkix-ta`, `pkix-ee`, `dane-ta`, or `dane-ee`.
180240
The default value is `pkix-ee`.
181241
* `selector` is `cert`, or `spki`.
@@ -195,8 +255,8 @@ The default value is empty.
195255

196256
Two TLSA records will be generated for each available key type,
197257
one using a SHA256 digest and one using a SHA512 digest.
198-
When using the `spki` selector, the tool will additionally look for a backup key file using the file name of the `cert_file` + `_backup` (before the file extension, e.g. `example.com_backup.key`).
199-
If a backup key is found, additional TLSA records will be generated for the backup key.
258+
When using the `spki` selector, the tool will additionally look for backup and previous key files.
259+
If a backup or previous key is found, additional TLSA records will be generated for those keys.
200260

201261
Example:
202262

@@ -220,10 +280,12 @@ The `user` argument is required, all others are optional.
220280
* `host` is the host name for the email address.
221281
The default value is `@`.
222282
* `cert_file` is the file name of the certificate or private key used for S/MIME email for the user.
283+
If the file name is an absolute path, it will be used verbatim,
284+
otherwise the file path will be relative to the configured `certificate`, `private_key`, `backup_key`, or `previous_key` directory
285+
and the file name will be passed into the correspoding file name format string.
286+
Private keys will be searched for in each of the key directories.
223287
The default value is the name of the source zone file.
224-
The tool will first search for a certificate or private key file with the `user` argument + `@` prepended to the file name, e.g. {{smimea:user}} will search for `user@example.com`, then `example.com`.
225-
For certificate files the `.pem` file extension is optional, for private key files the `.key` file extension is optional.
226-
If an absolute path is not specified, the path for certificate files will be relative to `/etc/ssl/certs` and the path for private key files will be realtive to `/etc/ssl/private` (may be changed in the config file).
288+
By default the `user` argument + `@` will be prepended to the file name, e.g. {{smimea:user}} will search for `user@example.com.rsa.pem`, etc.
227289
* `usage` is one of the following: `pkix-ta`, `pkix-ee`, `dane-ta`, or `dane-ee`.
228290
The default value is `pkix-ee`.
229291
* `selector` is `cert`, or `spki`.
@@ -242,8 +304,8 @@ The default value is empty.
242304
Two SMIMEA records will be generated for each available key type,
243305
one using a SHA256 digest and one using a SHA512 digest.
244306
For `cert` selectors an additional record will be generated with the full contents of the certificate.
245-
When using the `spki` selector, the tool will additionally look for a backup key file using the file name of the `cert_file` + `_backup` (before the file extension, e.g. `example.com_backup.key`).
246-
If a backup key is found, additional SMIMEA records will be generated for the backup key.
307+
When using the `spki` selector, the tool will additionally look for backup and previous key files.
308+
If a backup or previous key is found, additional SMIMEA records will be generated for those keys.
247309

248310
Example:
249311

@@ -264,8 +326,10 @@ ACME Challenge (TXT) records are specified as follows:
264326
All arguments are optional.
265327

266328
* `challenge_file` is the file name of the json file storing ACME challenge information.
329+
If the file name is an absolute path, it will be used verbatim,
330+
otherwise the file path will be relative to the configured `acme` directory
331+
and the file name will be passed into the correspoding file name format string.
267332
The default value is the name of the source zone file.
268-
If an absolute path is not specified, the path will be relative to `/etc/ssl/challenges` (may be changed in the config file).
269333
* `ttl` is the TTL value for the TXT record.
270334
The default value is empty.
271335

@@ -288,12 +352,17 @@ Becomes:
288352

289353
DKIM (TXT) records are specified as follows:
290354

291-
{{dkim:domain:host:ttl}}
355+
{{dkim:selector:domain:host:ttl}}
292356

293357
All arguments are optional.
294358

359+
* `selector` is the DKIM selector.
360+
The default value is specified in the `settings` section of the config file.
295361
* `domain` is the name of the OpenDKIM private key.
296-
If an absolute path is not specified, the key will be in a path relative to `/etc/opendkim/keys` (may be changed in the config file) and in a file named `default.private`, e.g. `/etc/opendkim/<domain>/default.private`.
362+
If `domain` is an absolute path, it will be used verbatim,
363+
otherwise the file path will be relative to the configured `dkim` directory
364+
and the file name will be passed into the correspoding file name format string.
365+
The default value is the name of the source zone file.
297366
* `host` is the host name for the DKIM key.
298367
The default value is `@`
299368
* `ttl` is the TTL value for the TXT record.
@@ -308,7 +377,6 @@ Becomes:
308377
default._domainkey TXT "v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC2G8vw5hMce1Zy2ovLnBTEbXxiOqY/CsLu+uqlyMOdOjOGtQqx1wX2aXksazjEIQ3x5RfbuvRfVn/84W4J6WI90/a606veHHalQouXLfQIlu3QuTUkjsj+aldchivc/AI/wZNiIPrPR96UGIzBbSE9zGvwpQ23Z1LzGUXAsPKx1wIDAQAB"
309378

310379

311-
312380
### DMARC Records
313381

314382
DMARC (TXT) records are specified as follows:

0 commit comments

Comments
 (0)