Domain Name System
Introduction
Root DNS Servers
Domains and Zones
A (non typical) DNS Lookup
Caching of DNS entries
Resolvers—Recursive Lookup
DNS message structure
Reverse lookup
Zone files
Zone file records
Slave servers
Intranets and Dialup IP Connections
Introduction
The mapping between host names and IP numbers must be stored in a data base. If users do not know the IP number they can do a "lookup" on the data base.
The database could be centralised; but in the spirit of the internet which avoids reliance on any one point of possible failure it is distributed among the hosts on the internet.
Unfortunately (for the spirit of the internet) the naming scheme (called the domain name system) is based on a hierarchy and so there is a need for some central coordination of the names of countries.
The IP of a machine in Iceland can be found only if I know which computers store the data base parts for Iceland. Therefore there must be some central place(s) where locations of the countries of the world are stored. (or in the case of the USA which has no country code the parts of the internet like com and edu).
Root DNS Servers
The computers that provide the information about the databases in different countries are called root servers.
There are currently 13 root servers named:
?.root-servers.net where ? is replaced by the letters a to m.
These are mostly located in USA but one is in Japan and another in Europe.
The root servers are all updated from a common file. In July 1997 a corrupted version of this file was loaded onto all the root servers and as a result a lot of IP number lookups failed.
Now questions are being asked about the sense of having such a centralised point of failure. Unfortunately the current distributed data base lookup procedure assumes the presence of root servers.
The names of root servers must be provided in a file (root.cache) when DNS starts up.
Domains and Zones
A domain is the entire set of machines that are contained within a domain name.
Example
unisa.edu.au domain has all the machines at the University of SA
A zone is the set of hosts for which a particular DNS server is authoritative.
Example: the authoritative nameserver for the domain levels.unisa.edu.au runs on the host lv.levels.unisa.edu.au. Thus all the hosts with names ending in levels.unisa.edu.au are in the zone of the DNS server on lv.levels.unis.edu.au.
A name server can control several zones at once.
A forwarders host is a place we can refer request that we cannot answer—usually the name server for the domain above.
A (non typical) DNS Lookup
The following example is not typical because of caching (see later) but this procedure is carried out at least once every few hours.
Example: lookup the IP number of www.unisa.edu.au
Step 1. Find out where the Australian (au) data base is stored.
ares>/usr/sbin/nslookup
Default Server: lux.levels.unisa.edu.au
Address: 130.220.16.65
We do not want to use this server because its not a root - server....
> server b.root-servers.net
Default Server: b.root-servers.net
Address: 128.9.0.107
Look for data base records that point to Name Servers
> set type=ns
Find all the name servers for domain au.
> au.
Server: b.root-servers.net
Address: 128.9.0.107
Non-authoritative answer:
au nameserver = MULGA.CS.MU.OZ.au
au nameserver = JATZ.AARNET.EDU.au
au nameserver = NS.UU.NET
au nameserver = NS.EU.NET
au nameserver = NS1.BERKELEY.EDU
au nameserver = NS2.BERKELEY.EDU
au nameserver = VANGOGH.CS.BERKELEY.EDU
au nameserver = MUNNARI.OZ.au
Authoritative answers can be found from:
MULGA.CS.MU.OZ.au internet address = 128.250.1.22
MULGA.CS.MU.OZ.au internet address = 128.250.37.150
JATZ.AARNET.EDU.au internet address = 139.130.204.4
NS.UU.NET internet address = 137.39.1.3
NS.EU.NET internet address = 192.16.202.11
NS1.BERKELEY.EDU internet address = 128.32.206.9
NS1.BERKELEY.EDU internet address = 128.32.136.9
NS2.BERKELEY.EDU internet address = 128.32.206.12
NS2.BERKELEY.EDU internet address = 128.32.136.12
VANGOGH.CS.BERKELEY.EDU internet address = 128.32.33.5
MUNNARI.OZ.au internet address = 128.250.22.2
MUNNARI.OZ.au internet address = 128.250.1.21
Step 2 Find out where the edu.au database is stored—all the hosts listed above will know where edu.au is kept. Just choose one.
> server munnari.oz.au
Default Server: munnari.oz.au
Addresses: 128.250.1.21, 128.250.22.2
> edu.au.
Server: munnari.oz.au
Addresses: 128.250.1.21, 128.250.22.2
edu.au nameserver = ns1.berkeley.edu
edu.au nameserver = ns2.berkeley.edu
edu.au nameserver = jatz.aarnet.edu.au
edu.au nameserver = munnari.oz.au
edu.au nameserver = mulga.cs.mu.oz.au
ns1.berkeley.edu internet address = 128.32.206.9
ns1.berkeley.edu internet address = 128.32.136.9
ns2.berkeley.edu internet address = 128.32.136.12
ns2.berkeley.edu internet address = 128.32.206.12
jatz.aarnet.edu.au internet address = 139.130.204.4
munnari.oz.au internet address = 128.250.1.21
munnari.oz.au internet address = 128.250.22.2
mulga.cs.mu.oz.au internet address = 128.250.1.22
mulga.cs.mu.oz.au internet address = 128.250.37.150
edu.au data base is also on the au servers.
Step 3 Find unisa.edu.au data base
> unisa.edu.au.
Server: munnari.oz.au
Addresses: 128.250.1.21, 128.250.22.2
Non-authoritative answer:
unisa.edu.au nameserver = sacomm.schulz.unisa.edu.au
unisa.edu.au nameserver = lv.levels.unisa.edu.au
Authoritative answers can be found from:
sacomm.schulz.unisa.edu.au internet address = 136.169.13.1
lv.levels.unisa.edu.au internet address = 130.220.16.6
Step 4. Choose one of the servers above and lookup again.
> server lv.levels.unisa.edu.au
Default Server: lv.levels.unisa.edu.au
Address: 130.220.16.6
> www.unisa.edu.au.
Server: lv.levels.unisa.edu.au
Address: 130.220.16.6
www.unisa.edu.au canonical name = Adminserv2.schulz.unisa.edu.au
schulz.unisa.edu.au nameserver = LV.Levels.unisa.edu.au
schulz.unisa.edu.au nameserver = ntx.City.unisa.edu.au
schulz.unisa.edu.au nameserver = ns.saard.net
LV.Levels.unisa.edu.au internet address = 130.220.16.6
ntx.City.unisa.edu.au internet address = 136.169.24.29
ns.saard.net internet address = 203.21.37.18
Change to looking for IP numbers of hosts
> set type=any
Step 5. Lookup the web server host
> Adminserv2.schulz.unisa.edu.au.
Server: lv.levels.unisa.edu.au
Address: 130.220.16.6
Adminserv2.schulz.unisa.edu.au internet address = 136.169.13.113
Schulz.unisa.EDU.AU nameserver = LV.Levels.unisa.EDU.AU
Schulz.unisa.EDU.AU nameserver = ntx.City.unisa.EDU.AU
Schulz.unisa.EDU.AU nameserver = ns.saard.net
LV.Levels.unisa.EDU.AU internet address = 130.220.16.6
ntx.City.unisa.EDU.AU internet address = 136.169.24.29
ns.saard.net internet address = 203.21.37.18
So www.unisa.edu.au IP= 136.169.13.113!
Caching of DNS entries
Every time a DNS server looks up an IP addresses it stores both the address and the place where the authority was located (the NS record) in memory.
This means that almost all the requests that would have been sent to the root servers never actually get past the local name server.
Addresses are stored in the name servers cache. (data segment in memory only) The cache is lost if the name server process is killed (ie the machine is rebooted)
Each DNS entry has time to live (TTL) which determines how the long record can remain in cache. If new entries are cached faster than old ones expire the name server process size may exceed the OS limits and be killed.
Resolvers—Recursive Lookup
The resolver is the client to the name server. It cannot make intelligent requests for resolution so most complex requests are performed by the name server on behalf of the resolver client.
If the resolver requests a recursive lookup then the name server keeps sending out DNS questions until an IP number is obtained or all authorities are queried.
DNS message structure
(nslookup with "set debug=on")
A DNS message consist of:
1. Header (flags,error messages...)
2. Question section (room for one question)
3. Answer section (answer plus resource records)
4. Authority section (list names servers where the question can be answered)
5. Additional information
Example
> set debug=on
> ogrady.com.
Server: lux.levels.unisa.edu.au
Address: 130.220.16.65
res_mkquery(0, ogrady.com, 1, 1)
------------
Got answer:
HEADER:
opcode = QUERY, id = 5, rcode = NOERROR
header flags: response, want recursion, recursion avail.
questions = 1, answers = 1, authority records = 2, additional = 2
QUESTIONS:
ogrady.com, type = A, class = IN
ANSWERS:
-> ogrady.com
internet address = 206.3.216.222
ttl = 58144 (16 hours 9 mins 4 secs)
AUTHORITY RECORDS:
-> ogrady.com
nameserver = NS2.ILIAD.COM
ttl = 144260 (1 day 16 hours 4 mins 20 secs)
-> ogrady.com
nameserver = NS.ILIAD.COM
ttl = 144260 (1 day 16 hours 4 mins 20 secs)
ADDITIONAL RECORDS:
-> NS2.ILIAD.COM
internet address = 206.3.216.3
ttl = 134820 (1 day 13 hours 27 mins)
-> NS.ILIAD.COM
internet address = 206.3.216.2
ttl = 134820 (1 day 13 hours 27 mins)
------------
Non-authoritative answer:
Name: ogrady.com
Address: 206.3.216.222
The "non-authoritative answer" means the address came from the cache on lux rather than directly from the authoritative name server.
Reverse lookup
It is also possible to find the name of a host given its IP number.
> 127.17.220.130.in-addr.arpa.
Server: lv.levels.unisa.edu.au
Address: 130.220.16.6
127.17.220.130.in-addr.arpa name = EEDAK.levels.unisa.edu.au
220.130.in-addr.arpa nameserver = LV.levels.unisa.edu.au
220.130.in-addr.arpa nameserver = sacomm.Schulz.unisa.edu.au
220.130.in-addr.arpa nameserver = ns.saard.net
220.130.in-addr.arpa nameserver = ns.adelaide.edu.au
LV.levels.unisa.edu.au internet address = 130.220.16.6
sacomm.Schulz.unisa.edu.au internet address = 136.169.13.1
ns.saard.net internet address = 203.21.37.18
ns.adelaide.edu.au internet address = 129.127.40.3
Note that the IP is written backwards and the special domain in-addr.arpa is used.
Many TCP/IP services, for example, the World Wide Web, NFS, rlogin, and FTP, use reverse lookup to verify that incoming connections are from a legitimate computer.
Reverse lookup depends on the DNS server having extra records (called PTR records) inserted in its data base file. These are not automatically generated from the records (called A records) giving the IP number for a host name.
If both an A record and a PTR record are registered for the incoming client, the server assumes that a responsible network administrator has assigned this name and address. If the information in the DNS is incomplete or missing, many servers will reject connections from the client.
Zone files
Each DNS server has configuration files (called zone files) that contain the data base for the zone it controls and also information it provides for other DNS servers so they know which zone it is responsible for.
Zone File Records
The SOA record tells other names servers about host performing the DNS task and the extent of the zone for which it is responsible.
NS records tell where (eg root servers) information about other domains can be found.
A records give the IP numbers of zone hosts.
PTR records give the domain names of IP numbers in the zone.
MX records specify where to send mail for the hosts in the zone. Not all mail host addresses will have IP numbers.
forwarder records point to where questions the DNS server cannot answer can be sent.
secondary records declare other DNS servers as slaves. The data base in the slave is just a copy of the data base in the primary.
If the primary DNS server is down the slave server can be used instead.
Slave Servers
How does the server outside the zone decide which slave server to use:
A name server looking up a name first needs the list of NS records for the zone the name belongs to. How does the querying name server decide which NS record to use, which authoritative name server or slave to ask?
The querying name server calculates and stores a round trip time (RTT) for each slave name server for a zone. It uses the name server with the lowest RTT. After a name server is queried, the querying name server updates its RTT.
When a name server first caches a list of NS records, the RTT for all of them is set to zero. Because it chooses among name servers with equal RTTs at random, each name server will be queried once. From then on, it favours the name server with the lowest RTT. Whenever a querying name server consults the name server with the lowest RTT, it decrements all the other name server's RTTs a little bit. Over time, the other RTTs creep down and will eventually be queried. Of course, if they are slow to respond, their RTT goes back up andthey're not consulted again for a while.
Intranets and Dialup IP Connections
If you want an intranet without any connection to the outside world you can ignore the root servers file and use IP numbers anyway you like.
If you have a dial up IP connection however the IP numbers must be registered in some way or the dialup host must change all the IP numbers in IP packets going out.
When the dialup line is operating the root servers file is needed if you want to lookup outside the intranet.
Solution is to reboot the DNS server every time the dialup line is brought up or down.