创新路
我们一直在努力

CentOS7 DNS系统搭建

 

DNS(Domain Name System,域名解析系统),通过主机名,最终得到该主机名对应的IP地址的过程叫做域名解析(或主机名解析)。在公司环境下,因为内部服务器的使用需求,往往需搭建公司内部的DNS系统,下面开始在CentOS7下搭建DNS

  

环境准备:

    1. 一台CentOS7的机器

    2. IP地址:192.168.0.254

    3. 主机名:server.example.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. 启动服务

# systemctl  enable  named-chroot-setup

   # systemctl  restart  named-chroot

 

    4. 测试

                # vim /etc/resolv.conf

                     nameserver  192.168.0.254

                     search example.com

                # nslookup www.example.com

                # nslookup 192.168.0.1

 

这样,一个简单的DNS系统就完成了搭建完成了。

未经允许不得转载:天府数据港官方信息博客 » CentOS7 DNS系统搭建

客官点个赞呗! (0)
分享到:

评论 2

评论前必须登录!

  1. #1

    OH,IP地址冲突了,192.168.0.254貌似是业务服务器。

    jwenshan3年前 (2016-12-28)
    • 梦回归墟

      没有啊!用的虚拟机单独的网络,没有接入公网,不会冲突!

      梦回归墟3年前 (2016-12-29)

天府云博 - 做有态度的开发&运维&设计学习分享平台!

联系我们百度云主机