192.168.1.1-路由器设置 | 192.168.0.1-无线路由器设置

CentOS7 下DNS服务器的搭建

发布时间:2015-01-07 11:01

所谓DNS(Domain Name System,域名系统),因特网上作为域名和IP地址相互映射的一个分布式数据库,能够使用户更方便的访问互联网。通过主机名,最终得到该主机名对应的IP地址的过程叫做域名解析(或主机名解析)。DNS运行在UDP协议之上,使用端口号53。


下面开始在CentOS7下搭建DNS服务器的方法,仅供参考!


 

说明:本文只介绍chroot的方式,对于非chroot的方式不做介绍!


 

环境准备:

    1. 一台CentOS7的机器

    2. IP地址:192.168.0.254

    3. 主机名:server.luyouqiwang.com
 


 

开始搭建DNS

    1. 安装软件包
 

                # yum install bind  bind-chroot  bind-utils -y

        2. 开始配置(安装chroot软件包之后,DNS所有相关的文件均在/var/named/chroot/目录下)

                # cd /var/named/chroot/

                # cp /etc/named.conf  ./

                # chgrp named named.conf

                # vim named.conf

                        options {

                                    listen-on port 53 {any;};

                                    directory  "/var/named";

                        };

                        zone "." IN {

                                    type hint;

                                    file "named.ca";

                        };

                        zone "example.com."  IN {

                                    type master;

                                    file "example.com.zone";

                        };

                        zone "0.168.192.IN-addr.arpa." IN {

                                    type master;

                                    file "192.168.0.zone";

                        };

                # cd ../var/named/

                # cp /var/named/named.ca  ./

                # vim example.com.zone

                        $TTL 600

                        @ IN SOA ns1.example.com. admin.example.com. {

                                    20150106

                                    1H

                                    5M

                                    2D

                                    6H)

                           IN NS ns1

                           IN MX 10 mail

                        ns1 IN A 192.168.0.1

                        mail IN A 192.168.0.2

                        www  IN  A 192.168.0.3

                # vim 192.168.0.zone

                        $TTL 600

                        @ IN SOA ns1.example.com. admin.example.com. {

                                    2014122322

                                    1H

                                    5M

                                    2D

                            6H)

                           IN NS ns1.example.com.

                        1  IN  PTR  ns1.example.com.

                        2  IN  PTR  mail.example.com.

                        3  IN  PTR  www.example.com.

                # chgrp named *


 

    3. 启动bind服务
 

         # systemctl  enable  named-chroot-setup

                # systemctl  restart  named-chroot


 

    4. 测试
 

                # vim /etc/resolv.conf

                     nameserver  192.168.0.254

                     search example.com

                # nslookup www.luyouqiwang.com

                # nslookup 192.168.0.1


 

总结:到此为止,一个基本的DNS解析就已经完成了,其他关于DNS的转发、子域授权、视图等配置会陆续的补充!

关于我们 - RSS地图 - 最近更新 - 友情链接 - 网站地图 - 版权声明