View definition

type EDNS0_SUBNET

Defined in github.com/miekg/dns/edns.go

Description

EDNS0_SUBNET is the subnet option that is used to give the remote nameserver an idea of where the client lives. It can then give back a different answer depending on the location or network topology. Basic use pattern for creating an subnet option:

o := new(dns.OPT)
o.Hdr.Name = "."
o.Hdr.Rrtype = dns.TypeOPT
e := new(dns.EDNS0_SUBNET)
e.Code = dns.EDNS0SUBNET
e.Family = 1	// 1 for IPv4 source address, 2 for IPv6
e.NetMask = 32	// 32 for IPV4, 128 for IPv6
e.SourceScope = 0
e.Address = net.ParseIP("127.0.0.1").To4()	// for IPv4
// e.Address = net.ParseIP("2001:7b8:32a::2")	// for IPV6
o.Option = append(o.Option, e)

Note: the spec (draft-ietf-dnsop-edns-client-subnet-00) has some insane logic for which netmask applies to the address. This code will parse all the available bits when unpacking (up to optlen). When packing it will apply SourceNetmask. If you need more advanced logic, patches welcome and good luck.

EDNS0_SUBNET is referenced in 4 repositories

github.com/miekg/dns github.com/devel/dnsmapper github.com/miekg/exdns

...