nat64ptr

package module
v0.0.0-...-ee36b8f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 9, 2026 License: MIT Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

coredns-nat64ptr-plugin

coredns-nat64ptr-plugin is a CoreDNS plugin named nat64ptr. It rewrites PTR lookups under a configured NAT64 /96 IPv6 reverse zone into the embedded IPv4 address's in-addr.arpa. PTR lookup, forwards the request to the next plugin, then rewrites response owner names back to the original ip6.arpa. name.

This is useful when IPv6-only clients behind NAT64 need reverse DNS for IPv4 destinations represented inside a NAT64 prefix.

Project Name

  • Project/module name: coredns-nat64ptr-plugin
  • CoreDNS plugin directive: nat64ptr
  • Go module path: github.com/sunoaki/coredns-nat64ptr-plugin

Corefile

. {
    nat64ptr 2602:2a3:4:9b64:2::/96
    forward . 172.16.0.53
}

Only PTR questions below the configured /96 reverse zone are handled. Other requests are passed to the next plugin unchanged. A second optional argument configures the backend reverse suffix; it defaults to in-addr.arpa.. A third optional argument appends a suffix to returned PTR targets.

nat64ptr 2602:2a3:4:9b64:2::/96 in-addr.arpa.
nat64ptr 2602:2a3:4:9b64:2::/96 in-addr.arpa. 42xlat.sunoaki.net

Query Flow

For 2602:2a3:4:9b64:2::172.23.0.53, the IPv6 reverse name starts with the embedded IPv4 nibbles:

5.3.0.0.7.1.c.a...

nat64ptr converts those nibbles into 53.0.23.172.in-addr.arpa., forwards the rewritten request to the next plugin, then rewrites the response Question and Answer owner names back to the original IPv6 ip6.arpa. name. If a PTR suffix is configured, a returned target such as burble.dn42. becomes burble.dn42.42xlat.sunoaki.net..

CoreDNS Integration

Add this plugin to CoreDNS plugin.cfg before the plugin that should receive the rewritten IPv4 PTR query, usually before forward:

nat64ptr:github.com/sunoaki/coredns-nat64ptr-plugin

Then rebuild CoreDNS with the normal CoreDNS build process.

Development

Run the unit tests with:

go test ./...

Files

  • setup.go: CoreDNS registration and Corefile parsing.
  • nat64ptr.go: PTR request matching, IPv4 extraction, downstream forwarding, and response rewriting.
  • nat64ptr_test.go: Unit tests for extraction and end-to-end rewrite behavior.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NAT64PTR

type NAT64PTR struct {
	Next plugin.Handler
	// contains filtered or unexported fields
}

NAT64PTR rewrites PTR requests for a configured NAT64 /96 IPv6 reverse zone into IPv4 in-addr.arpa. requests, then rewrites the response owner names back to the original IPv6 ip6.arpa. name expected by the client.

func (*NAT64PTR) Name

func (n *NAT64PTR) Name() string

func (*NAT64PTR) ServeDNS

func (n *NAT64PTR) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址