Code Monkey home page Code Monkey logo

coredns-auto-ipv6-ptr's Introduction

coredns-auto-ipv6-ptr

Goal: Generate IPv6 PTR records on the fly.

Additional benefit: Works with known hosts.

Examples

Generate PTR records if not found in a zonefile

0.0.0.b.0.0.3.0.8.b.d.0.1.0.0.2.ip6.arpa {
    autoipv6ptr {
        suffix lan.mydomain.tld
    }
    file your.reverse.zone
    log
}

Same as above but with a transferred zone

1.0.0.b.0.0.3.0.8.b.d.0.1.0.0.2.ip6.arpa {
    autoipv6ptr {
        suffix servers.mydomain.tld
        ttl 60
    }
    secondary {
        transfer from your.master.dns
    }
    log
}

Order is everything!

It's necessary that file or secondary comes right after autoipv6ptr! This plugin always calls the next plugin and checks its return. It will only generate a PTR if a negative result comes back.

Building a ready-to-use coredns binary using Docker

Using the docker infrastructure it's easy for you to build a working binary with the plugin:

docker build --pull --no-cache --output type=local,dest=result -f Dockerfile.build .

If everything checks out you'll find an x86_64 binary locally under result/coredns.

Testing

Run:

./result/coredns -conf tests/Corefile -p 1337

Test with dig. Known record:

dig @::1 -p 1337 +short -x 2001:db8:300::10
success.example.com.

Unknown record:

dig @::1 -p 1337 +short -x 2001:db8:300::11
20010db8030000000000000000000011.example.com.

coredns-auto-ipv6-ptr's People

Contributors

sniff122 avatar vlcty avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

coredns-auto-ipv6-ptr's Issues

Alternative to presets file

Excuse me for this issue, I found no better way for a comment.

It is more of a story than anything, so here it goes

  • I like the idea of autogenerated PTR-records for not fixed entries
  • However, the format of the presets file is arbitrarily, I already have the data that would go in here in a zone file
  • So, how to make autoipv6ptr take a zone file for presets?
  • Not at all, use e.g. the existing file plugin for all the nitty-gritty of parsing etc.
  • All that is left is a fallthrough option for the file plugin in case there no record exists in the zone file.
  • So here is a first rough-cut and works-for-me patch:
diff --git a/plugin/file/file.go b/plugin/file/file.go
index 0834ddc4..3ed38da7 100644
--- a/plugin/file/file.go
+++ b/plugin/file/file.go
@@ -91,6 +91,10 @@ func (f File) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (i
        m.Authoritative = true
        m.Answer, m.Ns, m.Extra = answer, ns, extra

+       if len(answer) == 0 {
+         log.Infof("No answer section -> fallthrough")
+               return plugin.NextOrFailure(f.Name(), f.Next, ctx, w, r)
+       }
        switch result {
        case Success:
        case NoData:

Allows for Corefile stanzas like

<reverse-network-zone>.ip6.arpa {
  file <reverse-network-zone>.ip6.arpa.zone
  autoipv6ptr {
      suffix example.org
  }
}

Alternative would be to copy the file plugin and insert the synthesise function appropriately when there is a suffix option given

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.