Linux(CentOS 5.4)中Bind服务的安装与配置全过程-DNS配置

andyzhaojianhui 2010-12-23

RedHat 5系列的都差不多。本人也测试了!DNS的配置,之后会联合DNS+apache服务器配置部署出来!
[root@testserver named]# uname -a
Linux testserver 2.6.18-164.el5 #1 SMP Thu Sep 3 03:28:30 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux
[root@testserver CentOS]# rpm -qa | grep bind
bind-chroot-9.3.6-4.P1.el5
bind-utils-9.3.6-4.P1.el5
bind-libs-9.3.6-4.P1.el5
ypbind-1.19-12.el5
bind-9.3.6-4.P1.el5
kdebindings-3.5.4-6.el5
[root@testserver CentOS]# rpm -ivh bind-libbind-devel-9.3.6-4.P1.el5.x86_64.rpm
Preparing...                ########################################### [100%]
   1:bind-libbind-devel     ########################################### [100%]
[root@testserver CentOS]# rpm -ivh bind-devel-9.3.6-4.P1.el5.x86_64.rpm
Preparing...                ########################################### [100%]
   1:bind-devel             ########################################### [100%]
[root@testserver CentOS]# rpm -qa | grep bind
bind-chroot-9.3.6-4.P1.el5
bind-utils-9.3.6-4.P1.el5
bind-libs-9.3.6-4.P1.el5
ypbind-1.19-12.el5
bind-9.3.6-4.P1.el5
bind-libbind-devel-9.3.6-4.P1.el5
kdebindings-3.5.4-6.el5
bind-libbind-devel-9.3.6-4.P1.el5
bind-devel-9.3.6-4.P1.el5

[root@testserver CentOS]#
[root@testserver CentOS]# rpm -ivh caching-nameserver-9.3.6-4.P1.el5.x86_64.rpm
Preparing...                ########################################### [100%]
   1:caching-nameserver     ########################################### [100%]
这里有点蒙了,安装到那里去了呢?一般的配置文件都在/etc/下,当然也可以rpm -ax | grep i bind,去看看/etc/named.*
[root@testserver named]# ls -la /etc/named.*
lrwxrwxrwx 1 root named 52 Dec 17 16:50 /etc/named.caching-nameserver.conf -> /var/named/chroot//etc/named.caching-nameserver.conf
lrwxrwxrwx 1 root named 42 Dec 17 16:50 /etc/named.rfc1912.zones -> /var/named/chroot//etc/named.rfc1912.zones
看到了吗?原来这是一个 l 文件,方法有两种,你可以直接进入原目录去对原文件进行编辑,也可对链接文件操作,效果一样的!
[root@testserver CentOS]# cd /var/named/chroot/etc/
[root@testserver etc]# ls
localtime named.caching-nameserver.conf named.rfc1912.zones rndc.key
[root@testserver etc]# cd /var/named/chroot/var/named/
[root@testserver named]# ls -ld
drwxr-x--- 4 root named 4096 Dec 17 16:50 .
[root@testserver named]# ls
data              localhost.zone   named.ca         named.local slaves
localdomain.zone named.broadcast named.ip6.local named.zero
[root@testserver named]# cd ../../etc/

# pwd
/var/named/chroot/etc
# cd ../var/named/
# pwd
/var/named/chroot/var/named


[root@testserver etc]# cp -b named.rfc1912.zones named.rfc1912.zones.bak
[root@testserver etc]# ls
localtime named.caching-nameserver.conf named.rfc1912.zones named.rfc1912.zones.bak rndc.key

any;为更改后的

[root@testserver etc]# vim named.caching-nameserver.conf
options {
listen-on port 53 { any; };
listen-on-v6 port 53 { ::1; };
directory     "/var/named";
dump-file     "/var/named/data/cache_dump.db";
        statistics-file "/var/named/data/named_stats.txt";
        memstatistics-file "/var/named/data/named_mem_stats.txt";
query-source    port 53;   
query-source-v6 port 53;
allow-query     { any; };
};
logging {
        channel default_debug {
                file "data/named.run";
                severity dynamic;
        };
};
view localhost_resolver {
match-clients         { any; };
match-destinations { any; };
recursion yes;
include "/etc/named.rfc1912.zones";
};

[root@testserver named]# cd ../../etc/
---------------------------------------------------------------------------
[root@testserver etc]# cp named.rfc1912.zones named.rfc1912.zones.bak

# vi /etc/resolv.conf

配置selinux
[root@testserver etc]# setup
弹出一个对话框。我们要进行的是防火墙配置,步骤如下:
选择“Firewall Configuration”---按 “Tab”键切换到“Run Tool”—回车—“Security Level”选项要在“Enabled”前面按一下“Tab”键---“SelLinux”选项要选“Disabled”—按一下“Tab”键---选中“Customize”---弹出新对话框---在“Other Port”栏目里输入“53:tcp 53:udp”—“OK”—返回上一个对话框—“OK”—对话框自动关闭。配置完成。

启动named
# service named start
# /etc/init.d/named start

修改配置后记得重启
# service named restart
# /etc/init.d/named restart

相关推荐