DNS: Records and Messages

Let's now get into what DNS records and messages look like.

Resource Records

The DNS distributed database consists of entities called RRs, or Resource Records.

Format

RRs contain some or all of the following values:

  • Name of the domain.
  • Resource data (RDATA) provides information appropriate for the type of resource record.
  • Type of the resource record. We will discuss these shortly.
  • Time-to-live (TTL) is how long the record should be cached by the client in seconds.
  • DNS Class. There a many types of classes but we’re mainly concerned with IN which implies the ‘Internet’ class. That’s what all of our upcoming examples use so we won’t be discussing it again. Another common value for the DNS Class is CH for ‘CHAOS’. The CH class is mostly used for things like querying DNS server versions.

Types of resource records

  • Address type or A addresses contain IPv4 address to hostname mappings. They consist of:
    • The name is the hostname in question.
    • The TTL in seconds.
    • The type which is A in this case.
    • The RDATA which in this case is the IP address of the domain.
    • Example: educative.io. 299 IN A 104.20.7.183 where educative.io is the name, 299 is the TTL in seconds, IN is the class, A is the type of the RR, and 104.20.7.183 is the RDATA.
  • Canonical name or CNAME records are records of alias hostnames against actual hostnames. For example if, ibm.com is really servereast.backup2.com, then the latter is the canonical name of ibm.com.
    • The name is the alias name for the real or ‘canonical’ name of the server.
    • The RDATA is the canonical name of the server.
    • Example: bar.example.com. CNAME foo.example.com.
  • Mail Exchanger or MX records are records of the server that accepts email on behalf of a certain domain. We have seen this one before!
    • The name is the name of the host.
    • The RDATA is the name of the mail server associated with the host.
    • Example: educative.io IN MX 10 aspmx2.googlemail.com.

These resource records are stored in text form in special files called zone files.

Get hands-on with 1200+ tech skills courses.