Skip to content

DNS Protocol

DNS (Domain Name System) operates using a specific protocol to query and reply about domain name resolutions. The protocol is based on messages that consist of both queries and responses. The message format is the same for both types, but they differ in content.

DNS Message Structure

Each DNS message consists of several sections:

This contains information that is common to both query and response messages.

  • Identification (16 bits): This is a unique number used to match queries with their responses. Both the query and reply will have the same identification number to ensure they are related.
  • Flags: A series of flags that tell the server/client what the message represents or requests:
  • 1 bit: Query or Reply (indicates whether the message is a query or a response).
  • 1 bit: Recursion Desired (this indicates if the sender wants the resolver to perform recursive querying).
  • 1 bit: Recursion Available (this indicates if the server supports recursion).
  • 1 bit: Authoritative Answer (indicates whether the response is from an authoritative server or not).

Fields in DNS Messages

For a query:

  • Name: The domain name you're asking about (e.g., www.example.com).
  • Type: The type of DNS record you are asking for (e.g., A record for an IP address, MX record for mail exchange).

For a response:

  • RRs (Resource Records): The answer to the query, which will include resource records such as:
  • Authoritative records: For authoritative DNS servers.
  • Additional information: Which may help in further resolving the query, e.g., IP addresses of authoritative servers.

Inserting Records into DNS (Registering a Domain)

Here's an example to understand how DNS records are inserted when you register a new domain.

Step-by-Step Process

Let’s assume you start a new company called "Network Utopia" and you register the domain example.com. Here’s how it works:

Domain Registration

  1. You register the domain example.com with a DNS registrar, like Network Solutions.
  2. During this registration process, you will provide the names and IP addresses of your authoritative name servers (DNS servers).

Registrar Inserts Records

The registrar will then insert DNS records into the TLD (Top-Level Domain) server for .com (since .com is the TLD of your domain). These records typically include:

  • NS (Name Server) Record: Specifies which DNS servers are authoritative for your domain. This is where DNS queries for example.com will be sent.
  • Example: (example.com, dns1.example.com, NS)
    • This means example.com is associated with dns1.example.com as its authoritative name server.
  • A (Address) Record: This specifies the IP address of the authoritative DNS server.
  • Example: (dns1.example.com, 212.212.212.1, A)
    • This means the authoritative DNS server for example.com is located at IP address 212.212.212.1.

Create Additional Records for Subdomains

Now, as a part of managing the domain, you can create additional DNS records for your website or services. For example:

  • A record for www.example.com: This will associate the www subdomain with the IP address of your web server.
  • MX (Mail Exchange) Record for example.com: This will specify the mail server responsible for handling emails sent to example.com.

  • Example:

    • A record: (www.example.com, 212.212.212.2, A)
    • This means that www.example.com points to the IP address 212.212.212.2 (your web server).
    • MX record: (example.com, mail.example.com, MX)
    • This specifies that the mail server for example.com is located at mail.example.com.