centos 5.4中Bind服务安装配置全过程-DNS配置
[root@testserver named]# uname -a
linux alinux 2.6.18-164.15.1.el5 #1 SMP Wed Mar 17 11:37:14 EDT 2010 i686 i686 i386 GNU/Linux
[root@testserver CentOS]# rpm -qa | grep bind
[root@testserver CentOS]# rpm -qa | grep bind 查看本机是否安装bind
[root@testserver CentOS]#yum install bind* 把有关于bind的全装上,
[root@testserver CentOS]#yum install caching-nameserver 这个也是必要的
一般的配置文件都在/etc/下,当然也可以rpm -ax | grep i bind,去看看/etc/named.*
配置文件在 /var/named/chroot/var/named/ 跟 /var/named/chroot/var/etc这两个目录下
[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
da
ta 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
[root@testserver etc]# vim named.caching-nameserver.conf any;为更改后的(注意红色部分)
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
//定义一个正向域 area.com ,定义正向解析文件名 alinux.net.cn.zone
//定义反向域 ,定义反向解析文件名 10.25.61.zone
[root@testserver etc]# vi named.rfc1912.zones
//test
zone "alinux.net.cn" IN {
type master;
file "alinux.net.cn.zone";
allow-update { none; };
};
zone "61.25.10.in-addr.arpa" IN {
type master;
file "10.25.61.zone";
allow-update { none; };
};
-------------------------------------------
# 配置正反向解析文件
-------------------------------------------
#cp -p localdomain.zone area.com.zone
#vim alinux.net.cn.zone
$TTL 86400
@ IN SOA www.alinux.net.cn. root.area.com. (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
IN NS www.alinux.net.cn.
www IN A 10.25.61.32
IN AAAA ::1
-----------------------------------------------
#cp -p named.local 10.25.61.zone
#vim 10.25.61.zone
$TTL 86400
@ IN SOA www.alinux.net.cn. root.area.com. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS www.alinux.net.cn
32 IN PTR www.alinux.net.cn
-------------------------------------------------
32是指的是IP:10.25.61.32的最后一个数。
配置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
测试
C:Usersalinux>nslookup www.tom.com
服务器: UnKnown
Address: 125.93.88.19
非权威应答:
名称: web.cdn.tomcdn.com
Address: 121.14.51.6
aliases: www.tom.com
修改配置,然后重启
# service named restart
# /etc/init.d/named restart
设置开机自启动
chkconfig named on 345