Linux - DNS

An Introduction to Names and DNS

Networking with DNS


As we have seen earlier, IP addresses are used to uniquely identify systems on a network. However, because of the numbering format that is used by the IP addressing schemes, it is not always easy to remember the IP address of a website. Imagine how difficult it would be if you had to remember the IP address to all the sites you visit! Well thankfully we do not have to remember IP addresses as we are helped by a system called DNS (Domain Name System). DNS is basically a globally distributed database of IP addresses, hostnames and various other information. Most ISPs have their own DNS servers, normally a primary and secondary server for redundancy. Your requests will go to these DNS servers first asking for an IP address. Individual DNS servers do not know the name of every server. To get around this a hierarchy of DNS servers exists:



Root Level Name Servers - know about the information to the right of the name. For example a root level server contains information for names like ".co.uk", ".de", ".nl". These root level servers know which servers should then handle these requests.

So when you type a web address into your browser, a request is made to a root level name server. Your request is than passed out to a name server which handles the country suffix, this in turn is then sent to another name server which knows about the domain you are looking for. Finally the name is then cross referenced to an ip address.

A list of your DNS servers can generally be found within a file called "/etc/resolv.conf". Normally there will be more than one entry for redundancy.

Example of entries from my "/etc/resolv.conf"



nameserver 194.168.4.100
nameserver 194.168.8.100

In the above example, any requests would go to the first server listed.

To see which server our request will go to we can use a command called "nslookup". We will look at this command later in a little more detail. We could have also used a command called "dig" to obtain the same information.



john@john-desktop:~$ nslookup www.johnreed.co.uk
Server:		194.168.4.100
Address:	194.168.4.100#53

Non-authoritative answer:
Name:	www.johnreed.co.uk
Address: 217.10.138.186

As you can see from the output above, our request went to DNS server 194.168.4.100 on port 53.

For an overview of Linux's network configuration files visit our Network Configuration Files