The following content is reproduced from http://www.uusnn.com /? P = 117
Domain Name System (DNS) is a solution for name interpretation, and is also a commonly used name resolution solution. In Linux, the DNS server is based on the BIND software and uses the daemon named by configuring relevant files in the/etc and/var/named directories, provides resolution services between host names and IP addresses for clients on the network.
To install the DNS server, first check whether the DNS server has been installed and run the command [rpm-Qa | gerp bind] (the DNS server in Linux is implemented through the BIND software)
The software contained in the bind system includes:
Ø bind-*: DNS name server software.
Ø bind-devel-*: DNS development tool, not required.
Ø bind-utils-*: DNS testing tools such as dig and host-level NSLookup.
* Caching-nameserver-*: the basic configuration file of the cache DNS server, including the sample file/etc/named. conf and/var/named/localhost. Zone.
Define me-config-bind-*: Gui DNS Configuration tool.
Put the centos 5.4 installation CD into the optical drive, and enter the command on the terminal to mount the optical drive: Mount/dev/CDROM/mnt/CDROM
Go to the centos directory (CD/mnt/CDROM/centos) of the CD and install the following software package on the terminal. (You can also use yum for installation .)
This article uses Yum to install: Yum install bind * And then Yum install caching-nameserver *. these must be installed. If the former is not installed and the latter is run with the service named start command, the following error occurs:
Locating/var/named/chroot/etc/named. conf failed:
Configure the primary DNS Server
You can modify the DNS configuration file to configure the DNS server. The configuration files of the DNS server mainly include the following:
/Etc/named. conf ............... Global configuration file of the DNS server
/Etc/named. rfc1912.zones .............. Region configuration file of the DNS server
/Var/named. Ca ............ Directive file pointing to the Root Domain Name Server
/Var/named. loal ............ Files used for parsing local loopback addresses
/Var/named/localhost. Zone .............. Files used for parsing local loopback addresses
/Var/named/domainname. Zone ............. User-created local host region database file
There are two main DNS configuration files: one global configuration file and the other regional configuration file. The global configuration file is/var/named/chroot/etc/named. caching-nameserver.conf; the region configuration file is/var/named/chroot/etc/named. rfc1912.zones.
If you use yum for installation, the following software packages are installed:
Bind-devel-9.3.6-4.P1.el5_4.2
Ypbind-1.19-12.el5
Bind-9.3.6-4.P1.el5_4.2
Bind-libbind-devel-9.3.6-4.P1.el5_4.2
Bind-utils-9.3.6-4.P1.el5_4.2
Bind-chroot-9.3.6-4.P1.el5_4.2
Bind-libs-9.3.6-4.P1.el5_4.2
Bind-sdb-9.3.6-4.P1.el5_4.2
Caching-nameserver-9.3.6-4.P1.el5_4.2
Configure named. conf in the main configuration file
First, go to the/var/named/chroot/etc/directory, and configure the master configuration file named. conf in this directory.
Because the above software package is installed, a named is generated by default in this directory. CONF file, but this named. the conf file is just an explanatory document, so we need to use the following command to set named. copy the template of the conf file. The command is as follows:
# Cp-P named. caching-nameserver.conf named. conf
Modify the named. conf file as follows (red indicates the location to be modified ):
Options {
Listen-on port 53 {Any ;};
Listen-on-v6 port 53 {: 1 ;};
Directory "/var/named ";
Dump-file "/var/named/data/cache_dump.db ";
Statistics-file "/var/named/data/named_stats.txt ";
Memstatistics-file "/var/named/data/named_mem_stats.txt ";
// Those options shocould be used carefully because they disable port
// Randomization
// Query-source port 53;
// Query-source-v6 port 53;
Allow-query {Any ;};
Allow-query-Cache {localhost ;};
};
Logging {
Channel default_debug {
File "Data/named. Run ";
Severity dynamic;
};
};
View localhost_resolver {
Match-clients {Any ;};
Match-destinations {Any ;};
Recursion yes;
Include "/etc/named. rfc1912.zones ";
};
Add the following content to the region configuration file (named. rfc1912.zones) in this directory (based on your own situation ):
Zone "guoguang.com "{
Type master;
File "guoguang.com ";
};
Zone "1.168.192.in-ADDR. Arpa "{
Type master;
File "192.168.1.rev ";
};
Configure a forward and reverse parsing File
The files are in the same directory. After the chroot package is installed, you must configure the files to be in the/var/named/chroot/var/named/directory, in addition, there is a reverse template file in this directory. The template of the forward parsing file is: localdomain. Zone; the template of the reverse parsing file is: Named. Local.
First, go to the/var/named/chroot/var/named/directory and run the commands to copy the template files in the forward and reverse directions.
# Cp-P localdomain. Zone guoguang.com
# Cp-P named. Local 192.168.1.rev
When using the command, do not forget to add the parameter P, and then edit the forward resolution file (guoguang.com) and reverse resolution file (192.168.1.rev) respectively, as follows:
Parsing the configuration file (guoguang.com ):
$ TTL 86400
@ In SOA localhost root (
42; Serial (D. Adams)
3 h; refresh
15 m; retry
1 W; expiry
1D); Minimum
In NS localhost
Localhost in a 127.0.0.1
WWW in a 192.168.1.2
Mail in a 192.168.1.2
FTP in cname WWW
@ In MX 10 mail
Reverse resolution configuration file (192.168.1.rev ):
$ TTL 86400
@ In SOA localhost. Root. localhost .(
1997022700; Serial
28800; refresh
14400; retry
3600000; expire
86400); Minimum
In NS localhost.
1 In PTR localhost.
2 In PTR www.guoguang.com.
2 In PTR mail.guoguang.com.
The following describes how to configure the DNS Client and test whether the DNS server is running properly.
Configure DNS Client
If it is a Linux client, you can modify the configuration file to set it. You can also use the graphical interface settings. The configuration file of the command is set as follows: Open/etc/resolv. CONF file, add the following command to the file:
Nameserver 192.168.1.2
For a Windows client, go to the Internet Protocol (TCP/IP) check box, click Properties, and go to Internet Protocol (TCP/IP)] In the Properties dialog box, set the DNS server address.
DNS domain name resolution
Run the NSLookup command to test the function.
Test results in Linux:
[Root @ localhost ~] # NSLookup
> 192.168.1.2
Server: 192.168.1.2
Address: 192.168.1.2 #53
2.1.168.192.in-ADDR. Arpa name = www.guoguang.com.
2.1.168.192.in-ADDR. Arpa name = mail.guoguang.com.
> Www.guoguang.com
Server: 192.168.1.2
Address: 192.168.1.2 #53
Name: www.guoguang.com
Address: 192.168.1.2
> Mail.guoguang.com
Server: 192.168.1.2
Address: 192.168.1.2 #53
Name: mail.guoguang.com
Address: 192.168.1.2
Test in a Windows client:
In addition, in Linux, you can use the host command to test:
[Root @ localhost ~] # Host 192.168.1.2
2.1.168.192.in-ADDR. Arpa Domain Name Pointer www.guoguang.com.
2.1.168.192.in-ADDR. Arpa Domain Name Pointer mail.guoguang.com.
[Root @ localhost ~] # Host www.guoguang.com
Www.guoguang.com has address 192.168.1.2
[Root @ localhost ~] # Host mail.guoguang.com
Mail.guoguang.com has address 192.168.1.2
[Root @ localhost ~] #
If you can test the normal operation of the DNS server on the local machine (DNS server), but not on the client, it should be that the firewall of the server is not closed.