github.com/philhug/dnscontrol@v0.2.4-0.20180625181521-921fa9849001/cmd/convertzone/README.md (about) 1 # convertzone -- Converts a standard DNS zonefile into tsv, pretty, or DSL 2 3 This is a crude hack we put together to read a couple common zonefile 4 formats and output them in a few different formats. Current input 5 formats are BIND zonefiles and OctoDNS "config" YAML files. Current 6 output formats as BIND zonefiles, tab separated records, or a draft 7 DNSControl dnsconfig.js file. For dnsconfig.js, it does about 90% 8 of the work, but should be manually verified. 9 10 The primary purpose of this program is to convert BIND-style 11 zonefiles to DNSControl dnsconfig.js files. Nearly all DNS Service 12 providers include the ability to export records as a BIND-style zonefile. 13 This makes it easy to import DNS data from other systems into DNSControl. 14 Later OctoDNS input was added because we had the parser (as part of 15 the OctoDNS provider), so why not use it? 16 17 ## Building the software 18 19 Build the software and install in your personal bin: 20 21 ```cmd 22 $ cd cmd/convertzone 23 $ go build 24 $ cp convertzone ~/bin/. 25 ``` 26 27 28 ## Usage Overview 29 30 convertzone: Read and write DNS zone files. 31 32 convertzone [-in=INPUT] [-out=OUTPUT] zonename [filename] 33 34 Input format: 35 -in=bind BIND-style zonefiles (DEFAULT) 36 -in=octodns OctoDNS YAML "config" files. 37 38 Output format: 39 40 -out=dsl DNSControl DSL language (dnsconfig.js) (DEFAULT) 41 -out=tsv TAB-separated values 42 -out=pretty pretty-printed (BIND-style zonefiles) 43 44 zonename The FQDN of the zone name. 45 filename File to read (optional. Defaults to stdin) 46 47 The DSL output format is useful for creating the first 48 draft of your dnsconfig.js when importing zones from 49 other services. 50 51 The TSV format makes it easy to process a zonefile with 52 shell tools. 53 54 The PRETTY format is just a nice way to clean up a zonefile. 55 56 If no filename is specified, stdin is assumed. 57 Output is sent to stdout. 58 59 The zonename is required as it can not be guessed automatically from the input. 60 61 Example: 62 63 convertzone stackoverflow.com zone.stackoverflow.com >new/draft.js 64 65 66 ### -out=tsv: 67 68 This is useful for `awk` and other systems that expect a very 69 uniform set of input. 70 71 Example: Print all CNAMEs: 72 73 convertzone -out=tsv foo.com <zone.foo.com | awk '$4 == "CNAME" { print $1 " -> " $5 }' 74 75 76 ### -out=pretty: 77 78 This is useful for cleaning up a zonefile. It sorts the records, 79 moving SOA and NS records to the top of the zone; all other records 80 are alphabetically sorted; if a label has mutiple records, they are 81 listed in a logical (not numeric) order, multiple A records are 82 listed sorted by IP address, MX records are sorted by priority, 83 etc. Use `-ttl` to set a default TTL. 84 85 Example: Clean up a zone file: 86 87 convertzone -out=pretty foo.com <old/zone.foo.com >new/zone.foo.com 88 89 90 ### -out=dsl: 91 92 This is useful for generating your draft `dnsconfig.js` configuration. 93 The output can be appended to the `dnsconfig.js` file as a good first draft. 94 95 Example: Generate statements for a dnsconfig.js file: 96 97 convertzone -out=dsl foo.com <old/zone.foo.com >first-draft.js 98 99 Note: The conversion is not perfect. You'll need to manually clean 100 it up and insert it into `dnsconfig.js`. More instructions in the 101 DNSControl [migration doc]({site.github.url}}/migration).