1. Universal theory
The DNS servers are divided into:
Master (Primary DNS server): A file that has zone data and manages the entire zone's data.
Slave (from a server or a secondary server): a copy of the zone file with the primary DNS service, the secondary primary DNS server resolves the client, and when the primary DNS server is broken, the primary server can be completely replaced.
Forward: Forwards any query requests to other servers. Play a role as an agent.
Cache: Caching the server.
Hint: Root DNS Internet server set.
2. Software Installation
#For Debian/ubuntu
Apt-get Install bind*
#For Centos/fedora/redhat
Yum Install bind*
The other needs to install the appropriate installation package according to its own function.
3. Configure
With the following command
Cat/etc/sysconfig/named
You can see where the system is pointing the named directory.
/etc/sysconfig/named #由该文件控制是否动chroot及其他参数
/etc/named.conf #配置文件
/var/named/#数据库文件 (such as forward, reverse, root file) storage location
/var/run/named: #named程序默认将pid文件放置此目录下
The main need to configure the files here is/etc/named.conf
Vim/etc/named.conf
#修改文件 idea of any place according to your own needs
Options {
listen-on port {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";
Query-source Port 53;
QUERY-SOURCE-V6 Port 53;
allow-query {any;};
};
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";
};
If I want to bind ryan.com to 192.168.0.5
Vim/etc/named.rfc1912.zones
#附加以下内容并保存
Zone "Ryan.com" in {
Type master;
File "Ryan.com.zone";
allow-update {none;};
};
Zone "Ryan.com-arpa" in {
Type master;
File "Ryan.com.arpa";
allow-update {none;};
};
Then create a new two files separately
Vim/var/named/ryan.com.zone
#插入以下内容并保存
$TTL 1D
@ in SOA ryan.com. Root. (
0; Serial
1D; Refresh
1H; Retry
1W; Expire
3H); Minimum
@ NS ryan.com.
@ A 192.168.1.5
www A 192.168.1.5
* A 192.168.1.5
Vim/var/named/ryan.com.arpa
#插入以下内容并保存
$TTL 1D
@ in SOA ryan.com. Root. (
0; Serial
1D; Refresh
1H; Retry
1W; Expire
3H); Minimum
@ NS ryan.com.
@ A 192.168.1.5
5 PTR Www.111cn.net
The above edits basically completes the basic configuration, next modifies your machine domain name resolution
Vim/etc/resolv.conf
#修改 (not added) point to the machine IP where DNS resides
NameServer 192.168.0.5
To the end of this configuration.
4. Test
#设置开机启动
Chkconfig named--level 235 on
#开启dns Server
Service named start
#如已经开启请使用下面的命令重启
Service named restart
Then enter in the terminal
Nslookup
#enter进入nslookup的会话后直接输入需要测试的域名看看返回的结果是否正确如:
Vkilo.ryan.com
There are also some test orders, such as Dig, based on personal preferences and requirements. And the master and the slave here are no longer burdensome.
< wrap up >