码迷,mamicode.com
首页 > 其他好文 > 详细

CentOS7 下DNS的搭建

时间:2015-01-07 07:07:11      阅读:216      评论:0      收藏:0      [点我收藏+]

标签:dns for centos7

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


下面开始在CentOS7下搭建DNS,仅供参考!


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


环境准备:

    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. 启动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.example.com

                # nslookup 192.168.0.1


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





本文出自 “Keyman” 博客,请务必保留此出处http://keyman.blog.51cto.com/9807984/1599925

CentOS7 下DNS的搭建

标签:dns for centos7

原文地址:http://keyman.blog.51cto.com/9807984/1599925

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!