1、软件安装:
redhat默认使用bind作为安装软件
使用yum安装 yum install -y bind bind-chroot bind-utils
bind提供主程序
bind-chroot提供配置文件的挂载。目的:提高系统的安全性。
bind-utils提供一些dns的小工具。例如named-checkzone等。
2、启动服务:
使用/etc/init.d.named start (service named start)启动服务。
<1>编辑主配置文件,vim /var/named/chroot/etc/named.conf.
//
// named.conf
//
// Provided by Red Hat bind package to configure the ISC BIND named(8) DNS
// server as a caching only nameserver (as a localhost DNS resolver only).
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
// options {
listen-on port { any; };
// listen-on-v6 port 53 { any; };
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";
allow-query { any; };
recursion yes;
# dnssec-enable yes;
# dnssec-validation yes;
# dnssec-lookaside auto;
/* Path to ISC DLV key */
bindkeys-file "/etc/named.iscdlv.key"; managed-keys-directory "/var/named/dynamic";
}; logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
}; zone "." IN {
type hint;
file "named.ca";
}; zone "mylove.cn" IN {
type master;
file "mylove.cn.zone";
}; include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";
修改option里面的127.0.0.1为any。
添加自己域名的zone文件
zone "mylove.cn" IN {
type master;
file "mylove.cn.zone";
};
<2>新建自己的zone文件
拷贝/var/named/chroot/var/named/named.local 改名为自己zone文件相同的名字,并在此基础上修改文件内容
cp -P /var/named/chroot/var/named/named.localhost /var/named/chroot/var/named/mylove.cn.zone
使用cp -P 是为了保证文件权限不出问题
$TTL 1D
mylove.cn. IN SOA mylove.cn. root.mylove.cn. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
mylove.cn. NS ns.love.cn.
ns.mylove.cn. A 192.168.1.170
www.mylove.cn. A 192.168.1.170
在此检查下配置文件和zone文件
[root@localhost ~]# named-checkzone mylove.cn /var/named/mylove.cn.zone
zone mmm/IN: loaded serial 0
OK
[root@localhost ~]# named-checkconf
前面这些做好后,重启named服务!然后测试。
已经解析成功了!
未完待续......