Resource Record Formats

DNS (Domain Name System) uses Resource Records (RRs) to store information about domain names. Each RR has a specific format and type, defining the type of data it holds. Here’s a detailed look at common DNS Resource Record formats:

General Structure of Resource Records

A standard DNS Resource Record has the following fields:

  1. Name: The domain name to which this record pertains.

  2. TTL (Time to Live): The duration (in seconds) that the record may be cached by DNS resolvers.

  3. Class: The class of the data, typically IN for Internet.

  4. Type: The type of the resource record (e.g., A, AAAA, CNAME).

  5. RDATA: The type-specific data.

Here are the formats for some common Resource Record types:

A Record (Address Record)

The A record maps a domain name to an IPv4 address.

Format:

Name       TTL    Class  Type  Address
example.com.  3600  IN    A     192.0.2.1

AAAA Record (IPv6 Address Record)

The AAAA record maps a domain name to an IPv6 address.

Format:

Name       TTL    Class  Type  Address
example.com.  3600  IN    AAAA  2001:0db8:85a3:0000:0000:8a2e:0370:7334

CNAME Record (Canonical Name Record)

The CNAME record maps a domain name to another domain name (aliasing).

Format:

Name       TTL    Class  Type   Canonical Name
www.example.com. 3600  IN    CNAME example.com.

MX Record (Mail Exchange Record)

The MX record specifies the mail servers responsible for receiving email on behalf of a domain.

Format:

Name       TTL    Class  Type  Priority Mail Server
example.com.  3600  IN    MX    10 mail.example.com.
example.com.  3600  IN    MX    20 mail2.example.com.

NS Record (Name Server Record)

The NS record specifies the authoritative name servers for a domain.

Format:

Name       TTL    Class  Type  Name Server
example.com.  3600  IN    NS    ns1.example.com.
example.com.  3600  IN    NS    ns2.example.com.

PTR Record (Pointer Record)

The PTR record maps an IP address to a domain name (reverse DNS lookup).

Format:

Name                 TTL    Class  Type  PTR Record
1.2.0.192.in-addr.arpa. 3600  IN    PTR  example.com.

SOA Record (Start of Authority Record)

The SOA record provides information about the DNS zone, including the primary name server, email of the domain administrator, and domain serial number.

Format:

Name       TTL    Class  Type  Primary NS        Email            Serial     Refresh Retry Expire Minimum
example.com.  3600  IN    SOA   ns1.example.com. admin.example.com. 2021071501 3600 1800 1209600 86400

TXT Record (Text Record)

The TXT record is used to associate arbitrary text with a domain name.

Format:

Name       TTL    Class  Type  Text
example.com.  3600  IN    TXT   "v=spf1 include:example.com ~all"

SRV Record (Service Locator Record)

The SRV record is used to define the location of servers for specific services.

Format:

Name                TTL    Class  Type  Priority Weight Port Target
_service._proto.example.com. 3600 IN SRV 10 5 5060 sipserver.example.com.

Example DNS Zone File

Here's an example DNS zone file incorporating various types of records:

$TTL 86400
@   IN  SOA ns1.example.com. admin.example.com. (
            2021071501 ; Serial
            3600       ; Refresh
            1800       ; Retry
            1209600    ; Expire
            86400 )    ; Minimum TTL

; Name Servers
    IN  NS      ns1.example.com.
    IN  NS      ns2.example.com.

; A Records
ns1 IN  A       192.0.2.1
ns2 IN  A       192.0.2.2
www IN  A       192.0.2.3

; AAAA Records
www IN  AAAA    2001:0db8:85a3:0000:0000:8a2e:0370:7334

; MX Records
    IN  MX 10   mail.example.com.
    IN  MX 20   mail2.example.com.

; CNAME Records
ftp IN  CNAME   www.example.com.

; TXT Records
    IN  TXT     "v=spf1 include:example.com ~all"

; SRV Records
_sip._tcp IN SRV 10 5 5060 sipserver.example.com.

Conclusion

Understanding and configuring DNS Resource Records is fundamental for managing domain names and ensuring proper resolution of hostnames to IP addresses. By mastering the various types of resource records and their formats, you can effectively manage DNS settings for domains and troubleshoot related issues.

Last updated