|
|
S'il n'y a pas de solution c'est qu'il n'y a pas de problème! |
|
|
Introduction
When I moved to Nerim ISP, I got a static IP, so I decided to buy a domain name at Gandi and to setup my own DNS.
I did not find that setting up a DNS was straightforward (configuration file syntax looks like Stone Age :)) and some friends of Linux-sottises pushed me to write down a light manual for bind.
This page is based on DNS-HOWTO, which is useful, but a little "dark" in some places... I also used the book DNS and Bind from Paul Albitz & Cricket Liu at O'Reilly. Obviuously, this pages has not the ambition to replace this book, but should help people to setup a primary DNS, while understanding "a little" what they are doing :) Some words on how DNS work To begin, some words to briefly (and naturally incompletely) explain how the resolution works: what happens when you type www.domain.com in your prefered browser? Well, your browser must find what is the IP corresponding to www.domain.com, because you already knwo that every server on the Internet is known by its IP adress. A programm which looks for an IP from a name (or a name from an IP) is called a resolver. The full information of these associations "name-IP" is "distributed" among the Internet and not stored in a unique place. Nowhere exists a machine with all this information! Then begins a "treasure hunt" in which several machines will give a "clue", a piece of information to the resolver to help it to find the adress of www.domain.com. The resolver will first ask a question to "God" for a first clue: who is in charge of names ending by .com? God here are the root DNS servers which adresses are in /var/named/root.hint (have a look at this file, I will tell you further how to maintain this file) On of the root server will tell the resolver which DNS are in charge of .com domains. Those servers are called GTLD servers (Generic Top Level Domains). The resolver will then ask one of those GTLD servers ot ask: who is in charge of domain.com? With the adresses of those servers, the resolvers wil ask one of then: what is the adress of www.domain.com? and the resolver job is over. Naturally, ther would be a huge traffic if each time those operation were made. To avoid such traffic, each DNS has a cache system in which it looks if it already answered the same question... Ok, but what happens if the adress changed? Well, each DNS give the validity time for the information it gives at the ame time it gives an information. When this time is over, the answer is not taken in the cache, but a new question is asked. This cache behaviour exists at each level of DNS. Each DNS is responsible for the validity time (TTL=Time To Live): if TTL is very short, more traffic will be generated, if it is very long, it will take a long time for modification of the DNS to be taken into account by other DNS.
Practical test
then
(we are going to use root server a.root-servers.net). Type:
(with . th the end, which means "who is in charge of the branch .net? The list of GTLD servers in charge of .net appears. Chose one, for example:
Ask it who, is in charge of linux-sottises.net, type (do not forget the . at the end):
you have the information about the servers in charge of linux-sottises.net. You should have 3 servers: ns0.linux-sottises.net, ns6.gandi.net and metroid.nerim.net. Chose one of them, for example, type:
now ask it what is the adress of www.linux-sottises.net (with or without . at the end, at this level it is the same):
You get the adress 62.4.22.49 Setup A All that follows is about bind 8.2.3. Install it by a package from your distribution, or by compiling it from Internet Software Consortium.
You are the owner of a domain name, you have a static IP, you have chosen a name for your DNS (and have declared it when you baught your domain). You also knwo the the name and IP of the machine which will be used as secondary DNS.
There are two kinds of configuration files: the general configuration file of bind (in general /etc/named.conf) and the description files of the zones. Il y a deux types de fichiers de configuration: le fichier de configuration générale de bind (en général /etc/named.conf) et les fichiers de description de "zones" (in general in /var/named). When you install bind, you also have a file /var/named/root.hint or /var/named.root which contains the adresses of the root servers (you can also download it at ftp.rs.internic.net, directory /domain, file named.root) The file /etc/named.conf have different sections which describe options, logging, and the zones files names. An example is better: download or have a look at mine, and let us give some comments: The part between { }; contains all the options
Use man named.conf to see more options The logging part I use is simple and standard. Look man named.conf for more information. Then come the general caracteristics of the zones of your server. The first order "zone" is about the root of the name servers (.) and use the file root.hint (all the files are in the directory indicated at the beginning of the file). IN indicates an INternet class (in fact it is the only class really used). You can see here my file root.hint. Then comme the caracteristics of the "linux-sottises.net" zone which bind is master.
The next zone is a "reverse" zone (IP to name) and is about the local loop (the relation of the server with itself). The name before .in-addr.arpa will be used in the zone file, for example 0.0.127.in-addr.arpa will be able to describe adresses of the form 127.0.0.X Remark: if you suppress the master zone of the configuration file and keep the the part 0.0.127.in-addr.arpa and the corresponding file (see further), you have a simple DNS which will be useful when the DNS of your ISP are out! Let us go to the zone files. Download or have a look at linux-sottises.net which I stored in /var/named/zone as mentionned in bind configuration files.
Finally, you have to configure the reverse file for the local loop with name zone/127.0.0 din the configuration file /var/named.conf. You can download it or have a look here. There appears a new type of record: PTR, pointer. 1 at the beginning of the line means 127.0.0.1 If you want to see all these information "online", run:
without forgetting the last . For your own server, you still have to launch the named daemon from your boot srcipt or following the rules of your distribution How to keep a good root.hint file... You can maintain a "good" root.hint file (which does not vary a lot!!) with the script hintupdate that you can launch by cron every month or week if you are as paranoid as me!! There are french comments at the beginning of the script.... you need:
Naturally, comments or questions are welcome to tnka at linux-sottises.net |
|