nat64_to_ipv4

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

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

Go to latest
Published: Feb 23, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

README

Caddy NAT64 log filter module

NAT64 allows a host on a IPv6-only network to communicate with legacy IPv4 hosts. The IPv4 addresses will be embedded in the well-known prefix 64::ff9b::/96.

When Caddy is deployed in such a scenario, it will log the IP addresses of legacy clients embedded in the well-known prefix. This can be undesirable for further analysis.

When this module is configured, it will check if an IPv6 address is inside the well-known NAT64 prefix and if so, the address will be rewritten to the IPv4 form.

Since log filters cannot be chained, this module can in addition also apply masks to the IP addresses, like Caddy's builtin ip_mask does.

Only rewrite NAT64 addresses to IPv4 form

example.com {
    log {
        format filter {
            fields {
                request>remote_ip nat64_to_ipv4
            }
        }
    }
    respond "Hello"
}

Rewrite NAT64 addresses and apply mask

example.com {
    log {
        format filter {
            fields {
                request>remote_ip nat64_to_ipv4 24 48
            }
        }
    }
    respond "Hello"
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNat64Address

func IsNat64Address(ip net.IP) bool

Types

type NAT64Filter

type NAT64Filter struct {
	IPv4MaskRaw int `json:"ipv4_cidr,omitempty"`
	IPv6MaskRaw int `json:"ipv6_cidr,omitempty"`
	// contains filtered or unexported fields
}

NAT64Filter is a Caddy log field filter that rewrites NAT64 IPv6 addresses to their corresponding IPv4 addresses. Optionally, it can also mask out parts of the IP adress, like ip_mask does.

func (NAT64Filter) CaddyModule

func (NAT64Filter) CaddyModule() caddy.ModuleInfo

func (*NAT64Filter) Filter

func (f *NAT64Filter) Filter(in zapcore.Field) zapcore.Field

func (*NAT64Filter) Provision

func (f *NAT64Filter) Provision(ctx caddy.Context) error

Provision parses m's IP masks, from integers.

func (*NAT64Filter) UnmarshalCaddyfile

func (f *NAT64Filter) UnmarshalCaddyfile(d *caddyfile.Dispenser) error

UnmarshalCaddyfile sets up the module from Caddyfile tokens.

Jump to

Keyboard shortcuts

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