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

DNS主从服务器配置

时间:2018-10-11 12:18:44      阅读:151      评论:0      收藏:0      [点我收藏+]

标签:网卡   ipa   amp   bootproto   soa   file   主dns   hint   port   

一. 主DNS服务部署

1.1修改网络配置,主机名

vim /etc/sysconfig/network-scripts/ifcfg-eth0
        DEVICE=eth0
        TYPE=Ethernet
        ONBOOT=yes
        NM_CONTROLLED=no
        BOOTPROTO=static
        IPADDR=192.168.1.30
        NETMASK=255.255.255.0
        DNS1=192.168.1.30
        DNS2=192.168.1.40

/etc/init.d/network restar

vim /etc/sysconfig/network
        NETWORKING=yes
        HOSTNAME=ns1.duanyufei.org

1.2安装服务,修改主配置文件

mount /dev/sr0 /mnt/

vim /etc/yum.repos.d/CentOS-Base.repo
            [local]
            name=local
            baseurl=file:///mnt
            enabled=1
            gpgcheck=0

yum –y install bind bind-utils

vim /etc/named.conf
    options {
            listen-on port 53 { 192.168.1.30; };
            directory "/var/named";
            allow-query {localhost;};
            dnssec-enable no;
            dnssec-validation no; 

    zone "duanyufei.org" IN {
            type master;
            file "duanyufei.org.zone";
            allow-transfer {192.168.1.40;};
            };
    zone "1.168.192.in-addr.arpa" IN {
            type master;
            file "192.168.1.arpa";
            allow-transfer {192.168.1.40;};
            }; 

1.3配置区域正向解析文件

cp /var/named/named.empty /var/named/duanyufei.org.zone
vim /var/named/duanyufei.org.zone
            $TTL 86400
            @ IN SOA duanyufei.org. admin.duanyufei.org.(管理员邮箱) (
                                                         0 ; serial
                                                    1D ; refresh
                                                    1H ; retry
                                                 1W ; expire
                                                3H ) ; minimum
                 IN NS ns1.duanyufei.org. //主DNS从DNS服务器的主机名
                 IN NS ns2.duanyufei.org.
          ns1 IN A 192.168.1.30            //DNS服务器对应的IP地址
          ns2 IN A 192.168.1.40
        www IN A 192.168.1.100          //www.duanyufei.org对应的IP
            ftp IN CNAME www

1.4配置区域反向解析文件

cp /var/named/duanyufei.org.zone /var/named/192.168.1.arpa

vim /var/named/192.168.1.arpa
    $TTL 86400
    @ IN SOA duanyufei.org. admin.duanyufei.org.(管理员邮箱) (
                                                              0 ; serial
                                                            1D ; refresh
                                                            1H ; retry
                                                            1W ; expire
                                                           3H ) ; minimum
            IN NS ns1.duanyufei.org. 
            IN NS ns2.duanyufei.org.
       10 IN PTR ns1.duanyufei.org.
       20 IN PTR ns2.duanyufei.org.
     100 IN PTR www.duanyufei.org.
       ftp IN CNAME www

1.5更改区域配置文件的属主属组

chown named:named /var/named/192.168.1.arpa /var/named/duanyufei.org.zone

1.6开启服务,并设置开机自启

/etc/init.d/named start && chkconfig --level 35 named on

二.从DNS服务部署

2.1修改网络配置

vim /etc/sysconfig/network-scripts/ifcfg-eth0
        DEVICE=eth0
        TYPE=Ethernet
        ONBOOT=yes
        NM_CONTROLLED=no
        BOOTPROTO=static
        IPADDR=192.168.1.40
        NETMASK=255.255.255.0
        DNS1=192.168.1.40
        DNS2=192.168.1.30

/etc/init.d/network restart
vim /etc/sysconfig/network
        NETWORKING=yes
        HOSTNAME=ns2.duanyufei.org

2.2安装bind软件包

yum -y install bind bind-utils

2.3编辑主配置文件

scp root@192.168.1.30:/etc/named.conf /etc/
vim /etc/named.conf
    options {
        listen-on port 53 { 192.168.1.40; };
        directory "/var/named";
    zone "duanyufei.org" IN {
        type slave;
        file "slaves/duanyufei.org.zone"; 
        masters {192.168.1.30;};
        };
    zone "1.168.192.in-addr.arpa" IN {
        type slave;
        file "slaves/192.168.1.arpa";
        masters {192.168.1.30;};
        };

2.4启动named服务并设置为开机自启

/etc/init.d/named start && chkconfig --level 35 named on

2.5验证是否有拷贝的文件

ll /var/named/slaves/

客户端验证配置

一块网卡vmnet1、首选DNS 192.168.1.30、 备用DNS 192.168.1.40
cmd --> nslookup duanyufei.org

三.缓存DNS服务部署

3.1构建网络

两块网卡,第一块网卡为桥接,第二块vmnet1
cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth1
vim /etc/sysconfig/network-scripts/ifcfg-eth0
        DEVICE=eth0
        TYPE=Ethernet
        ONBOOT=yes
        NM_CONTROLLED=no
        BOOTPROTO=dhcp

vim /etc/sysconfig/network-scripts/ifcfg-eth1
        DEVICE=eth1
        TYPE=Ethernet
        ONBOOT=yes
        NM_CONTROLLED=no
        BOOTPROTO=static
        IPADDR=192.168.1.254
        NETMASK=255.255.255.0

/etc/init.d/network restart
vim /etc/sysctl.conf
        7 net.ipv4.ip_forward = 1 (开启路由转发)

sysctl -p
iptables -t nat -I POSTROUTING -s 192.168.1.0/24 -j SNAT --to-source 192.168.20.186(换为桥接获取的IP //允许192.168.1.0上网) 编辑iptables防护墙规则

3.2安装DNS服务

    mount /dev/sr0 /mnt/
    yum -y install bind bind-utils

3.3修改主配置文件

cp /etc/named.conf /etc/named.conf.bak
vim /etc/named.conf
    options {
            listen-on port 53 { 192.168.1.254; };
            directory "/var/named";
            allow-query {any;};
            forwarders {114.114.114.114;8.8.8.8;};
            dnssec-enable no;
            dnssec-validation no;
    zone "." IN {
            type hint;
            file "named.ca"; 

/etc/init.d/named start && chkconfig --level 35 named on

3.4客户端配置、测试

一块网卡vmnet1、网关192.168.1.254、首选DNS 192.168.1.254

DNS主从服务器配置

标签:网卡   ipa   amp   bootproto   soa   file   主dns   hint   port   

原文地址:http://blog.51cto.com/14013608/2298607

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