github.com/teknogeek/dnscontrol/v2@v2.10.1-0.20200227202244-ae299b55ba42/docs/get-zones.md (about) 1 --- 2 layout: default 3 title: Get-Zones subcommand 4 --- 5 6 # get-zones (was "convertzone") 7 8 DNSControl has a stand-alone utility that will contact a provider, 9 download the records of one or more zones, and output them to a file 10 in a variety of formats. 11 12 The original purpose of this command is to help convert legacy domains 13 to DNScontrol (bootstrapping). Since bootstrapping can not depend on 14 `dnsconfig.js`, `get-zones` relies on command line parameters and 15 `creds.json` exclusively. 16 17 Syntax: 18 19 dnscontrol get-zones [command options] credkey provider zone [...] 20 21 --creds value Provider credentials JSON file (default: "creds.json") 22 --format value Output format: dsl pretty tsv nameonly (default: "pretty") 23 --out value Instead of stdout, write to this file 24 --ttl value Default TTL (0 picks the zone's most common TTL) (default: 0) 25 26 ARGUMENTS: 27 credkey: The name used in creds.json (first parameter to NewDnsProvider() in dnsconfig.js) 28 provider: The name of the provider (second parameter to NewDnsProvider() in dnsconfig.js) 29 zone: One or more zones (domains) to download; or "all". 30 31 FORMATS: 32 --format=dsl dnsconfig.js format (not perfect, but a decent first draft) 33 --format=nameonly Just print the zone names 34 --format=pretty BIND Zonefile format 35 --format=tsv TAB separated value (useful for AWK) 36 37 When using `tsv`, the columns are: 38 FQDN (the label with the domain) 39 ShortName (just the label, "@" if it is the naked domain) 40 TTL 41 Record Type (A, AAAA, CNAME, etc.) 42 Target and arguments (quoted like in a zonefile) 43 44 The --ttl flag applies to pretty and dsl formats. 45 46 EXAMPLES: 47 dnscontrol get-zones myr53 ROUTE53 example.com 48 dnscontrol get-zones gmain GANDI_V5 example.comn other.com 49 dnscontrol get-zones cfmain CLOUDFLAREAPI all 50 dnscontrol get-zones -format=tsv bind BIND example.com 51 dnscontrol get-zones -format=dsl -out=draft.js glcoud GCLOUD example.com`, 52 53 54 # Example commands 55 56 dnscontrol get-zone 57 58 # Developer Note 59 60 This command is not implemented for all providers. 61 62 To add this to a provider: 63 64 1. Document the feature 65 66 In the `*Provider.go` file, change the setting to implemented. 67 68 * OLD: ` providers.CanGetZones: providers.Unimplemented(),` 69 * NEW: ` providers.CanGetZones: providers.Can(),` 70 71 2. Update the docs 72 73 ``` 74 go generate 75 ``` 76 77 3. Implement the `GetZoneRecords` function 78 79 Find the `GetZoneRecords` function in the `*Provider.go` file. 80 81 If currently returns `fmt.Errorf("not implemented")`. 82 83 Instead, it should gather the records from the provider 84 and return them as a list of RecordConfig structs. 85 86 The code to do that already exists in `GetDomainCorrections`. 87 You should extract it into its own function (`GetZoneRecords`), rather 88 than having it be burried in the middle of `GetDomainCorrections`. 89 `GetDomainCorrections` should call `GetZoneRecords`. 90 91 Once that is done the `get-zone` subcommand should work. 92 93 4. Optionally implemement the `ListZones` function 94 95 If the `ListZones` function is implemented, the "all" special case 96 will be activated. In this case, listing a single zone named `all` 97 will query the provider for the list of zones. 98 99 (Technically what is happening is by implementing the `ListZones` 100 function, you are completing the `ZoneLister` interface for that 101 provider.)