github.com/pmoroney/dnscontrol@v0.2.4-0.20171024134423-fad98f73f44a/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 BIND-style zonefile 4 and output a draft DNSControl dnsconfig.js file. It does about 90% 5 of the work, but it isn't complete. 6 7 ## Building the software 8 9 Build the software and install in your personal bin: 10 11 ```cmd 12 $ cd cmd/convertzone 13 $ go build 14 $ cp convertzone ~/bin/. 15 ``` 16 17 18 ## Usage Overview 19 20 convertzone converts an old-style DNS zone file into one of three formats: 21 22 convertzone [-mode=MODE] zonename [filename] 23 24 -mode=tsv Output the zone recoreds as tab-separated values 25 -mode=pretty Output the zone pretty-printed. 26 -mode=dsl Output the zone records as the DNSControl DSL language. 27 28 zonename The FQDN of the zone name. 29 filename File to read (optional. Defaults to stdin) 30 31 Output is sent to stdout. 32 33 The zonename is required as it can not be guessed automatically from the input. 34 35 Example: 36 37 convertzone stackoverflow.com zone.stackoverflow.com >new/stackoverflow.com 38 39 40 ### -mode=tsv: 41 42 This is useful for `awk` and other systems that expect a very 43 uniform set of input. 44 45 Example: Print all CNAMEs: 46 47 convertzone -mode=tsv foo.com <zone.foo.com | awk '$4 == "CNAME" { print $1 " -> " $5 }' 48 49 50 ### -mode=pretty: 51 52 This is useful for cleaning up a zonefile. It sorts the records, 53 moving SOA and NS records to the top of the zone; all other records 54 are alphabetically sorted; if a label has mutiple records, they are 55 listed in a logical (not numeric) order, multiple A records are 56 listed sorted by IP address, MX records are sorted by priority, 57 etc. Use `-ttl` to set a default TTL. 58 59 Example: Clean up a zone file: 60 61 convertzone -mode=pretty foo.com <old/zone.foo.com >new/zone.foo.com 62 63 64 ### -mode=dsl: 65 66 This is useful for generating your draft `dnsconfig.js` configuration. 67 The output can be appended to the `dnsconfig.js` file as a good first draft. 68 69 Example: Generate statements for a dnsconfig.js file: 70 71 convertzone -mode=dsl foo.com <old/zone.foo.com >first-draft.js 72 73 Note: The conversion is not perfect. You'll need to manually clean 74 it up and insert it into `dnsconfig.js`. More instructions in the 75 DNSControl [migration doc]({site.github.url}}/migration).