Intro to DNS

The Domain Name System

Ben Scott

Oct 2007 (Rev B)

About this Presentation

Presentation Structure

  1. Boring conceptual stuff
    • Concepts
    • Terminology
    • Nuts and bolts
  2. DNS Query Mechanics
    • Tools: host and dig
    • The life and times of a DNS query
  3. A working ISC BIND named configuration (time permitting)

Planting trees in a forest

What is DNS?

DNS stands for "Domain Name System".

Simply put, given a name, DNS allows you to lookup information about that name.

Given something.example.com, DNS might tell you:

Buzzword = Directory service

Scope

Problems

IP networks use numerical addresses (e.g., 192.0.2.15)

DNS Gives Us

Features of DNS

Names and Records

Labels and Names

Hierarchy - Root Domain

DNS is designed around a hierarchy, or tree structure.

The root domain

Hierarchy - Child Domains

Child domains

For something.example.com:

Name Qualification - Relative Names

Relative Domain Names

Name Qualification - FQDNs

Fully Qualified Domain Names (FQDNs)

Top Level Domains - GTLDs

Global Top Level Domains (GTLDs)

Top Level Domains - ccTLDs

Country Code Top Level Domains (ccTLDs)

Resource Records

Domain names have resource records (RRs) associated with them. Every RR has:

Resource Record Parameters

Some Common Record Types

Listing Resource Records

Full version

;Domain-Name 		TTL	Class	Type	Value

www.example.com.	600	IN	A	192.0.2.15

Listing Resource Records

Full version

;Domain-Name 		TTL	Class	Type	Value

www.example.com.	600	IN	A	192.0.2.15

Abbreviated Version

;Domain-Name 		Type	Value

www.example.com.	A	192.0.2.15

A file listing resource records is called a "zone file". (We'll talk about zones in a little bit.)

A (Address) Records

Syntax Trick - Comments

Comments can be used to document zone files. They are ignored by the software, and do not appear in DNS.

; put a comment here
foo.example.com.   A   192.0.2.58 ; or here

Note that ISC BIND named's configuration file (named.conf) uses different syntax for everything, and comments in particular.

Syntax Trick - Line spanning

very.very.very.very.very.very.very.very.long.example.com.   A   192.0.2.28

Ahh! The record fell off the edge of the screen!

Syntax Trick - Line spanning

very.very.very.very.very.very.very.very.long.example.com.   A   192.0.2.28

Ahh! The record fell off the edge of the screen!

Easy fix:

very.very.very.very.very.very.very.very.long.example.com. (
	A
	192.0.2.28
)

Syntax Trick - Repeating LHS

You can save yourself some typing in your zone files.

Lots of records for the example.com domain ...

example.com.   NS   fred.example.com.
example.com.   NS   barney.example.com.
example.com.   NS   blue.friend.us.
example.com.   MX   10 huey.example.com.
example.com.   A    192.0.2.42

Syntax Trick - Repeating LHS

You can save yourself some typing in your zone files.

Lots of records for the example.com domain ...

example.com.   NS   fred.example.com.
example.com.   NS   barney.example.com.
example.com.   NS   blue.friend.us.
example.com.   MX   10 huey.example.com.
example.com.   A    192.0.2.42

... so let's just list that once

example.com.   NS   fred.example.com.
               NS   barney.example.com.
               NS   blue.friend.us.
               MX   10 huey.example.com.
               A    192.0.2.42
5B

Syntax Trick - Repeating RHS

You can save typing on the RHS, too.

In a domain, everything tends to be about that domain...

example.com.   NS   fred.example.com.
               NS   barney.example.com.
               NS   blue.friend.us.
               MX   10 huey.example.com.
               MX   20 dewey.example.com.

Syntax Trick - Repeating RHS

You can save typing on the RHS, too.

In a domain, everything tends to be about that domain...

example.com.   NS   fred.example.com.
               NS   barney.example.com.
               NS   blue.friend.us.
               MX   10 huey.example.com.
               MX   20 dewey.example.com.

... so you can use relative names

example.com.   NS   fred
               NS   barney
               NS   blue.friend.us.
               MX   10 huey
               MX   20 dewey
               A    192.0.2.42

Name Servers

Distributed Authority

The root servers:

Delegation

A nameserver can say, in effect, "This server is responsible for that subdomain". This is called delegation, and is done with the NS record.

In the com. zone:

Glue

What if we delegate to a nameserver with a domain name in the child domain? Catch-22?

example.com.         NS    fred.example.com.

Glue

What if we delegate to a nameserver with a domain name in the child domain? Catch-22?

example.com.         NS    fred.example.com.
fred.example.com.    A     192.0.2.5    ; glue record

Note that glue records are not authorative. They only serve to help others find the authorative nameservers for a domain.

Glue is the only time you can list a LHS domain name outside your zone of authority. (What's a zone?)

Zones

A "zone" (zone of authority) is a contiguous part of the namespace for which a given set of nameservers is authoritative.

In other words: A zone is a section of DNS that a nameserver controls.

Zones (diagram)

DNS delegation and zones diagram

SOA Records

A new zone is designated with an SOA (Start Of Authority) record.

Example SOA Record

example.com.   SOA   fred.example.com.   jsmith.example.com. (
   12345   ; serial number
   1h      ; refresh - how often peer NSs check for updates
   10m     ; retry - if refresh fails, how often to try again
   1w      ; expiration - how long before peer NSs stop giving out old data
   1d      ; TTL - how long other NSs cache our answers
   )

MX (Mail Exchanger) Records

example.com.   MX   10   huey.example.com.
               MX   20   dewey.example.com.
               MX   20   louie.example.com.

Deliver anything@example.com to huey first. If huey is down, try dewey and/or louie.

Alias (CNAME) Records

CNAME = Canonical Name

www.example.com.    CNAME    donald.example.com.

CNAME is an alias for the LHS domain, not the RHS value. So you cannot do this:

example.com.     MX       10 huey.example.com.
example.com.     CNAME    www.example.net.

A complete example

example.com.   SOA   (
     fred.example.com.
     jsmith.example.com.
     12345 1h 10m 1w 1d )
; nameservers
         NS      fred
         NS      blue.friend.us.
fred     A       192.0.2.5
; mail exchangers
         MX      10 huey
         MX      20 green.friend.us.
huey     A       192.0.2.7
; web server
www      CNAME   donald
donald   A       192.0.2.6
; subdomain for overseas division
asia          NS     ghost.asia
asia          NS     shell.asia
ghost.asia    A      192.0.2.215 ; glue
shell.asia    A      192.0.2.216 ; glue

DNS Query Mechanics

What actually happens to process DNS queries

Tools

The Life and Times of a DNS Query

What actually happens when you type

http://www.example.com/files/mswinsrc.tgz

into your web browser?

Establish Domain Name

http://www.example.com/files/mswinsrc.tgz is not a domain name. The browser parses the URL. It will extract www.example.com as the domain name. It then asks the question, "What is the address of www.example.com?"

The Resolver

The Resolver on Linux

Resolver Configuration

File /etc/resolv.conf configures the resolver. In our example:

nameserver 192.0.2.205
search asia.example.com example.com

The resolver is responsible for turning an unqualified name like whatever into a FQDN like whatever.example.com.

Back to our query

So, our resolver builds a query which asks for the A records associated with www.example.com. It sends that query to the configured resolving nameserver at 192.0.2.205.

Let us call our resolving nameserver SPIRIT.

Iterative Resolution

Iterative Resolution

Iterative Resolution

Iterative Resolution

Iterative Resolution

Cached Answers

End of slides

End of slides>