Keywords:
DNS Linux Redhat
Install DNS
Configuration File: File Name and source/etc/named. conf,/var/named. Local,/var/named. Ca (caching-nameserver-7.2-7.noarch.rpm)
/Etc/resolv. conf system comes
Installation:
B. Start the service
/Etc/rc. d/init. d/named start
Service named start
C. Stop the service
PS-Ef | grep named # Find the process number
Kill process number
D. Detection
Modify/etc/resolv. conf
NSLookup
> 127.0.0.1
> Localhost
Configuration File Parsing
Basically, the main configurations of BIND are put in the/etc/named. conf file! However, for the hostname <--> ip ing relationship, you need to set it by zone! However, the name of this zone is specified in/etc/named. conf! Therefore, please note that the name of each zone is variable, but you need to name it in/etc/named. conf! In addition, it is best to place the zone file directly to the default directory of BIND, that is,/var/named! This is better management!
Configuration file instance:
/Etc/named. conf is the primary DNS configuration file!
[Root @ wljs root] # vi/etc/named. conf
Options {
Directory "/var/named"; // This is in the provision of "forward and reverse file decoding"
// Directory to be placed ", default directory
};
// First define the content of the file whose type is. (Root) hint.
Zone "." {// defines the root
Type hint; // The selected type is hint (. Dedicated)
File "named. ca"; // default file name: Named. ca
}; // Sometimes it may be named. Root!
// In the DNS database, the named. Ca file lists the addresses of all root DNS servers!
/// Then define the Positive and Negative Solutions of localhost.
Zone "localhost" {// This zone is used to resolve the localhost domain name!
Type master; // The main setting file on the local machine!
File "named. localhost"; // File Name of the forward solution! You can enjoy it as you like!
};
Zone "0.0.127.in-ADDR. Arpa "{
// Reverse IP address segment! That in-addr.arp
// It is a fixed IP segment!
Type master;
File "named.127.0.0"; // any name!
};
// Note: When writing Reverse Address Resolution
// The IP address order is the opposite!
// Define the Positive and Negative Solutions of your own domain!
Zone "wljs.edu.cn "{
// Assume this is the domain name you want to define
Type master;
File "named.wljs.edu.cn ";
};
Zone "162.45.210.in-ADDR. Arpa "{
Type master;
File "named.210.45.162 ";
};
Note:
1. Directory: this value is the directory placed in each zone file. For example, when the file named. localhost is in the correct zone of localhost, the path of this file is in/var/named. localhost!
2. About. (Root): the most important thing about root is that the value of type is hint! Remember to write it right!
3. Positive and Negative Solutions for localhost: The names of files can be set at will. However, you should pay special attention to the domain name after that zone!
4. Positive and Negative Solutions for other domains: in fact, it is no different from localhost, just because the domain name is different!
5. Anti-solution Syntax: the anti-solution zone has a special syntax. It must write the IP address in turn, for example, 127.0.0.0/24, it must be written in the form of 0.0.127 in turn! Among them need to pay attention to is, the last must add a in-addr.arpa! Don't forget it!
Configuration file named. Local
Named. local stores the forward resolution of localhost. Its content is as follows:
[Root @ localhost root] # vi/var/named. Local
$ TTL 86400
@ In SOA localhost. Root. localhost .(
2002120601; Serial
28800; refresh
14400; retry
720000; expire
86400); Minimum
@ In NS localhost.
Localhost. In a 127.0.0.1
Note:
1. $ TTL 86400; this is related to the time when the cache is cleared! Unit: Second! It defines how long records can be stored in the DNS cache for external queries! This value is too big or too small! TTL is time to live!
2. @ indicates the part defined by zone! Take the content of this file as an example. in/etc/named. conf, we define localhost as a zone. Therefore, here, this symbol represents localhost!
3. SOA: Start of authority! That is, the setting next to it is about to begin! This exists in every zone file!
4. There will be two more parts after SOA. The first one is the host name (localhost.). Please note that there is a decimal point (.) next to the localhost. This is very important! It represents "a complete hostname + domain name 』! If (.) is not added, it indicates that the text is "hostname only, and domain name" must be added 』! This is the most common mistake for beginners! The second is administrator's email! Because @ (which is already a special symbol) cannot be used, it is also replaced by (.) Here! For example, I used root @ localhost
As my e-mail, so I wrote it as root. localhost. Similarly, there is a (.) at the end (.)!
5. the scratch sign () contains five numbers. Except for the minimum and TTL values, the five numbers are related to the synchronization of slave and master data!
Serial: This number is only used as a reference value for the update between the master and slave. That is to say, when the serial of the slave is smaller than the master, the update operation will take effect! Generally, we use time as the basis for serial. For example, if we set the time for the first time in December 6, 2002, we can write it as "2002120601". Please note that this number cannot exceed 10 digits.
Refresh: How long does slave Take to actively update?
Retry: If the refresh time is reached, but slave cannot connect to the master, after which, slave will attempt to connect to the host again;
Expire: If slave has been unable to connect to the master, after how long will it take, the command slave should not connect to the master again!
Minimum: This is actually TTL! If you do not define TTL, set the TTL value here!
6. @ in NS localhost.; NS indicates the meaning of name server, followed by "hostname or FQDN". This indicates that the previous domain is managed by this host! This line means that the name server managed by @ (zone, that is, the domain localhost) is the host localhost. Note that the localhost must be followed! Why? If (.) is not added, the host name will be changed to localhost. localhost.
! Why? This is because in the default bind scenario, if no. is written, it indicates that the name is hostname, and domain name must be added!
7. localhost. In a 127.0.0.1
This statement specifies the ing between the host and the IP address! It is usually expressed as a positive solution. Because name server is the host name, the forward solution of name server will be added later.
/Var/named/named.127.0.0
The/var/named/named.127.0.0 file is the reverse file of localhost!
[Root @ localhost named] # vi named.127.0.0
# The file name is set in/etc/named. conf.
$ TTL 600
@ In SOA localhost. Root. localhost. (2002120601; Serial
28800; refresh
14400; retry
720000; expire
86400); minimum;
@ In NS localhost.
1 In PTR localhost.; PTR is the reverse decoding symbol!
; IP-> host
Named.wljs.edu.cn
$ TTL 86400
@ In SOA jsj1.wljs.edu.cn. root.wljs.edu.cn .(
2004102901; Serial
28800; refresh
14400; retry
720000; expire
86400); Minimum
@ In NS jsj1.wljs.edu.cn.
@ In MX 10 jsj1.wljs.edu.cn.
Jsj1 in a 210.45.162.14
Jsj2 in a 210.45.162.30
Jsj1 in TXT "Red Hat Linux 9"
WWW in cname jsj1.wljs.edu.cn.
Note:
1. mx: Short for mail exchanger (MX). It specifies the mail distribution server! Specifies a proxy mail distribution server to receive emails from the internet! Then, the proxy mail delivery server will distribute the mail to the corresponding host!
2. txt: Description section!
3. cname: Specifies the host alias.
$ TTL 86400
@ In SOA jsj1.edu.cn. root.jsj1.edu.cn .(
2004102901; Serial
28800; refresh
14400; retry
720000; expire
86400); Minimum
@ In NS jsj1.wljs.edu.cn
In PTR jsj1.wljs.edu.cn.
30 in PTR jsj2.wljs.edu.cn.
/Var/named. Ca file of the primary DNS Server
The named. Ca file in the DNS database provides the address of the root DNS server. When a DNS request exceeds the domain proxy range, the DNS server sends the request to the root DNS. The named. Ca file contains information about the root name server!
This file usually does not need to be modified! However, a good system administrator should update this file frequently because the sites in this file will change with the changes in the network!
Test
After the file is configured, test it:
1. Start the service:/etc/rc. d/init. d/named start
2. Modify the name server of the/etc/resolv. conf file to 210.45.162.14.
3. NSLookup
> Jsj1.wljs.edu.cn
> Jsj2.wljs.edu.cn
> 210.45.162.14