or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

client.mdconstants.mddnssec.mddynamic-updates.mdedns0.mdindex.mdmessaging.mdrr-types.mdserver.mdtsig.mdutilities.mdzone-parsing.mdzone-transfer.md
tile.json

rr-types.mddocs/

DNS Resource Record Types

Complete reference for all DNS resource record types supported by the library. All RR types implement the RR interface.

Base Types

RR Interface

Base interface implemented by all resource records.

type RR interface {
	Header() *RR_Header
	String() string
}

RR_Header

Common header for all resource records.

type RR_Header struct {
	Name     string // Owner name (must be FQDN)
	Rrtype   uint16 // RR type
	Class    uint16 // RR class
	Ttl      uint32 // Time to live
	Rdlength uint16 // Rdata length
}

func (h *RR_Header) Header() *RR_Header
func (h *RR_Header) String() string

RR Utility Functions

// NewRR parses single RR from string
func NewRR(s string) (RR, error)

// Copy creates deep copy of RR
func Copy(r RR) RR

// Len returns RR length in wire format
func Len(rr RR) int

// IsDuplicate checks if two RRs are duplicates
func IsDuplicate(r1, r2 RR) bool

// IsRRset validates if slice is proper RRset
func IsRRset(rrset []RR) bool

Basic Record Types

A - IPv4 Address

type A struct {
	Hdr RR_Header
	A   net.IP // IPv4 address
}

AAAA - IPv6 Address

type AAAA struct {
	Hdr  RR_Header
	AAAA net.IP // IPv6 address
}

CNAME - Canonical Name

type CNAME struct {
	Hdr    RR_Header
	Target string // Canonical name
}

NS - Name Server

type NS struct {
	Hdr RR_Header
	Ns  string // Name server domain name
}

PTR - Pointer

type PTR struct {
	Hdr RR_Header
	Ptr string // Pointer domain name
}

MX - Mail Exchange

type MX struct {
	Hdr        RR_Header
	Preference uint16 // Preference value
	Mx         string // Mail exchange domain name
}

SOA - Start of Authority

type SOA struct {
	Hdr     RR_Header
	Ns      string // Primary name server
	Mbox    string // Responsible party mailbox
	Serial  uint32 // Serial number
	Refresh uint32 // Refresh interval
	Retry   uint32 // Retry interval
	Expire  uint32 // Expire time
	Minttl  uint32 // Minimum TTL
}

TXT - Text

type TXT struct {
	Hdr RR_Header
	Txt []string // Text strings
}

SRV - Service Locator

type SRV struct {
	Hdr      RR_Header
	Priority uint16 // Priority
	Weight   uint16 // Weight
	Port     uint16 // Port number
	Target   string // Target domain name
}

DNSSEC Record Types

DNSKEY - DNS Public Key

type DNSKEY struct {
	Hdr       RR_Header
	Flags     uint16 // Flags
	Protocol  uint8  // Protocol (always 3)
	Algorithm uint8  // Algorithm
	PublicKey string // Base64 encoded public key
}

func (k *DNSKEY) KeyTag() uint16
func (k *DNSKEY) ToDS(h uint8) *DS
func (k *DNSKEY) ToCDNSKEY() *CDNSKEY
func (k *DNSKEY) NewPrivateKey(s string) (crypto.PrivateKey, error)

DS - Delegation Signer

type DS struct {
	Hdr        RR_Header
	KeyTag     uint16 // Key tag
	Algorithm  uint8  // Algorithm
	DigestType uint8  // Digest type
	Digest     string // Hex encoded digest
}

func (ds *DS) ToCDS() *CDS

RRSIG - Resource Record Signature

type RRSIG struct {
	Hdr         RR_Header
	TypeCovered uint16 // Type covered by signature
	Algorithm   uint8  // Algorithm
	Labels      uint8  // Number of labels
	OrigTtl     uint32 // Original TTL
	Expiration  uint32 // Signature expiration
	Inception   uint32 // Signature inception
	KeyTag      uint16 // Key tag
	SignerName  string // Signer name
	Signature   string // Base64 encoded signature
}

func (rr *RRSIG) Sign(k crypto.Signer, rrset []RR) error
func (rr *RRSIG) Verify(k *DNSKEY, rrset []RR) error
func (rr *RRSIG) ValidityPeriod(t time.Time) bool

NSEC - Next Secure

type NSEC struct {
	Hdr        RR_Header
	NextDomain string   // Next domain name
	TypeBitMap []uint16 // Type bit map
}

NSEC3 - Next Secure v3

type NSEC3 struct {
	Hdr        RR_Header
	Hash       uint8    // Hash algorithm
	Flags      uint8    // Flags
	Iterations uint16   // Iterations
	SaltLength uint8    // Salt length
	Salt       string   // Hex encoded salt
	HashLength uint8    // Hash length
	NextDomain string   // Next hashed owner name
	TypeBitMap []uint16 // Type bit map
}

func (rr *NSEC3) Cover(name string) bool
func (rr *NSEC3) Match(name string) bool

NSEC3PARAM - NSEC3 Parameters

type NSEC3PARAM struct {
	Hdr        RR_Header
	Hash       uint8  // Hash algorithm
	Flags      uint8  // Flags
	Iterations uint16 // Iterations
	SaltLength uint8  // Salt length
	Salt       string // Hex encoded salt
}

CDNSKEY - Child DNSKEY

type CDNSKEY struct {
	DNSKEY // Embeds DNSKEY
}

CDS - Child DS

type CDS struct {
	DS // Embeds DS
}

DLV - DNSSEC Lookaside Validation

type DLV struct {
	DS // Embeds DS
}

TA - Trust Anchor

type TA struct {
	Hdr        RR_Header
	KeyTag     uint16 // Key tag
	Algorithm  uint8  // Algorithm
	DigestType uint8  // Digest type
	Digest     string // Hex encoded digest
}

Certificate and Security Records

TLSA - TLS Authentication

type TLSA struct {
	Hdr          RR_Header
	Usage        uint8  // Certificate usage
	Selector     uint8  // Selector
	MatchingType uint8  // Matching type
	Certificate  string // Hex encoded certificate data
}

func (rr *TLSA) Sign(usage, selector, matchingType int, cert *x509.Certificate) error
func (rr *TLSA) Verify(cert *x509.Certificate) error

SMIMEA - S/MIME Certificate Association

type SMIMEA struct {
	Hdr          RR_Header
	Usage        uint8  // Certificate usage
	Selector     uint8  // Selector
	MatchingType uint8  // Matching type
	Certificate  string // Hex encoded certificate data
}

func (rr *SMIMEA) Sign(usage, selector, matchingType int, cert *x509.Certificate) error
func (rr *SMIMEA) Verify(cert *x509.Certificate) error

CERT - Certificate

type CERT struct {
	Hdr         RR_Header
	Type        uint16 // Certificate type
	KeyTag      uint16 // Key tag
	Algorithm   uint8  // Algorithm
	Certificate string // Base64 encoded certificate
}

SSHFP - SSH Fingerprint

type SSHFP struct {
	Hdr         RR_Header
	Algorithm   uint8  // Algorithm
	Type        uint8  // Fingerprint type
	FingerPrint string // Hex encoded fingerprint
}

IPSECKEY - IPsec Key

type IPSECKEY struct {
	Hdr         RR_Header
	Precedence  uint8  // Precedence
	GatewayType uint8  // Gateway type
	Algorithm   uint8  // Algorithm
	GatewayAddr net.IP // Gateway IP address
	GatewayHost string // Gateway hostname
	PublicKey   string // Base64 encoded public key
}

OPENPGPKEY - OpenPGP Key

type OPENPGPKEY struct {
	Hdr       RR_Header
	PublicKey string // Base64 encoded public key
}

KEY - Public Key (obsolete)

type KEY struct {
	DNSKEY // Embeds DNSKEY
}

RKEY - Resource Key

type RKEY struct {
	Hdr       RR_Header
	Flags     uint16 // Flags
	Protocol  uint8  // Protocol
	Algorithm uint8  // Algorithm
	PublicKey string // Base64 encoded public key
}

SIG - Signature (obsolete)

type SIG struct {
	RRSIG // Embeds RRSIG
}

func (rr *SIG) Sign(k crypto.Signer, m *Msg) ([]byte, error)
func (rr *SIG) Verify(k *KEY, msg []byte) error

Service Discovery Records

SVCB - Service Binding

type SVCB struct {
	Hdr      RR_Header
	Priority uint16         // Priority
	Target   string         // Target domain name
	Value    []SVCBKeyValue // Service parameters
}

HTTPS - HTTPS Binding

type HTTPS struct {
	SVCB // Embeds SVCB
}

NAPTR - Naming Authority Pointer

type NAPTR struct {
	Hdr         RR_Header
	Order       uint16 // Order
	Preference  uint16 // Preference
	Flags       string // Flags
	Service     string // Service
	Regexp      string // Regular expression
	Replacement string // Replacement domain name
}

Network and Address Records

L32 - Locator32

type L32 struct {
	Hdr        RR_Header
	Preference uint16 // Preference
	Locator32  net.IP // IPv4 locator
}

L64 - Locator64

type L64 struct {
	Hdr        RR_Header
	Preference uint16 // Preference
	Locator64  uint64 // 64-bit locator
}

LP - Locator Pointer

type LP struct {
	Hdr        RR_Header
	Preference uint16 // Preference
	Fqdn       string // FQDN
}

NID - Node Identifier

type NID struct {
	Hdr        RR_Header
	Preference uint16 // Preference
	NodeID     uint64 // Node ID
}

EUI48 - EUI-48 Address

type EUI48 struct {
	Hdr     RR_Header
	Address uint64 // 48-bit address
}

EUI64 - EUI-64 Address

type EUI64 struct {
	Hdr     RR_Header
	Address uint64 // 64-bit address
}

LOC - Location

type LOC struct {
	Hdr       RR_Header
	Version   uint8  // Version
	Size      uint8  // Size
	HorizPre  uint8  // Horizontal precision
	VertPre   uint8  // Vertical precision
	Latitude  uint32 // Latitude
	Longitude uint32 // Longitude
	Altitude  uint32 // Altitude
}

GPOS - Geographical Position

type GPOS struct {
	Hdr       RR_Header
	Longitude string // Longitude
	Latitude  string // Latitude
	Altitude  string // Altitude
}

Policy and Information Records

CAA - Certification Authority Authorization

type CAA struct {
	Hdr   RR_Header
	Flag  uint8  // Flags
	Tag   string // Property tag
	Value string // Property value
}

URI - Uniform Resource Identifier

type URI struct {
	Hdr      RR_Header
	Priority uint16 // Priority
	Weight   uint16 // Weight
	Target   string // URI target
}

SPF - Sender Policy Framework

type SPF struct {
	Hdr RR_Header
	Txt []string // SPF text strings
}

DNAME - Delegation Name

type DNAME struct {
	Hdr    RR_Header
	Target string // Delegation target
}

TALINK - Trust Anchor Link

type TALINK struct {
	Hdr          RR_Header
	PreviousName string // Previous trust anchor name
	NextName     string // Next trust anchor name
}

Experimental and Obsolete Records

HIP - Host Identity Protocol

type HIP struct {
	Hdr                RR_Header
	HitLength          uint8    // HIT length
	PublicKeyAlgorithm uint8    // Public key algorithm
	PublicKeyLength    uint16   // Public key length
	Hit                string   // Hex encoded HIT
	PublicKey          string   // Base64 encoded public key
	RendezvousServers  []string // Rendezvous server names
}

APL - Address Prefix List

type APL struct {
	Hdr      RR_Header
	Prefixes []APLPrefix // Address prefixes
}

type APLPrefix struct {
	Negation bool      // Negation flag
	Network  net.IPNet // IP network
}

DHCID - DHCP Identifier

type DHCID struct {
	Hdr    RR_Header
	Digest string // Base64 encoded digest
}

ZONEMD - Zone Message Digest

type ZONEMD struct {
	Hdr    RR_Header
	Serial uint32 // Serial number
	Scheme uint8  // Scheme
	Hash   uint8  // Hash algorithm
	Digest string // Hex encoded digest
}

AMTRELAY - AMT Relay

type AMTRELAY struct {
	Hdr         RR_Header
	Precedence  uint8  // Precedence
	GatewayType uint8  // Gateway type (includes discovery bit)
	GatewayAddr net.IP // Gateway IP address
	GatewayHost string // Gateway hostname
}

RESINFO - Resource Information

type RESINFO struct {
	Hdr RR_Header
	Txt []string // Information strings
}

AVC - Application Visibility and Control

type AVC struct {
	Hdr RR_Header
	Txt []string // AVC strings
}

NINFO - Name Information

type NINFO struct {
	Hdr    RR_Header
	ZSData []string // Zone status data
}

HINFO - Host Information

type HINFO struct {
	Hdr RR_Header
	Cpu string // CPU type
	Os  string // Operating system
}

RP - Responsible Person

type RP struct {
	Hdr  RR_Header
	Mbox string // Mailbox domain name
	Txt  string // TXT domain name
}

AFSDB - AFS Database

type AFSDB struct {
	Hdr      RR_Header
	Subtype  uint16 // Subtype
	Hostname string // Hostname
}

X25 - X.25 Address

type X25 struct {
	Hdr         RR_Header
	PSDNAddress string // PSDN address
}

ISDN - ISDN Address

type ISDN struct {
	Hdr        RR_Header
	Address    string // ISDN address
	SubAddress string // Sub-address
}

RT - Route Through

type RT struct {
	Hdr        RR_Header
	Preference uint16 // Preference
	Host       string // Intermediate host
}

PX - Pointer to X.400

type PX struct {
	Hdr        RR_Header
	Preference uint16 // Preference
	Map822     string // RFC 822 mapping
	Mapx400    string // X.400 mapping
}

KX - Key Exchanger

type KX struct {
	Hdr        RR_Header
	Preference uint16 // Preference
	Exchanger  string // Key exchanger
}

MB - Mailbox Domain Name

type MB struct {
	Hdr RR_Header
	Mb  string // Mailbox domain name
}

MD - Mail Destination (obsolete)

type MD struct {
	Hdr RR_Header
	Md  string // Mail destination
}

MF - Mail Forwarder (obsolete)

type MF struct {
	Hdr RR_Header
	Mf  string // Mail forwarder
}

MG - Mail Group Member

type MG struct {
	Hdr RR_Header
	Mg  string // Mail group member
}

MR - Mail Rename Domain Name

type MR struct {
	Hdr RR_Header
	Mr  string // Mail rename name
}

MINFO - Mailbox Information

type MINFO struct {
	Hdr   RR_Header
	Rmail string // Responsible mailbox
	Email string // Error mailbox
}

NULL - Null Record

type NULL struct {
	Hdr  RR_Header
	Data string // Arbitrary data
}

NSAPPTR - NSAP Pointer

type NSAPPTR struct {
	Hdr RR_Header
	Ptr string // Pointer domain name
}

NIMLOC - Nimrod Locator

type NIMLOC struct {
	Hdr     RR_Header
	Locator string // Hex encoded locator
}

EID - Endpoint Identifier

type EID struct {
	Hdr      RR_Header
	Endpoint string // Hex encoded endpoint
}

NXT - Next (obsolete)

type NXT struct {
	NSEC // Embeds NSEC
}

NXNAME - Next Name

type NXNAME struct {
	Hdr RR_Header
	// No rdata
}

UID - User Identifier

type UID struct {
	Hdr RR_Header
	Uid uint32 // User ID
}

GID - Group Identifier

type GID struct {
	Hdr RR_Header
	Gid uint32 // Group ID
}

UINFO - User Information

type UINFO struct {
	Hdr   RR_Header
	Uinfo string // User information
}

UNSPEC - Unspecified

type UNSPEC struct {
	Hdr RR_Header
	// No rdata
}

ANY - Wildcard

type ANY struct {
	Hdr RR_Header
	// No rdata
}

Special Records

OPT - EDNS0 Option

type OPT struct {
	Hdr    RR_Header
	Option []EDNS0 // EDNS0 options
}

func (rr *OPT) Do() bool
func (rr *OPT) SetDo(do bool)
func (rr *OPT) Version() uint8
func (rr *OPT) SetVersion(v uint8)
func (rr *OPT) ExtendedRcode() int
func (rr *OPT) SetExtendedRcode(v uint8)
func (rr *OPT) UDPSize() uint16
func (rr *OPT) SetUDPSize(size uint16)

See EDNS0 Details for complete EDNS0 documentation.

TKEY - Transaction Key

type TKEY struct {
	Hdr        RR_Header
	Algorithm  string // Algorithm domain name
	Inception  uint32 // Inception time
	Expiration uint32 // Expiration time
	Mode       uint16 // Mode
	Error      uint16 // Error code
	KeySize    uint16 // Key size
	Key        string // Hex encoded key
	OtherLen   uint16 // Other data length
	OtherData  string // Hex encoded other data
}

TSIG - Transaction Signature

type TSIG struct {
	Hdr        RR_Header
	Algorithm  string // Algorithm domain name
	TimeSigned uint64 // Time signed
	Fudge      uint16 // Time fudge
	MACSize    uint16 // MAC size
	MAC        string // Hex encoded MAC
	OrigId     uint16 // Original message ID
	Error      uint16 // Error code
	OtherLen   uint16 // Other data length
	OtherData  string // Hex encoded other data
}

See TSIG Details for complete TSIG documentation.

RFC3597 - Unknown/Generic RR

type RFC3597 struct {
	Hdr   RR_Header
	Rdata string // Hex encoded rdata
}

SVCB/HTTPS Support Types

SVCBKeyValue Interface

type SVCBKeyValue interface {
	Key() SVCBKey
	String() string
}

SVCB Parameter Types

type SVCBMandatory struct {
	Code []SVCBKey // Mandatory keys
}

type SVCBAlpn struct {
	Alpn []string // ALPN protocol IDs
}

type SVCBNoDefaultAlpn struct {
	// No fields
}

type SVCBPort struct {
	Port uint16 // Port number
}

type SVCBIPv4Hint struct {
	Hint []net.IP // IPv4 hints
}

type SVCBIPv6Hint struct {
	Hint []net.IP // IPv6 hints
}

type SVCBECHConfig struct {
	ECH []byte // ECH configuration
}

type SVCBDoHPath struct {
	Template string // DoH URI template
}

type SVCBOhttp struct {
	Target string // OHTTP target
}

type SVCBLocal struct {
	KeyCode SVCBKey // Key code
	Data    []byte  // Data
}

Usage Examples

Creating A Record

rr := &dns.A{
	Hdr: dns.RR_Header{
		Name:   "example.com.",
		Rrtype: dns.TypeA,
		Class:  dns.ClassINET,
		Ttl:    3600,
	},
	A: net.ParseIP("192.0.2.1"),
}

Creating MX Record

rr := &dns.MX{
	Hdr: dns.RR_Header{
		Name:   "example.com.",
		Rrtype: dns.TypeMX,
		Class:  dns.ClassINET,
		Ttl:    3600,
	},
	Preference: 10,
	Mx:         "mail.example.com.",
}

Creating SOA Record

rr := &dns.SOA{
	Hdr: dns.RR_Header{
		Name:   "example.com.",
		Rrtype: dns.TypeSOA,
		Class:  dns.ClassINET,
		Ttl:    3600,
	},
	Ns:      "ns1.example.com.",
	Mbox:    "admin.example.com.",
	Serial:  2024010101,
	Refresh: 3600,
	Retry:   1800,
	Expire:  604800,
	Minttl:  86400,
}

Parsing RR from String

rr, err := dns.NewRR("example.com. 3600 IN A 192.0.2.1")
if err != nil {
	log.Fatal(err)
}

// Type assert to specific type
if a, ok := rr.(*dns.A); ok {
	fmt.Printf("IPv4: %s\n", a.A)
}

Working with TXT Records

rr := &dns.TXT{
	Hdr: dns.RR_Header{
		Name:   "example.com.",
		Rrtype: dns.TypeTXT,
		Class:  dns.ClassINET,
		Ttl:    3600,
	},
	Txt: []string{"v=spf1 mx -all", "google-site-verification=abc123"},
}

Creating SRV Record

rr := &dns.SRV{
	Hdr: dns.RR_Header{
		Name:   "_http._tcp.example.com.",
		Rrtype: dns.TypeSRV,
		Class:  dns.ClassINET,
		Ttl:    3600,
	},
	Priority: 10,
	Weight:   60,
	Port:     80,
	Target:   "www.example.com.",
}

Copying RR

original := &dns.A{
	Hdr: dns.RR_Header{
		Name:   "example.com.",
		Rrtype: dns.TypeA,
		Class:  dns.ClassINET,
		Ttl:    3600,
	},
	A: net.ParseIP("192.0.2.1"),
}

copied := dns.Copy(original).(*dns.A)

Type Constants

All RR type codes are defined as constants:

const (
	TypeA          uint16 = 1
	TypeNS         uint16 = 2
	TypeMD         uint16 = 3
	TypeMF         uint16 = 4
	TypeCNAME      uint16 = 5
	TypeSOA        uint16 = 6
	TypeMB         uint16 = 7
	TypeMG         uint16 = 8
	TypeMR         uint16 = 9
	TypeNULL       uint16 = 10
	TypePTR        uint16 = 12
	TypeHINFO      uint16 = 13
	TypeMINFO      uint16 = 14
	TypeMX         uint16 = 15
	TypeTXT        uint16 = 16
	TypeRP         uint16 = 17
	TypeAFSDB      uint16 = 18
	TypeX25        uint16 = 19
	TypeISDN       uint16 = 20
	TypeRT         uint16 = 21
	TypeNSAPPTR    uint16 = 23
	TypeSIG        uint16 = 24
	TypeKEY        uint16 = 25
	TypePX         uint16 = 26
	TypeGPOS       uint16 = 27
	TypeAAAA       uint16 = 28
	TypeLOC        uint16 = 29
	TypeNXT        uint16 = 30
	TypeEID        uint16 = 31
	TypeNIMLOC     uint16 = 32
	TypeSRV        uint16 = 33
	TypeATMA       uint16 = 34
	TypeNAPTR      uint16 = 35
	TypeKX         uint16 = 36
	TypeCERT       uint16 = 37
	TypeDNAME      uint16 = 39
	TypeOPT        uint16 = 41
	TypeAPL        uint16 = 42
	TypeDS         uint16 = 43
	TypeSSHFP      uint16 = 44
	TypeIPSECKEY   uint16 = 45
	TypeRRSIG      uint16 = 46
	TypeNSEC       uint16 = 47
	TypeDNSKEY     uint16 = 48
	TypeDHCID      uint16 = 49
	TypeNSEC3      uint16 = 50
	TypeNSEC3PARAM uint16 = 51
	TypeTLSA       uint16 = 52
	TypeSMIMEA     uint16 = 53
	TypeHIP        uint16 = 55
	TypeNINFO      uint16 = 56
	TypeRKEY       uint16 = 57
	TypeTALINK     uint16 = 58
	TypeCDS        uint16 = 59
	TypeCDNSKEY    uint16 = 60
	TypeOPENPGPKEY uint16 = 61
	TypeCSYNC      uint16 = 62
	TypeZONEMD     uint16 = 63
	TypeSVCB       uint16 = 64
	TypeHTTPS      uint16 = 65
	TypeSPF        uint16 = 99
	TypeUINFO      uint16 = 100
	TypeUID        uint16 = 101
	TypeGID        uint16 = 102
	TypeUNSPEC     uint16 = 103
	TypeNID        uint16 = 104
	TypeL32        uint16 = 105
	TypeL64        uint16 = 106
	TypeLP         uint16 = 107
	TypeEUI48      uint16 = 108
	TypeEUI64      uint16 = 109
	TypeNXNAME     uint16 = 128
	TypeURI        uint16 = 256
	TypeCAA        uint16 = 257
	TypeAVC        uint16 = 258
	TypeAMTRELAY   uint16 = 260
	TypeRESINFO    uint16 = 261
	TypeTKEY       uint16 = 249
	TypeTSIG       uint16 = 250
	TypeIXFR       uint16 = 251
	TypeAXFR       uint16 = 252
	TypeMAILB      uint16 = 253
	TypeMAILA      uint16 = 254
	TypeANY        uint16 = 255
	TypeTA         uint16 = 32768
	TypeDLV        uint16 = 32769
	TypeReserved   uint16 = 65535
)

Type Conversion Functions

// TypeToString converts type code to string
func TypeToString(t uint16) string

// StringToType converts string to type code
func StringToType(s string) (uint16, bool)

// Type methods
type Type uint16
func (t Type) String() string

Related Topics

  • DNSSEC Operations - DNSSEC signing and validation
  • EDNS0 Extensions - OPT record details
  • TSIG Authentication - TSIG record details
  • Zone Parsing - Parsing RRs from zone files
  • DNS Messaging - Using RRs in messages