You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!

Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.

If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.

Having a problem logging in? Please visit this page to clear all LQ-related cookies.

Introduction to Linux - A Hands on Guide

This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.

When you're browsing LinuxQuestions, your computer doesn't send data to www.linuxquestions.org. It sends to 64.179.4.146. You don't have to remember the numerical address - DNS servers do it for you.

This text was written to tell you what DNS is, how it works and how you can use it. It doesn't describe configuration of your own DNS server.

Before I describe how the DNS system works, you need to know about IP adresses and domains.

IP adresses

64.179.4.146 is an example. IP (Internet protocol) address has a form of four numbers (between 0 and 255), separated by dots. Each machine in the Internet must have an unique IP address. It works as a postal address - no message can reach the machine without a correct address.

Numbers are friendly for machines, but hard to remember for humans. That's why we have hostnames and domains (there are more reasons, for example names allow you to easily change IP addresses of servers - only the DNS entry must be changed).

Hostnames, domains, zones

An example of a hostname: www.linuxquestions.org. It's a part of linuxquestions.org domain. Last portion of the address (.org) refers to a toplevel domain where the host belongs. Other toplevel domains are: .com, .net, .gov etc. Every country has its own toplevel domain. For example: .fr (France), .de (Germany), .jp (Japan) or .br (Brazilia).

Zone and domain mean nearly the same. There's one difference: zone is delegated to one server. A domain can be diveded into different zones.

How it works?

When you connect to LQ, you send a query to your DNS resolver (more about it later). The server checks if it has needed information cached. If it does, it sends it back to you. The server that stores data from previous queries is called a caching nameserver.

If it doesn't have the information you're searching for, it asks one of the root servers. Root servers are on the top of DNS servers tree (the structure looks like a tree). They contain pointers to name servers for each top level domain.

Now the toplevel domain server for .org is asked about linuxquestions.org domain, it knows the address of the server containing detailed information about all hosts in the linuxquestions.org domain.

The last server is asked about the host www.linuxquestions.org hosts. When your resolver server gets the reply, it sends the result back to you.

Types of DNS servers:

A caching nameserver finds answers to queries and then remembers them. This not only speeds up your response time but helps to keep the load on the root nameservers (which handle thousands of queries per second) as low as possible.
An Authoritative server is a server that can answer queries about a zone without help from any other server. Both primary and secondary servers are authoritative.Primary server(in terms of specific zone) is a server that reads zone data from its local configuration.Secondary server(in terms of a specific zone) gets zone data from outside sources (usually from master server).

How to use DNS servers?

The file with IP addresses of your nameservers is /etc/resolv.conf. When the machine is correctly configured, it should look like this:

Code:

nameserver 192.168.1.1
nameserver 192.168.1.3

DNS servers are listed in lines beginning with 'nameserver' (there are more things to configure in that file). In the example above there are two DNS servers: 192.168.1.1 and 192.168.1.3 (don't copy them, local addresses are used and it may not work in your network).

There's one more important file - /etc/host.conf. It should look like below:

Quote:

order hosts,bind
multi on

When the file is filled properly, everything should work fine.

Where to get the addresses from?

Your ISP is the best source. Most ISPs have their own DNS servers. They're closest to you (so should be the fastest).

If you're using DHCP (many ADSL connections) or modem, your ISP may pass the information to you when you connect. In such case, you don't need to edit /etc/resolv.conf manually.

How to test it?

You can use 'nslookup' or 'dig'.
First example, using nslookup:

Code:

sh-2.05b$ nslookup www.linuxquestions.org
Note: nslookup is deprecated and may be removed from future releases.
Consider using the `dig' or `host' programs instead. Run nslookup with
the `-sil[ent]' option to prevent this message from appearing.
Server: 192.168.1.1
Address: 192.168.1.1#53
Non-authoritative answer:
Name: www.linuxquestions.org
Address: 64.179.4.146

As you can see it gives the same answer as we got when ping was used.

Next example, using 'dig'. The command format is:

Code:

dig @DNS_server host

It returns more information, so may be harder to read. I'm asking the server 192.168.1.1 about www.linuxquestions.org. You don't need to give the DNS server. If you simply use 'dig.linuxquestions.org', your default DNS server will be used. In the 'ANSWER SECTION' you can see that www.linuxquestions.org is 64.179.4.146. In the line 'Query time' you can see how much time it takes to get an answer. In the example below the time is very short, because I use caching nameserver.

/etc/resolv.conf only has effect if the keyword "dns" occurs in the file /etc/nsswitch.conf.

This file is commonly called the "Name Service Switch" and it determines where your system looks for information; for example, you might use NIS or LDAP for hostname/IP address lookups (though I don't recommend it) and not use DNS at all. A common alternative to DNS is the /etc/hosts file, for another example. The NSS determines where the system looks for name data.

by huangzen on Fri, 2004-05-21 01:54

How does it works...? I register a domain name by paying them right? for example www.names4ever.com. So i owned that name. I login to their admin control panel and "manage name server" it's showing ns1.abac.com and ns2.abac.com is that my name server? how do "they" know I own that domain and I want it to point to my linux box? how?

by Mara on Fri, 2004-05-28 17:35

If you register a domain name you need to have your own name servers. The servers 'above' know only that your domain exists and which server (servers) should be asked for details. The information that your domain points to a specific IP is kept in your nameservers.
From what you write it looks like the company you buy the domain from allows you to use their nameservers, so they work as yours.

by huangzen on Fri, 2004-05-28 23:30

well yeah they let me use their DNS server but I only can put in ns1.abac.com and ns2.abac.com. I couldn't tell them which IP my server is located at... what should I do??

by Mara on Mon, 2004-05-31 15:11

I don't know the administration panel you use, but there should be an option to change default DNS servers (or just add your own as the primary one) and add/modify hostnames. When you have your own machine set as primary DNS you can do everything with your domain.

by huangzen on Mon, 2004-05-31 18:58

yea they do have a place for me to put in default DNS. I put in ns1.abac.com and ns2.abac.com that's all I can do with my dns.. is that all I needs to do? and is that all most people can do with their Domain name just to assign their prime DNS.

by Mara on Tue, 2004-06-01 16:58

If you can put name of a server you have BIND or other DNS software running, you can add different hostnames to your domain, create subdomains (so you can have hosts like here.myhome.mydomain.org) and some more things. I don't know a company registering domains that doesn't allow you to have your own primary DNS...To have it you just need a machine with static IP (important) and DNS serve software installed. Of course, you'd need to configure it, but it's not hard and there are tutorials.

by lukeh on Tue, 2004-08-24 01:08

Hey,
If your want to make your dns updating easier then setting up your own name server then register with http://www.dyndns.com or something similar... set it up with your domain name and download the dynamic updater to update your ip with the domain name.

by john123paul on Tue, 2005-08-09 01:45

Can any one help me how to configure DNS server.

by john123paul on Tue, 2005-08-09 01:48

I configured DNS server But I couldnt run it successfully
Can any one giv me a web page which has DNS how to