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 126.96.36.199 nameserver 188.8.131.52
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: 184.108.40.206 Address: 220.127.116.11#53 Non-authoritative answer: Name: www.johnreed.co.uk Address: 18.104.22.168
As you can see from the output above, our request went to DNS server 22.214.171.124 on port 53.
For an overview of Linux's network configuration files visit our Network Configuration Files