配置bind主域名伺服器

weixin_34026276發表於2017-11-15

1.設定網路引數:

vi /etc/sysconfig/network-scripts/ifcfg-eth0 

1
2
3
4
5
6
7
8
9
10
DEVICE="eth0"
HWADDR="00:0C:29:68:b1:0f"
NM_CONTROLLED="no"
ONBOOT="yes"
BOOTPROTO=static
IPADDR=192.168.10.95
NETMASK=255.255.255.0
GATEWAY=192.168.10.1
DNS1=202.106.0.20
DNS2=192.168.10.95

:wq


vi /etc/sysconfig/network

1
2
NETWORKING=yes
HOSTNAME=ns.linunxyy.cn

:wq


vi /etc/selinux/config 

1
SELINUX=disabled

:wq


chkconfig NetworkManager off

chkconfig iptables off

chkconfig network on 

vi /etc/hosts

1
192.168.10.95   ns      ns.linuxyy.cn

:wq


reboot


2.安裝bind軟體:

vi /etc/yum.repos.d/rhel.repo

1
2
3
4
5
[local]
name=local
baseurl=file:///mnt/
enabled=1
gpgcheck=0

:wq


mount /dev/cdrom /mnt

yum -y install bind-*

rpm -qa |grep bind

rpm -ql bind

rpm -ql bind-utils


3.修改配置檔案:

cd /var/named/chroot/etc/

cp /usr/share/doc/bind-9.7.3/sample/etc/named.conf ./

vi named.conf   ##修改如下,可以複製貼上

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
options
{
        directory               "/var/named";           // "Working" directory
        dump-file               "data/cache_dump.db";
        statistics-file         "data/named_stats.txt";
        memstatistics-file      "data/named_mem_stats.txt";
        listen-on port 53       { 192.168.10.95; };
        query-source port 53;
        allow-query             { 192.168.10.0/24; };
        recursion yes;
};
logging 
{
        channel default_debug {
                file "data/named.run";
                severity dynamic;
        };
};
zone "linuxyy.cn." IN {
                type master;
                file "linuxyy.cn.zone";
};
zone "10.168.192.in-addr.arpa" IN {
                type master;
                file "192.168.10.arpa";
};

:wq

[root@ns etc]# named-checkconf named.conf   ##測試主配置檔案是否有錯誤


cd /var/named/chroot/var/named/

vim linuxyy.cn.zone

1
2
3
4
5
6
7
8
9
10
11
12
13
14
$TTL 86400
@       IN SOA  linuxyy.cn. root.linuxyy.cn. (
                                        20171111        ; serial
                                        1D              ; refresh
                                        1H              ; retry
                                        1W              ; expire
                                        3H )            ; minimum
       IN      NS       ns.linuxyy.cn.
ns      IN      A       192.168.10.95
       IN      A       192.168.10.95
       IN      MX 10     mail.linuxyy.cn.
mail     IN      A       192.168.10.95
www     IN      A       192.168.10.96
ftp     IN      CNAME     www

:wq

vim  192.168.10.arpa

$TTL 86400

1
2
3
4
5
6
7
8
9
10
11
@       IN SOA  linuxfan.cn. root.linuxyy.cn. (
                                        20171111        ; serial
                                        1D              ; refresh
                                        1H              ; retry
                                        1W              ; expire
                                        3H )            ; minimum
@       IN      NS      ns.linuxyy.cn.
95      IN      PTR     ns.linuxyy.cn.
95      IN      PTR     mail.linuxyy.cn.
96      IN      PTR     www.linuxyy.cn.
96      IN      PTR     ftp.linuxyy.cn.

:wq

[root@ns named]# named-checkzone linuxyy.cn.zone 192.168.10.arpa   ##測試區域資料庫配置檔案


chown named:named linuxyy.cn.zone 192.168.10.arpa ../../etc/named.conf    ##設定許可權,確保named使用者有讀取的許可權

/etc/init.d/named restart

chkconfig named on

netstat -utpln |grep 53

4.測試:

windows/linux:


nslookup

server 192.168.10.95

mail.linuxyy.cn

www.linuxyy.cn

192.168.10.96

exit









本文轉自信自己belive51CTO部落格,原文連結:http://blog.51cto.com/11638205/2043891 ,如需轉載請自行聯絡原作者

相關文章