GithubHelp home page GithubHelp logo

octodns / octodns-bind Goto Github PK

View Code? Open in Web Editor NEW
5.0 5.0 8.0 163 KB

RFC compliant (Bind9) provider for octoDNS

License: MIT License

Shell 12.19% Python 75.90% Scilab 8.41% DIGITAL Command Language 3.50%

octodns-bind's Introduction

octoDNS Logo

DNS as code - Tools for managing DNS across multiple providers

In the vein of infrastructure as code octoDNS provides a set of tools & patterns that make it easy to manage your DNS records across multiple providers. The resulting config can live in a repository and be deployed just like the rest of your code, maintaining a clear history and using your existing review & workflow.

The architecture is pluggable and the tooling is flexible to make it applicable to a wide variety of use-cases. Effort has been made to make adding new providers as easy as possible. In the simple case that involves writing of a single class and a couple hundred lines of code, most of which is translating between the provider's schema and octoDNS's. More on some of the ways we use it and how to go about extending it below and in the /docs directory.

Table of Contents

Getting started

Workspace

Running through the following commands will install the latest release of octoDNS and set up a place for your config files to live. To determine if provider specific requirements are necessary see the providers table below.

$ mkdir dns
$ cd dns
$ python -m venv env
...
$ source env/bin/activate
# provider-specific-requirements would be things like: octodns-route53 octodns-azure
$ pip install octodns <provider-specific-requirements>
$ mkdir config

Installing a specific commit SHA

If you'd like to install a version that has not yet been released in a repeatable/safe manner you can do the following. In general octoDNS is fairly stable in between releases thanks to the plan and apply process, but care should be taken regardless.

$ pip install -e git+https://[email protected]/octodns/octodns.git@<SHA>#egg=octodns

Config

We start by creating a config file to tell octoDNS about our providers and the zone(s) we want it to manage. Below we're setting up a YamlProvider to source records from our config files and both a Route53Provider and DynProvider to serve as the targets for those records. You can have any number of zones set up and any number of sources of data and targets for records for each. You can also have multiple config files, that make use of separate accounts and each manage a distinct set of zones. A good example of this this might be ./config/staging.yaml & ./config/production.yaml. We'll focus on a config/production.yaml.

Dynamic Zone Config

octoDNS supports dynamically building the list of zones it will work with when source providers support it. The most common use of this would be with YamlProvider and a single dynamic entry to in effect use the files that exist in the provider's directory as the source of truth. Other providers may support the list_zones method and be available to populate zones dynamically as well. This can be especially useful when using octodns-dump to create an initial setup from an existing provider.

An example config would look something like:

---
providers:
  config:
    class: octodns.provider.yaml.YamlProvider
    directory: ./config
    default_ttl: 3600
    enforce_order: True
  ns:
    class: octodns_ns1.Ns1Provider
    api_key: env/NS1_API_KEY
  route53:
    class: octodns_route53.Route53Provider
    access_key_id: env/AWS_ACCESS_KEY_ID
    secret_access_key: env/AWS_SECRET_ACCESS_KEY

zones:
  # This is a dynamic zone config. The source(s), here `config`, will be
  # queried for a list of zone names and each will dynamically be set up to
  # match the dynamic entry.
  '*':
    sources:
      - config
    targets:
      - ns1
      - route53

Static Zone Config

In cases where finer grained control is desired and the configuration of individual zones varies zones can be an explicit list with each configured zone listed along with its specific setup. As exemplified below alias zones can be useful when two zones are exact copies of each other, with the same configuration and records. YAML anchors are also helpful to avoid duplication where zones share config, but not records.

---
manager:
  include_meta: True
  max_workers: 2

providers:
  config:
    class: octodns.provider.yaml.YamlProvider
    directory: ./config
    default_ttl: 3600
    enforce_order: True
  ns:
    class: octodns_ns1.Ns1Provider
    api_key: env/NS1_API_KEY
  route53:
    class: octodns_route53.Route53Provider
    access_key_id: env/AWS_ACCESS_KEY_ID
    secret_access_key: env/AWS_SECRET_ACCESS_KEY

zones:
  example.com.: &dual_target
    sources:
      - config
    targets:
      - ns1
      - route53

  # these have the same setup as example.com., but will have their own files
  # in the configuration directory for records.
  third.tv.: *dual_target
  fourth.tv.: *dual_target

  example.net.:
    # example.net. is an exact copy of example.com., there will not be an
    # example.net.yaml file in the config directory as `alias` includes
    # duplicating the records of the aliased zone along with its config.
    alias: example.com.

  other.com.:
    lenient: True
    sources:
      - config
    targets:
      - ns1

General Configuration Concepts

class is a special key that tells octoDNS what python class should be loaded. Any other keys will be passed as configuration values to that provider. In general any sensitive or frequently rotated values should come from environmental variables. When octoDNS sees a value that starts with env/ it will look for that value in the process's environment and pass the result along.

Further information can be found in the docstring of each source and provider class.

The include_meta key in the manager section of the config controls the creation of a TXT record at the root of a zone that is managed by octoDNS. If set to True, octoDNS will create a TXT record for the root of the zone with the value provider=<target-provider>. If not specified, the default value for include_meta is False.

The max_workers key in the manager section of the config enables threading to parallelize the planning portion of the sync.

Quick Example Record

Now that we have something to tell octoDNS about our providers & zones we need to tell it about our records. We'll keep it simple for now and just create a single A record at the top-level of the domain.

config/example.com.yaml

---
'':
  ttl: 60
  type: A
  values:
    - 1.2.3.4
    - 1.2.3.5

Further information can be found in Records Documentation.

Noop

We're ready to do a dry-run with our new setup to see what changes it would make. Since we're pretending here we'll act like there are no existing records for example.com. in our accounts on either provider.

$ octodns-sync --config-file=./config/production.yaml
...
********************************************************************************
* example.com.
********************************************************************************
* route53 (Route53Provider)
*   Create <ARecord A 60, example.com., [u'1.2.3.4', '1.2.3.5']>
*   Summary: Creates=1, Updates=0, Deletes=0, Existing Records=0
* dyn (DynProvider)
*   Create <ARecord A 60, example.com., [u'1.2.3.4', '1.2.3.5']>
*   Summary: Creates=1, Updates=0, Deletes=0, Existing Records=0
********************************************************************************
...

There will be other logging information presented on the screen, but successful runs of sync will always end with a summary like the above for any providers & zones with changes. If there are no changes a message saying so will be printed instead. Above we're creating a new zone in both providers so they show the same change, but that doesn't always have to be the case. If, to start, one of them had a different state, you would see the changes octoDNS intends to make to sync them up.

Making changes

WARNING: octoDNS assumes ownership of any domain you point it to. When you tell it to act it will do whatever is necessary to try and match up states including deleting any unexpected records. Be careful when playing around with octoDNS. It's best to experiment with a fake zone or one without any data that matters until you're comfortable with the system.

Now it's time to tell octoDNS to make things happen. We'll invoke it again with the same options and add a --doit on the end to tell it this time we actually want it to try and make the specified changes.

$ octodns-sync --config-file=./config/production.yaml --doit
...

The output here would be the same as before with a few more log lines at the end as it makes the actual changes. After which the config in Route53 and Dyn should match what's in the yaml file.

Workflow

In the above case we manually ran octoDNS from the command line. That works and it's better than heading into the provider GUIs and making changes by clicking around, but octoDNS is designed to be run as part of a deploy process. The implementation details are well beyond the scope of this README, but here is an example of the workflow we use at GitHub. It follows the way GitHub itself is branch deployed.

The first step is to create a PR with your changes.

GitHub user interface of a pull request

Assuming the code tests and config validation statuses are green the next step is to do a noop deploy and verify that the changes octoDNS plans to make are the ones you expect.

Output of a noop deployment command

After that comes a set of reviews. One from a teammate who should have full context on what you're trying to accomplish and visibility into the changes you're making to do it. The other is from a member of the team here at GitHub that owns DNS, mostly as a sanity check and to make sure that best practices are being followed. As much of that as possible is baked into octodns-validate.

After the reviews it's time to branch deploy the change.

Output of a deployment command

If that goes smoothly, you again see the expected changes, and verify them with dig and/or octodns-report you're good to hit the merge button. If there are problems you can quickly do a .deploy dns/main to go back to the previous state.

Bootstrapping config files

Very few situations will involve starting with a blank slate which is why there's tooling built in to pull existing data out of providers into a matching config file.

$ octodns-dump --config-file=config/production.yaml --output-dir=tmp/ example.com. route53
2017-03-15T13:33:34  INFO  Manager __init__: config_file=tmp/production.yaml
2017-03-15T13:33:34  INFO  Manager dump: zone=example.com., sources=('route53',)
2017-03-15T13:33:36  INFO  Route53Provider[route53] populate:   found 64 records
2017-03-15T13:33:36  INFO  YamlProvider[dump] plan: desired=example.com.
2017-03-15T13:33:36  INFO  YamlProvider[dump] plan:   Creates=64, Updates=0, Deletes=0, Existing Records=0
2017-03-15T13:33:36  INFO  YamlProvider[dump] apply: making changes

The above command pulled the existing data out of Route53 and placed the results into tmp/example.com.yaml. That file can be inspected and moved into config/ to become the new source. If things are working as designed a subsequent noop sync should show zero changes.

Note that a Dynamic Zone Config and be really powerful in combination with octodns-dump allowing you to quickly create a set of octoDNS zone files for all the zones configured in your sources.

$ octodns-dump --config-file=config/production.yaml --output-dir=tmp/ '*' route53
...

It is important to review any WARNING log lines printed out during an octodns-dump invocation as it will give you information about records that aren't supported fully or at all by octoDNS and thus won't be exact matches or included in the dumps. Generally records that cannot be converted are either of a type that octoDNS does not support or those that include "dynamic" functionality that doesn't match octoDNS's behaviors.

Providers

The table below lists the providers octoDNS supports. They are maintained in their own repositories and released as independent modules.

Provider Module Notes
Akamai Edge DNS octodns_edgedns
Amazon Route 53 octodns_route53
Azure DNS octodns_azure
BIND, AXFR, RFC-2136 octodns_bind
Cloudflare DNS octodns_cloudflare
Constellix octodns_constellix
DigitalOcean octodns_digitalocean
DNS Made Easy octodns_dnsmadeeasy
DNSimple octodns_dnsimple
Dyn (deprecated) octodns_dyn
easyDNS octodns_easydns
EdgeCenter DNS octodns_edgecenter
/etc/hosts octodns_etchosts
Gandi octodns_gandi
G-Core Labs DNS octodns_gcore
Google Cloud DNS octodns_googlecloud
Hetzner DNS octodns_hetzner
Mythic Beasts DNS octodns_mythicbeasts
NS1 octodns_ns1
OVHcloud DNS octodns_ovh
PowerDNS octodns_powerdns
Rackspace octodns_rackspace
Scaleway octodns_scaleway
Selectel octodns_selectel
SPF Value Management octodns_spf
TransIP octodns_transip
UltraDNS octodns_ultra
YamlProvider built-in Supports all record types and core functionality

Updating to use extracted providers

  1. Include the extracted module in your python environment, e.g. if using Route53 that would require adding the octodns_route53 module to your requirements.txt, setup.py, or similar.
  2. Update the class value for your provider to the new path, e.g. again for Route53 that would be replacing octodns.provider.route53.Route53Provider with octodns_route53.Route53Provider

The module required and provider class path for extracted providers can be found in the table above.

Sources

Similar to providers, but can only serve to populate records into a zone, cannot be synced to.

Source Record Support Dynamic Notes
EnvVarSource TXT No read-only environment variable injection
AxfrSource A, AAAA, CAA, CNAME, LOC, MX, NS, PTR, SPF, SRV, TXT No read-only
ZoneFileSource A, AAAA, CAA, CNAME, MX, NS, PTR, SPF, SRV, TXT No read-only
TinyDnsFileSource A, CNAME, MX, NS, PTR No read-only

Notes

  • ALIAS support varies a lot from provider to provider care should be taken to verify that your needs are met in detail.
    • Dyn's UI doesn't allow editing or view of TTL, but the API accepts and stores the value provided, this value does not appear to be used when served
    • Dnsimple's uses the configured TTL when serving things through the ALIAS, there's also a secondary TXT record created alongside the ALIAS that octoDNS ignores
  • octoDNS itself supports non-ASCII character sets, but in testing Cloudflare is the only provider where that is currently functional end-to-end. Others have failures either in the client libraries or API calls

Processors

Processor Description
AcmeMangingProcessor Useful when processes external to octoDNS are managing acme challenge DNS records, e.g. LetsEncrypt
AutoArpa See Automatic PTR generation below
EnsureTrailingDots Processor that ensures ALIAS, CNAME, DNAME, MX, NS, PTR, and SRVs have trailing dots
ExcludeRootNsChanges Filter that errors or warns on planned root/APEX NS records changes.
IgnoreRootNsFilter Filter that IGNORES root/APEX NS records and prevents octoDNS from trying to manage them (where supported.)
MetaProcessor Adds a special meta record with timing, UUID, providers, and/or version to aid in debugging and monitoring.
NameAllowlistFilter Filter that ONLY manages records that match specified naming patterns, all others will be ignored
NameRejectlistFilter Filter that IGNORES records that match specified naming patterns, all others will be managed
ValueAllowlistFilter Filter that ONLY manages records that match specified value patterns based on rdata_text, all others will be ignored
ValueRejectlistFilter Filter that IGNORES records that match specified value patterns based on rdata_text, all others will be managed
OwnershipProcessor Processor that implements ownership in octoDNS so that it can manage only the records in a zone in sources and will ignore all others.
SpfDnsLookupProcessor Processor that checks SPF values for violations of DNS query limits
TtlRestrictionFilter Processor that restricts the allow TTL values to a specified range or list of specific values
TypeAllowlistFilter Filter that ONLY manages records of specified types, all others will be ignored
TypeRejectlistFilter Filter that IGNORES records of specified types, all others will be managed
octodns-spf SPF Value Management for octoDNS

Automatic PTR generation

octoDNS supports automatically generating PTR records from the A/AAAA records it manages. For more information see the auto-arpa documentation.

Compatibility and Compliance

lenient

lenient mostly focuses on the details of Records and standards compliance. When set to true octoDNS will allow non-compliant configurations & values where possible. For example CNAME values that don't end with a ., label length restrictions, and invalid geo codes on dynamic records. When in lenient mode octoDNS will log validation problems at WARNING and try and continue with the configuration or source data as it exists. See Lenience for more information on the concept and how it can be configured.

strict_supports

strict_supports is a Provider level parameter that comes into play when a provider has been asked to create a record that it is unable to support. The simplest case of this would be record type, e.g. SSHFP not being supported by AzureProvider. If such a record is passed to an AzureProvider as a target the provider will take action based on the strict_supports. When true it will throw an exception saying that it's unable to create the record, when set to false it will log at WARNING with information about what it's unable to do and how it is attempting to work around it. Other examples of things that cannot be supported would be dynamic records on a provider that only supports simple or the lack of support for specific geos in a provider, e.g. Route53Provider does not support NA-CA-*.

It is worth noting that these errors will happen during the plan phase of things so that problems will be visible without having to make changes.

This concept is currently a work in progress and only partially implemented. While work is on-going strict_supports will default to false. Once the work is considered complete & ready the default will change to true as it's a much safer and less surprising default as what you configure is what you'll get unless an error is thrown telling you why it cannot be done. You will then have the choice to explicitly request that things continue with work-arounds with strict_supports set to false. In the meantime it is encouraged that you manually configure the parameter to true in your provider configs.

Configuring strict_supports

The strict_supports parameter is available on all providers and can be configured in YAML as follows:

providers:
  someprovider:
    class: whatever.TheProvider
    ...
    strict_supports: true

Custom Sources and Providers

You can check out the source and provider directory to see what's currently supported. Sources act as a source of record information. AxfrSource and TinyDnsFileSource are currently the only OSS sources, though we have several others internally that are specific to our environment. These include something to pull host data from gPanel and a similar provider that sources information about our network gear to create both A & PTR records for their interfaces. Things that might make good OSS sources might include an ElbSource that pulls information about AWS Elastic Load Balancers and dynamically creates CNAMEs for them, or Ec2Source that pulls instance information so that records can be created for hosts similar to how our GPanelProvider works.

Most of the things included in octoDNS are providers, the obvious difference being that they can serve as both sources and targets of data. We'd really like to see this list grow over time so if you use an unsupported provider then PRs are welcome. The existing providers should serve as reasonable examples. Those that have no GeoDNS support are relatively straightforward. Unfortunately most of the APIs involved to do GeoDNS style traffic management are complex and somewhat inconsistent so adding support for that function would be nice, but is optional and best done in a separate pass.

The class key in the providers config section can be used to point to arbitrary classes in the python path so internal or 3rd party providers can easily be included with no coordination beyond getting them into PYTHONPATH, most likely installed into the virtualenv with octoDNS.

For examples of building third-party sources and providers, see Related Projects & Resources.

Other Uses

Syncing between providers

While the primary use-case is to sync a set of yaml config files up to one or more DNS providers, octoDNS has been built in such a way that you can easily source and target things arbitrarily. As a quick example the config below would sync githubtest.net. from Route53 to Dyn.

---
providers:
  route53:
    class: octodns.provider.route53.Route53Provider
    access_key_id: env/AWS_ACCESS_KEY_ID
    secret_access_key: env/AWS_SECRET_ACCESS_KEY
  dyn:
    class: octodns.provider.dyn.DynProvider
    customer: env/DYN_CUSTOMER
    username: env/DYN_USERNAME
    password: env/DYN_PASSWORD

zones:

  githubtest.net.:
    sources:
      - route53
    targets:
      - dyn

Dynamic sources

Internally we use custom sources to create records based on dynamic data that changes frequently without direct human intervention. An example of that might look something like the following. For hosts this mechanism is janitorial, run periodically, making sure the correct records exist as long as the host is alive and ensuring they are removed after the host is destroyed. The host provisioning and destruction processes do the actual work to create and destroy the records.

---
providers:
  gpanel-site:
    class: github.octodns.source.gpanel.GPanelProvider
    host: 'gpanel.site.github.foo'
    token: env/GPANEL_SITE_TOKEN
  powerdns-site:
    class: octodns.provider.powerdns.PowerDnsProvider
    host: 'internal-dns.site.github.foo'
    api_key: env/POWERDNS_SITE_API_KEY

zones:

  hosts.site.github.foo.:
    sources:
      - gpanel-site
    targets:
      - powerdns-site

Contributing

Please see our contributing document if you would like to participate!

Getting help

If you have a problem or suggestion, please open an issue in this repository, and we will do our best to help. Please note that this project adheres to the Contributor Covenant Code of Conduct.

Related Projects and Resources

If you know of any other resources, please do let us know!

License

octoDNS is licensed under the MIT license.

The MIT license grant is not for GitHub's trademarks, which include the logo designs. GitHub reserves all trademark and copyright rights in and to all GitHub trademarks. GitHub's logos include, for instance, the stylized designs that include "logo" in the file title in the following folder: https://github.com/octodns/octodns/tree/main/docs/logos/

GitHub® and its stylized versions and the Invertocat mark are GitHub's Trademarks or registered Trademarks. When using GitHub's logos, be sure to follow the GitHub logo guidelines.

Authors

octoDNS was designed and authored by Ross McFarland and Joe Williams. See https://github.com/octodns/octodns/graphs/contributors for a complete list of people who've contributed.

octodns-bind's People

Contributors

bessb avatar dependabot[bot] avatar floriankoenig-work avatar jcollie avatar jpmens avatar kabenin avatar kompetenzbolzen avatar ross avatar yzguy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

octodns-bind's Issues

No records found in ZoneFileSource

I'm trying to import a BIND format zone file which I use in NSD, and I keep on seeing the message:

INFO ZoneFileSource[nsd] populate: found 0 records

Please see below the full output, the config file and the source zone file.

(env) me@mypc ~/devel/xywz/dns.gerrit $ octodns-sync --debug --config-file=./config/lab.yml
2022-11-15T16:18:58  [140562631124800] INFO  Manager __init__: config_file=./config/lab.yml (octoDNS 0.9.21)
2022-11-15T16:18:58  [140562631124800] INFO  Manager _config_executor: max_workers=2
2022-11-15T16:18:58  [140562631124800] INFO  Manager _config_include_meta: include_meta=False
2022-11-15T16:18:58  [140562631124800] INFO  Manager __init__: global_processors=[]
2022-11-15T16:18:58  [140562631124800] DEBUG Manager _config_providers: configuring providers
2022-11-15T16:18:58  [140562631124800] DEBUG YamlProvider[config] __init__: id=config, directory=./zones, default_ttl=3600, enforce_order=1, populate_should_replace=0
2022-11-15T16:18:58  [140562631124800] DEBUG YamlProvider[config] __init__: id=config, apply_disabled=False, update_pcent_threshold=0.30, delete_pcent_threshold=0.30
2022-11-15T16:18:58  [140562631124800] INFO  Manager __init__: provider=config (octodns.provider.yaml 0.9.21)
2022-11-15T16:18:58  [140562631124800] DEBUG PowerDnsProvider[pdns] __init__: id=pdns, host=10.10.10.10, port=8081, nameserver_values=None, nameserver_ttl=None
2022-11-15T16:18:58  [140562631124800] DEBUG PowerDnsProvider[pdns] __init__: id=pdns, apply_disabled=False, update_pcent_threshold=0.30, delete_pcent_threshold=0.30
2022-11-15T16:18:58  [140562631124800] DEBUG PowerDnsProvider[pdns] _request: method=GET, path=
2022-11-15T16:18:58  [140562631124800] DEBUG urllib3.connectionpool Starting new HTTP connection (1): 10.10.10.10:8081
2022-11-15T16:18:58  [140562631124800] DEBUG urllib3.connectionpool http://10.10.10.10:8081 "GET /api/v1/servers/localhost HTTP/1.1" 200 325
2022-11-15T16:18:58  [140562631124800] DEBUG PowerDnsProvider[pdns] _request:   status=200
2022-11-15T16:18:58  [140562631124800] DEBUG PowerDnsProvider[pdns] powerdns_version: got version 4.6.2 from server
2022-11-15T16:18:58  [140562631124800] INFO  Manager __init__: provider=pdns (octodns_powerdns 0.0.2)
2022-11-15T16:18:58  [140562631124800] DEBUG ZoneFileSource[nsd] __init__: id=nsd, directory=./zones_from_nsd, file_extension=zone, check_origin=False
2022-11-15T16:18:58  [140562631124800] INFO  Manager __init__: provider=nsd (octodns_bind 0.0.1)
2022-11-15T16:18:58  [140562631124800] DEBUG AxfrSource[axfr] __init__: id=axfr, host=10.10.10.10, key_name=None, key_secret=False
2022-11-15T16:18:58  [140562631124800] INFO  Manager __init__: provider=axfr (octodns_bind 0.0.1)
2022-11-15T16:18:58  [140562631124800] INFO  Manager sync: eligible_zones=[], eligible_targets=[], dry_run=True, force=False, plan_output_fh=<stdout>
2022-11-15T16:18:58  [140562631124800] INFO  Manager sync:   zone=xywz.com.
2022-11-15T16:18:58  [140562631124800] INFO  Manager sync:   sources=['nsd'] -> targets=['config']
2022-11-15T16:18:58  [140562384914112] DEBUG Zone __init__: zone=Zone<xywz.com.>, sub_zones=set()
2022-11-15T16:18:58  [140562384914112] DEBUG Manager sync:   populating, zone=xywz.com., lenient=False
2022-11-15T16:18:58  [140562384914112] DEBUG ZoneFileSource[nsd] populate: name=xywz.com., target=False, lenient=False
2022-11-15T16:18:58  [140562384914112] INFO  ZoneFileSource[nsd] populate:   found 0 records
2022-11-15T16:18:58  [140562384914112] DEBUG Manager sync:   planning, zone=xywz.com.
2022-11-15T16:18:58  [140562384914112] INFO  YamlProvider[config] plan: desired=xywz.com.
2022-11-15T16:18:58  [140562384914112] DEBUG Zone __init__: zone=Zone<xywz.com.>, sub_zones=set()
2022-11-15T16:18:58  [140562384914112] DEBUG YamlProvider[config] populate: name=xywz.com., target=True, lenient=True
2022-11-15T16:18:58  [140562384914112] DEBUG Zone __init__: zone=Zone<xywz.com.>, sub_zones=set()
2022-11-15T16:18:58  [140562384914112] WARNING YamlProvider[config] root NS record supported, but no record is configured for xywz.com.
2022-11-15T16:18:58  [140562384914112] DEBUG Zone changes: zone=Zone<xywz.com.>, target=YamlProvider
2022-11-15T16:18:58  [140562384914112] INFO  YamlProvider[config] plan:   No changes
2022-11-15T16:18:58  [140562631124800] INFO  Plan 
********************************************************************************
No changes were planned
********************************************************************************

---
manager:
  include_meta: False
  max_workers: 2

providers:
  config:
    class: octodns.provider.yaml.YamlProvider
    directory: ./zones
    default_ttl: 3600
    enforce_order: True
  pdns:
    class: octodns_powerdns.PowerDnsProvider
    host: 10.10.10.10
    port: 8081
    api_key: "Thier7pheishieraerah7taef4rae4"
  nsd:
    class: octodns_bind.ZoneFileSource
    directory: ./zones_from_nsd
    file_extension: zone
    check_origin: false
  axfr:
    class: octodns_bind.AxfrSource
    host: 10.10.10.10
    #key_name: env/AXFR_KEY_NAME
    #key_secret: env/AXFR_KEY_SECRET

zones:
  xywz.com.:
    sources:
      - nsd
    targets:
      - config

$ORIGIN xywz.com.
portal		600	IN	A	11.11.11.11

AxfrProvider unable to dump when Host is a DNS name

Hello,

I cannot dump my current Microsoft AD zones to octodns configuration file.

cat config/ad.yaml
providers:                           
  ad:                              
      class: octodns_bind.AxfrSource 
      host: ad.example.org       
      port: 53
  config:
       class: octodns.provider.yaml.YamlProvider
       directory: ./config/zones                  
       default_ttl: 3600                        
       enforce_order: True                       
zones:
  example.org.:
    sources:
      - ad
    target:
      - config

Dumping the zone:

octodns-dump --debug --config-file=config/lady.yaml --output-dir=config/zones/ example.org. ad
2023-04-27T13:33:36  [139897537410880] INFO  Manager __init__: config_file=config/ad.yaml (octoDNS 0.9.21)
2023-04-27T13:33:36  [139897537410880] INFO  Manager _config_executor: max_workers=1
2023-04-27T13:33:36  [139897537410880] INFO  Manager _config_include_meta: include_meta=False                                                                                                                     2023-04-27T13:33:36  [139897537410880] INFO  Manager __init__: global_processors=[]
2023-04-27T13:33:36  [139897537410880] DEBUG Manager _config_providers: configuring providers
2023-04-27T13:33:36  [139897537410880] DEBUG AxfrSource[ad] __init__: id=ad, host=ad.example.org., port=53, key_name=None, key_secret=False, key_algorithm=False
2023-04-27T13:33:36  [139897537410880] INFO  Manager __init__: provider=ad (octodns_bind 0.0.2)
2023-04-27T13:33:36  [139897537410880] DEBUG YamlProvider[config] __init__: id=config, directory=./config, default_ttl=3600, enforce_order=1, populate_should_replace=0
2023-04-27T13:33:36  [139897537410880] DEBUG YamlProvider[config] __init__: id=config, apply_disabled=False, update_pcent_threshold=0.30, delete_pcent_threshold=0.30
2023-04-27T13:33:36  [139897537410880] INFO  Manager __init__: provider=config (octodns.provider.yaml 0.9.21)
2023-04-27T13:33:36  [139897537410880] INFO  Manager dump: zone=example.org., output_dir=zones/, output_provider=None, lenient=False, split=False, sources=['ad']
2023-04-27T13:33:36  [139897537410880] INFO  Manager dump: using custom YamlProvider
2023-04-27T13:33:36  [139897537410880] DEBUG YamlProvider[dump] __init__: id=dump, directory=zones/, default_ttl=3600, enforce_order=1, populate_should_replace=0
2023-04-27T13:33:36  [139897537410880] DEBUG YamlProvider[dump] __init__: id=dump, apply_disabled=False, update_pcent_threshold=0.30, delete_pcent_threshold=0.30
2023-04-27T13:33:36  [139897537410880] DEBUG Zone __init__: zone=Zone<example.org.>, sub_zones=set()
2023-04-27T13:33:36  [139897537410880] DEBUG AxfrSource[ad] populate: name=example.org., target=False, lenient=False
Traceback (most recent call last):
  File "/var/tmp/env/lib64/python3.11/site-packages/dns/inet.py", line 90, in af_for_address
    dns.ipv4.inet_aton(text)
  File "/var/tmp/env/lib64/python3.11/site-packages/dns/ipv4.py", line 57, in inet_aton
    raise dns.exception.SyntaxError
dns.exception.SyntaxError: Text input is malformed.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/var/tmp/env/lib64/python3.11/site-packages/dns/inet.py", line 95, in af_for_address
    dns.ipv6.inet_aton(text, True)
  File "/var/tmp/env/lib64/python3.11/site-packages/dns/ipv6.py", line 181, in inet_aton
    raise dns.exception.SyntaxError
dns.exception.SyntaxError: Text input is malformed.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/var/tmp/env/bin/octodns-dump", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/var/tmp/env/lib64/python3.11/site-packages/octodns/cmds/dump.py", line 48, in main
    manager.dump(
  File "/var/tmp/env/lib64/python3.11/site-packages/octodns/manager.py", line 755, in dump
    source.populate(zone, lenient=lenient)
  File "/var/tmp/env/lib64/python3.11/site-packages/octodns_bind/__init__.py", line 53, in populate
    rrs = self.zone_records(zone)
          ^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/tmp/env/lib64/python3.11/site-packages/octodns_bind/__init__.py", line 184, in zone_records
    z = dns.zone.from_xfr(
        ^^^^^^^^^^^^^^^^^^
  File "/var/tmp/env/lib64/python3.11/site-packages/dns/zone.py", line 1369, in from_xfr
    for r in xfr:
  File "/var/tmp/env/lib64/python3.11/site-packages/dns/query.py", line 1221, in xfr
   File "/var/tmp/env/lib64/python3.11/site-packages/dns/query.py", line 1221, in xfr
    (af, destination, source) = _destination_and_source(
                                ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/tmp/env/lib64/python3.11/site-packages/dns/query.py", line 221, in _destination_and_source
    af = dns.inet.af_for_address(where)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/tmp/env/lib64/python3.11/site-packages/dns/inet.py", line 98, in af_for_address
    raise ValueError
ValueError

I am able to correctly get an axfr using dig:

dig @ad.example.org -t axfr example.org
#truncated
;; Query time: 320 msec
;; SERVER: 10.33.0.100#53(ad.example.org) (TCP)
;; WHEN: Thu Apr 27 13:45:55 CEST 2023
;; XFR size: 8091 records (messages 16, bytes 261872)

Adding some print() into the code, the problematic record seems to be c5d1c200-2ce8-42b3-bde4-72aea693b480._msdcs.example.org 600 IN CNAME ad.example.org. although it seems valid to me.

Did I do anything wrong?

Unable to Perform Zone Transfer: The DNS query name does not exist: localhost

While looking into a test failure related to octodns/octodns#1004 I pulled the lasted code and tried to run tests, but got a failure to resolve localhost?

tests/test_provider_octodns_bind.py:28: in <module>
    class TestAxfrSource(TestCase):
tests/test_provider_octodns_bind.py:29: in TestAxfrSource
    source = AxfrSource('test', 'localhost')
octodns_bind/__init__.py:165: in __init__
    self.host = self._host(host)
octodns_bind/__init__.py:180: in _host
    raise AxfrSourceZoneTransferFailed(err) from None
E   octodns_bind.AxfrSourceZoneTransferFailed: Unable to Perform Zone Transfer: The DNS query name does not exist: localhost.

Guessing this is related to #22 and localhost isn't resolving when looked up on my computer/network. My first thought is to change the name there to an IP address...

It is not possible to put the port number in variable

Hi, thank you for the work it's really usefull for me to be able to update zones from our git repository 👍

I would like to use an env variable to set the port for the DNS. But with this configuration a have an error :

  rfc2136:
    class: octodns_bind.Rfc2136Provider
    host: env/DNS_HOST
    port: env/DNS_PORT  <<== A number is set inside this var (5353)
    key_name: env/DNS_KEY
    key_secret: env/DNS_SECRET
    key_algorithm: hmac-sha256
Traceback (most recent call last):
  File "/builds/BotDesign/infra/octodns/venv/bin/octodns-sync", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/builds/BotDesign/infra/octodns/venv/lib/python3.11/site-packages/octodns/cmds/sync.py", line 57, in main
    manager.sync(
  File "/builds/BotDesign/infra/octodns/venv/lib/python3.11/site-packages/octodns/manager.py", line 592, in sync
    ps, d = future.result()
            ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/concurrent/futures/_base.py", line 456, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builds/BotDesign/infra/octodns/venv/lib/python3.11/site-packages/octodns/manager.py", line 435, in _populate_and_plan
    plan = target.plan(zone, processors=processors)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builds/BotDesign/infra/octodns/venv/lib/python3.11/site-packages/octodns/provider/base.py", line 178, in plan
    exists = self.populate(existing, target=True, lenient=True)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builds/BotDesign/infra/octodns/venv/lib/python3.11/site-packages/octodns_bind/__init__.py", line 53, in populate
    rrs = self.zone_records(zone)
          ^^^^^^^^^^^^^^^^^^^^^^^
  File "/builds/BotDesign/infra/octodns/venv/lib/python3.11/site-packages/octodns_bind/__init__.py", line 184, in zone_records
    z = dns.zone.from_xfr(
        ^^^^^^^^^^^^^^^^^^
  File "/builds/BotDesign/infra/octodns/venv/lib/python3.11/site-packages/dns/zone.py", line 1369, in from_xfr
    for r in xfr:
  File "/builds/BotDesign/infra/octodns/venv/lib/python3.11/site-packages/dns/query.py", line 1229, in xfr
    _connect(s, destination, expiration)
  File "/builds/BotDesign/infra/octodns/venv/lib/python3.11/site-packages/dns/query.py", line 869, in _connect
    err = s.connect_ex(address)
          ^^^^^^^^^^^^^^^^^^^^^
TypeError: 'str' object cannot be interpreted as an integer

Thanks for your help.

Regards,

GSS-TSIG Authentication Support for Active Directory DNS

Hi everyone, I would like to use octodns-bind module to update my AD DNS zones, AFAIK windows DNS server can accept dns updates in rfc2136 form but it requires a little bit modified authorization model, GSS-TSIG. I've been able to use nupdate cli tool to achieve this but I want to replace octo with my own script, however I can't see an option about gss-tsig. Does it support?

BIND provider as target?

Hello,
I have a use case where I want to get BIND zonefiles out of my OctoDNS configuration. It looks like octodns-bind package has BIND files as a source only. I'm curious: why is that? My scenario is not something people need, or are there other reasons for that?

Any inside would help! Thank you!

dns.resolver.resolver does not refer to /etc/hosts before querying resolver

Related #24 #25

dns.resolver.resolve() does not refer to /etc/hosts before making a query to a resolver it goes straight to a resolver. This generally is fine if you're referring to a remote server, but if it's running on localhost or something that you've set in /etc/hosts it won't work.

We should probably use socket.getaddrinfo instead which will look at /etc/hosts and then do a query via resolver if it finds nothing.

Support AXFR/RF2136 to Azure Private DNS

I am trying to keep in sync a zone from my Microsoft DNS Server to an Azure Private DNS.
However it does not seem possible as the Microsoft DNS Server uses an NS entry and Azure Private DNS do not support NS entry.

Would it be possible for this scenario to ignore the NS entries somehow ?
If I remove the NS entry I get :
octodns_bind.AxfrSourceZoneTransferFailed: Unable to Perform Zone Transfer: The DNS zone has no NS RRset at its origin.

If I have the NS entry I get:
octodns.provider.SupportsException: azure: root NS record not supported for domain.com.

Have all records types in the local dev server zone

It would be nice to have at least 1 of all supported record types in the local dev server zone, we can likely just copy the unit.tests one, and s/unit.tests/exxampled.com/g, or possible just change the bind mount to mount that file and we can change the named.conf to just server unit.tests

This would make it so that whenever a new record is added for tests, it's automatically picked up in the local dev environment

TXT records lose space symbol

If you attempt to update TXT record it won't fail but will split txt line into parts by spaces.
And this leads to lost all spaces in txt records.
@ IN TXT "A custom zone!"
will became
@ IN TXT "Acustomzone!"
and octodns will always attempt to update it

* ns2 (Rfc2136Provider)
*   Update
*     <TxtRecord TXT 3600, unit.tests., ['Acustomzone!']> ->
*     <TxtRecord TXT 3600, unit.tests., ['A custom zone!']> ()

This happens due to dnspython rdata tokenizer (which parses a string) it counts spaces by delimiters and to avoid it you have to surround your rdata string with quotes.
But there is no way to set quotes for txt record in octodns configuration files (I've tried yaml & zones) - it always strips them.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.