DNS: Records and Messages
Let's now get into what DNS records and messages look like.
We'll cover the following
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 isCH
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 isA
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
whereeducative.io
is the name, 299 is the TTL in seconds,IN
is the class,A
is the type of the RR, and104.20.7.183
is theRDATA
.
- The
- Canonical name or
CNAME
records are records of alias hostnames against actual hostnames. For example if,ibm.com
is reallyservereast.backup2.com
, then the latter is the canonical name ofibm.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.
- The
- 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.
- The
These resource records are stored in text form in special files called zone files.
Get hands-on with 1400+ tech skills courses.