2020-02-18 21:59:18 +08:00
|
|
|
|
|
|
|
!!! NOTE: This command has been replaced by the "dnscontrol get-zones"
|
|
|
|
!!! subcommand. It can do everything convertzone does and more, with
|
|
|
|
!!! fewer bugs. This command will be removed from the distribution soon.
|
|
|
|
|
2017-03-21 02:27:40 +08:00
|
|
|
# convertzone -- Converts a standard DNS zonefile into tsv, pretty, or DSL
|
|
|
|
|
2018-02-28 06:36:47 +08:00
|
|
|
This is a crude hack we put together to read a couple common zonefile
|
|
|
|
formats and output them in a few different formats. Current input
|
|
|
|
formats are BIND zonefiles and OctoDNS "config" YAML files. Current
|
|
|
|
output formats as BIND zonefiles, tab separated records, or a draft
|
|
|
|
DNSControl dnsconfig.js file. For dnsconfig.js, it does about 90%
|
|
|
|
of the work, but should be manually verified.
|
|
|
|
|
|
|
|
The primary purpose of this program is to convert BIND-style
|
|
|
|
zonefiles to DNSControl dnsconfig.js files. Nearly all DNS Service
|
|
|
|
providers include the ability to export records as a BIND-style zonefile.
|
|
|
|
This makes it easy to import DNS data from other systems into DNSControl.
|
|
|
|
Later OctoDNS input was added because we had the parser (as part of
|
|
|
|
the OctoDNS provider), so why not use it?
|
2017-08-05 23:59:35 +08:00
|
|
|
|
2017-04-14 00:46:47 +08:00
|
|
|
## Building the software
|
|
|
|
|
|
|
|
Build the software and install in your personal bin:
|
|
|
|
|
|
|
|
```cmd
|
2017-05-26 08:42:30 +08:00
|
|
|
$ cd cmd/convertzone
|
2017-04-14 00:46:47 +08:00
|
|
|
$ go build
|
|
|
|
$ cp convertzone ~/bin/.
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
## Usage Overview
|
|
|
|
|
2018-02-28 06:36:47 +08:00
|
|
|
convertzone: Read and write DNS zone files.
|
2017-03-21 02:27:40 +08:00
|
|
|
|
2018-02-28 06:36:47 +08:00
|
|
|
convertzone [-in=INPUT] [-out=OUTPUT] zonename [filename]
|
2017-03-21 02:27:40 +08:00
|
|
|
|
2018-02-28 06:36:47 +08:00
|
|
|
Input format:
|
|
|
|
-in=bind BIND-style zonefiles (DEFAULT)
|
|
|
|
-in=octodns OctoDNS YAML "config" files.
|
2017-03-21 02:27:40 +08:00
|
|
|
|
2018-02-28 06:36:47 +08:00
|
|
|
Output format:
|
2017-03-21 02:27:40 +08:00
|
|
|
|
2018-02-28 06:36:47 +08:00
|
|
|
-out=dsl DNSControl DSL language (dnsconfig.js) (DEFAULT)
|
|
|
|
-out=tsv TAB-separated values
|
|
|
|
-out=pretty pretty-printed (BIND-style zonefiles)
|
|
|
|
|
|
|
|
zonename The FQDN of the zone name.
|
|
|
|
filename File to read (optional. Defaults to stdin)
|
|
|
|
|
|
|
|
The DSL output format is useful for creating the first
|
|
|
|
draft of your dnsconfig.js when importing zones from
|
|
|
|
other services.
|
|
|
|
|
|
|
|
The TSV format makes it easy to process a zonefile with
|
|
|
|
shell tools.
|
|
|
|
|
|
|
|
The PRETTY format is just a nice way to clean up a zonefile.
|
|
|
|
|
|
|
|
If no filename is specified, stdin is assumed.
|
2017-03-21 02:27:40 +08:00
|
|
|
Output is sent to stdout.
|
|
|
|
|
Improve convertzone documentation (#54)
* NEW: convertzone/ Read BIND zone files, output records as DSL, TSV, or pretty-print.
* Refactored to be more gostyle.
* Fix buffering issue.
* Delete the hacky awk script.
* Linting.
* Lint and documentation fixes.
* DNSimple provider (#43)
* Implement a basic DNSimple provider.
Handles domain delegation as well as record create, update, and delete.
Note that this is completely untested at the moment. It’s so alpha it might burn your face off.
* Add some inline comments. Always use the StackExchange libs.
* Clean up dnsimple docs a little
* This will need to be changed before merging.
* Import the dnsimple dnscontrol package from its expected path
* Properly build the FQDN and implement record listing so create/update/delete are used correctly.
* Add support for overriding base URL to allow connection to sandbox.
* Vendor dnsimple-go and its dependencies.
* Remove unnecessary doc file.
* Use dnsutil.AddOrigin for combining record name and origin.
* Modifying dnsimple provider to pass tests
* NEW: convertzone/ Read BIND zone files, output records as DSL, TSV, o… (#49)
* NEW: convertzone/ Read BIND zone files, output records as DSL, TSV, or pretty-print.
* Refactored to be more gostyle.
* Fix buffering issue.
* Delete the hacky awk script.
* Linting.
* Update README.md
* Update README.md
* Update README.md
* Docs
2017-03-21 05:21:09 +08:00
|
|
|
The zonename is required as it can not be guessed automatically from the input.
|
|
|
|
|
2017-03-21 02:27:40 +08:00
|
|
|
Example:
|
|
|
|
|
2018-02-28 06:36:47 +08:00
|
|
|
convertzone stackoverflow.com zone.stackoverflow.com >new/draft.js
|
Improve convertzone documentation (#54)
* NEW: convertzone/ Read BIND zone files, output records as DSL, TSV, or pretty-print.
* Refactored to be more gostyle.
* Fix buffering issue.
* Delete the hacky awk script.
* Linting.
* Lint and documentation fixes.
* DNSimple provider (#43)
* Implement a basic DNSimple provider.
Handles domain delegation as well as record create, update, and delete.
Note that this is completely untested at the moment. It’s so alpha it might burn your face off.
* Add some inline comments. Always use the StackExchange libs.
* Clean up dnsimple docs a little
* This will need to be changed before merging.
* Import the dnsimple dnscontrol package from its expected path
* Properly build the FQDN and implement record listing so create/update/delete are used correctly.
* Add support for overriding base URL to allow connection to sandbox.
* Vendor dnsimple-go and its dependencies.
* Remove unnecessary doc file.
* Use dnsutil.AddOrigin for combining record name and origin.
* Modifying dnsimple provider to pass tests
* NEW: convertzone/ Read BIND zone files, output records as DSL, TSV, o… (#49)
* NEW: convertzone/ Read BIND zone files, output records as DSL, TSV, or pretty-print.
* Refactored to be more gostyle.
* Fix buffering issue.
* Delete the hacky awk script.
* Linting.
* Update README.md
* Update README.md
* Update README.md
* Docs
2017-03-21 05:21:09 +08:00
|
|
|
|
|
|
|
|
2018-02-28 06:36:47 +08:00
|
|
|
### -out=tsv:
|
Improve convertzone documentation (#54)
* NEW: convertzone/ Read BIND zone files, output records as DSL, TSV, or pretty-print.
* Refactored to be more gostyle.
* Fix buffering issue.
* Delete the hacky awk script.
* Linting.
* Lint and documentation fixes.
* DNSimple provider (#43)
* Implement a basic DNSimple provider.
Handles domain delegation as well as record create, update, and delete.
Note that this is completely untested at the moment. It’s so alpha it might burn your face off.
* Add some inline comments. Always use the StackExchange libs.
* Clean up dnsimple docs a little
* This will need to be changed before merging.
* Import the dnsimple dnscontrol package from its expected path
* Properly build the FQDN and implement record listing so create/update/delete are used correctly.
* Add support for overriding base URL to allow connection to sandbox.
* Vendor dnsimple-go and its dependencies.
* Remove unnecessary doc file.
* Use dnsutil.AddOrigin for combining record name and origin.
* Modifying dnsimple provider to pass tests
* NEW: convertzone/ Read BIND zone files, output records as DSL, TSV, o… (#49)
* NEW: convertzone/ Read BIND zone files, output records as DSL, TSV, or pretty-print.
* Refactored to be more gostyle.
* Fix buffering issue.
* Delete the hacky awk script.
* Linting.
* Update README.md
* Update README.md
* Update README.md
* Docs
2017-03-21 05:21:09 +08:00
|
|
|
|
|
|
|
This is useful for `awk` and other systems that expect a very
|
|
|
|
uniform set of input.
|
|
|
|
|
|
|
|
Example: Print all CNAMEs:
|
|
|
|
|
2018-02-28 06:36:47 +08:00
|
|
|
convertzone -out=tsv foo.com <zone.foo.com | awk '$4 == "CNAME" { print $1 " -> " $5 }'
|
Improve convertzone documentation (#54)
* NEW: convertzone/ Read BIND zone files, output records as DSL, TSV, or pretty-print.
* Refactored to be more gostyle.
* Fix buffering issue.
* Delete the hacky awk script.
* Linting.
* Lint and documentation fixes.
* DNSimple provider (#43)
* Implement a basic DNSimple provider.
Handles domain delegation as well as record create, update, and delete.
Note that this is completely untested at the moment. It’s so alpha it might burn your face off.
* Add some inline comments. Always use the StackExchange libs.
* Clean up dnsimple docs a little
* This will need to be changed before merging.
* Import the dnsimple dnscontrol package from its expected path
* Properly build the FQDN and implement record listing so create/update/delete are used correctly.
* Add support for overriding base URL to allow connection to sandbox.
* Vendor dnsimple-go and its dependencies.
* Remove unnecessary doc file.
* Use dnsutil.AddOrigin for combining record name and origin.
* Modifying dnsimple provider to pass tests
* NEW: convertzone/ Read BIND zone files, output records as DSL, TSV, o… (#49)
* NEW: convertzone/ Read BIND zone files, output records as DSL, TSV, or pretty-print.
* Refactored to be more gostyle.
* Fix buffering issue.
* Delete the hacky awk script.
* Linting.
* Update README.md
* Update README.md
* Update README.md
* Docs
2017-03-21 05:21:09 +08:00
|
|
|
|
|
|
|
|
2018-02-28 06:36:47 +08:00
|
|
|
### -out=pretty:
|
Improve convertzone documentation (#54)
* NEW: convertzone/ Read BIND zone files, output records as DSL, TSV, or pretty-print.
* Refactored to be more gostyle.
* Fix buffering issue.
* Delete the hacky awk script.
* Linting.
* Lint and documentation fixes.
* DNSimple provider (#43)
* Implement a basic DNSimple provider.
Handles domain delegation as well as record create, update, and delete.
Note that this is completely untested at the moment. It’s so alpha it might burn your face off.
* Add some inline comments. Always use the StackExchange libs.
* Clean up dnsimple docs a little
* This will need to be changed before merging.
* Import the dnsimple dnscontrol package from its expected path
* Properly build the FQDN and implement record listing so create/update/delete are used correctly.
* Add support for overriding base URL to allow connection to sandbox.
* Vendor dnsimple-go and its dependencies.
* Remove unnecessary doc file.
* Use dnsutil.AddOrigin for combining record name and origin.
* Modifying dnsimple provider to pass tests
* NEW: convertzone/ Read BIND zone files, output records as DSL, TSV, o… (#49)
* NEW: convertzone/ Read BIND zone files, output records as DSL, TSV, or pretty-print.
* Refactored to be more gostyle.
* Fix buffering issue.
* Delete the hacky awk script.
* Linting.
* Update README.md
* Update README.md
* Update README.md
* Docs
2017-03-21 05:21:09 +08:00
|
|
|
|
|
|
|
This is useful for cleaning up a zonefile. It sorts the records,
|
|
|
|
moving SOA and NS records to the top of the zone; all other records
|
|
|
|
are alphabetically sorted; if a label has mutiple records, they are
|
|
|
|
listed in a logical (not numeric) order, multiple A records are
|
|
|
|
listed sorted by IP address, MX records are sorted by priority,
|
|
|
|
etc. Use `-ttl` to set a default TTL.
|
|
|
|
|
|
|
|
Example: Clean up a zone file:
|
|
|
|
|
2018-02-28 06:36:47 +08:00
|
|
|
convertzone -out=pretty foo.com <old/zone.foo.com >new/zone.foo.com
|
Improve convertzone documentation (#54)
* NEW: convertzone/ Read BIND zone files, output records as DSL, TSV, or pretty-print.
* Refactored to be more gostyle.
* Fix buffering issue.
* Delete the hacky awk script.
* Linting.
* Lint and documentation fixes.
* DNSimple provider (#43)
* Implement a basic DNSimple provider.
Handles domain delegation as well as record create, update, and delete.
Note that this is completely untested at the moment. It’s so alpha it might burn your face off.
* Add some inline comments. Always use the StackExchange libs.
* Clean up dnsimple docs a little
* This will need to be changed before merging.
* Import the dnsimple dnscontrol package from its expected path
* Properly build the FQDN and implement record listing so create/update/delete are used correctly.
* Add support for overriding base URL to allow connection to sandbox.
* Vendor dnsimple-go and its dependencies.
* Remove unnecessary doc file.
* Use dnsutil.AddOrigin for combining record name and origin.
* Modifying dnsimple provider to pass tests
* NEW: convertzone/ Read BIND zone files, output records as DSL, TSV, o… (#49)
* NEW: convertzone/ Read BIND zone files, output records as DSL, TSV, or pretty-print.
* Refactored to be more gostyle.
* Fix buffering issue.
* Delete the hacky awk script.
* Linting.
* Update README.md
* Update README.md
* Update README.md
* Docs
2017-03-21 05:21:09 +08:00
|
|
|
|
|
|
|
|
2018-02-28 06:36:47 +08:00
|
|
|
### -out=dsl:
|
Improve convertzone documentation (#54)
* NEW: convertzone/ Read BIND zone files, output records as DSL, TSV, or pretty-print.
* Refactored to be more gostyle.
* Fix buffering issue.
* Delete the hacky awk script.
* Linting.
* Lint and documentation fixes.
* DNSimple provider (#43)
* Implement a basic DNSimple provider.
Handles domain delegation as well as record create, update, and delete.
Note that this is completely untested at the moment. It’s so alpha it might burn your face off.
* Add some inline comments. Always use the StackExchange libs.
* Clean up dnsimple docs a little
* This will need to be changed before merging.
* Import the dnsimple dnscontrol package from its expected path
* Properly build the FQDN and implement record listing so create/update/delete are used correctly.
* Add support for overriding base URL to allow connection to sandbox.
* Vendor dnsimple-go and its dependencies.
* Remove unnecessary doc file.
* Use dnsutil.AddOrigin for combining record name and origin.
* Modifying dnsimple provider to pass tests
* NEW: convertzone/ Read BIND zone files, output records as DSL, TSV, o… (#49)
* NEW: convertzone/ Read BIND zone files, output records as DSL, TSV, or pretty-print.
* Refactored to be more gostyle.
* Fix buffering issue.
* Delete the hacky awk script.
* Linting.
* Update README.md
* Update README.md
* Update README.md
* Docs
2017-03-21 05:21:09 +08:00
|
|
|
|
|
|
|
This is useful for generating your draft `dnsconfig.js` configuration.
|
|
|
|
The output can be appended to the `dnsconfig.js` file as a good first draft.
|
2017-04-14 00:46:47 +08:00
|
|
|
|
|
|
|
Example: Generate statements for a dnsconfig.js file:
|
|
|
|
|
2018-02-28 06:36:47 +08:00
|
|
|
convertzone -out=dsl foo.com <old/zone.foo.com >first-draft.js
|
2017-04-14 00:46:47 +08:00
|
|
|
|
|
|
|
Note: The conversion is not perfect. You'll need to manually clean
|
|
|
|
it up and insert it into `dnsconfig.js`. More instructions in the
|
2020-02-18 21:59:18 +08:00
|
|
|
DNSControl [migration doc]({site.github.url}}/migration).
|