github.com/teknogeek/dnscontrol/v2@v2.10.1-0.20200227202244-ae299b55ba42/cmd/convertzone/README.md (about)

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