GithubHelp home page GithubHelp logo

octodns / octodns-bind Goto Github PK

View Code? Open in Web Editor NEW
5.0 6.0 8.0 164 KB

RFC compliant (Bind9) provider for octoDNS

License: MIT License

Shell 12.37% Python 75.79% Scilab 8.36% DIGITAL Command Language 3.48%

octodns-bind's Issues

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,

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

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...

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!

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?

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

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?

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.

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.

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.

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.