DNS--搭建主服务器

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了DNS--搭建主服务器相关的知识,希望对你有一定的参考价值。

主服务器的概念我理解成比如一个公司的网站如何能得到解析,就需要在主服务器上添加区域文件,首先在主服务器上的配置文件中监听端口ip设置好,递归关闭,将根域文件删除或注释掉,建立一个gz.com的区域文件,类型是master,并注意文件路径/var/named/gz..com.zone
技术分享图片
[[email protected] named]# vim /etc/named.conf

options {
listen-on port 53 { 192.168.10.11; };
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";
allow-query { any; };

    recursion no;

    dnssec-enable yes;
    dnssec-validation yes;

    bindkeys-file "/etc/named.iscdlv.key";

    managed-keys-directory "/var/named/dynamic";

    pid-file "/run/named/named.pid";
    session-keyfile "/run/named/session.key";

};

logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};

zone "gz.com" IN {
type master;
file "/var/named/gz.com.zone";
};

#include "/etc/named.rfc1912.zones";
#include "/etc/named.root.key";
保存退出,并去建立该文件/var/named/gz.com.zone,默认文件不存在,需要自行建立
[[email protected] named]# cd /var/named/
[[email protected] named]# ll
总用量 16
drwxrwx--- 2 named named 23 3月 17 10:20 data
drwxrwx--- 2 named named 6 8月 4 2017 dynamic
-rw-r----- 1 root named 2281 5月 22 2017 named.ca
-rw-r----- 1 root named 152 12月 15 2009 named.empty
-rw-r----- 1 root named 152 6月 21 2007 named.localhost
[[email protected] named]# cp named.localhost gz.com.zone
[[email protected] named]# vim gz.com.zone
$TTL 1D
@ IN SOA server-124.gz.com. tt.qq.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
@ NS server-124.gz.com.
server-124 A 192.168.10.11
www A 192.168.10.8
ftp A 192.168.10.10
保存退出,注意这个文件必须让named用户可读
[[email protected] named]# ll
总用量 20
drwxrwx--- 2 named named 23 3月 17 10:20 data
drwxrwx--- 2 named named 6 8月 4 2017 dynamic
-rw-r----- 1 root root 272 3月 17 19:29 gz.com.zone
[[email protected] named]# chown named gz.com.zone
[[email protected] named]# systemctl reload named

在客户端将dns指向192.168.10.11,验证:
[[email protected] ~]# nslookup www.gz.com
Server: 192.168.10.11
Address: 192.168.10.11#53

Name: www.gz.com
Address: 192.168.10.8

[[email protected] ~]# nslookup ftp.gz.com
Server: 192.168.10.11
Address: 192.168.10.11#53

Name: ftp.gz.com
Address: 192.168.10.10
成功解析!

以上是关于DNS--搭建主服务器的主要内容,如果未能解决你的问题,请参考以下文章

DNS--搭建主服务器

主从DNS服务器的搭建八步骤

搭建主从DNS服务器

简述DNS服务器原理,并搭建主-从服务器

Linux下的DNS服务器搭建

搭建DNS服务,构建主从域名服务器