[root@46 /]#yum -y install bind bind-chroot bind-libs bind-utils caching-nameserver
目录说明
/var/named/chroot/etc #存放named.conf
/var/named/chroot/var/named #存放zone&arpa文件
/var/log/messages #查看配置过程中出错信息
[root@46 etc]# pwd
/var/named/chroot/etc
[root@46 etc]# cp -p named.caching-nameserver.conf named.conf #书上说找不到named.conf会自动启用named.caching-nameserver.conf,不过没试过
[root@46 etc]# ls
localtime named.caching-nameserver.conf named.conf named.rfc1912.zones rndc.key
[root@46 etc]# vi named.conf
//参照《LINUX 系统与网络服务管理技术大全》第11 章,注释有的是大力自己理解的,不一定正确。
//
// named.caching-nameserver.conf
//
// named.caching-nameserver.conf
//
// Provided by Red Hat caching-nameserver 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.
//
// DO NOT EDIT THIS FILE - use system-config-bind or an editor
// to create named.conf - edits to this file will be lost on
// caching-nameserver package upgrade.
//
options { //服务器的全局配置选项及一些默认设置
listen-on port 53 { any; }; //监听端口,也可写为 { 127.0.0.1; 192.168.139.46; }
listen-on-v6 port 53 { ::1; }; //对ip6支持
directory "/var/named"; //区域文件存储目录
dump-file "/var/named/data/cache_dump.db"; //dump cach的目录directory
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
pid-file "/var/run/named/named.pid"; //存着named的pid
forwarders { 168.95.1.1; 139.175.10.20; }; // 如果域名服务器无法解析时,将请求交由168.95.1.1; 139.175.10.20来解析
allow-query { any; }; //指定允许进行查询的主机,当然是要所有的电脑都可以查啦
allow-transfer { none; }; //指定允许接受区域传送请求的主机,说明白一点就是辅DNS定义,比如辅DNS的IP是192.168.139.5,那么可以这样定义{ 192.168.139.5; },要不然主辅DNS不能同步,当然,{}里的也可以用下面提到的ACL。
// Those options should be used carefully because they disable port
// randomization
// query-source port 53;
// query-source-v6 port 53;
};
logging { //指定服务器日志记录的内容和日志信息来源
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
// 这里定义一个acl列表
acl "acl1" {
192.168.139.0/200; 192.168.1.0/200
};
view localhost_resolver { //定义一个视图
match-clients { any; }; //查询者的源地址,any表示localhost_resolver视图对任何主机开放,如果写成{ acl1; },那么就只有acl1表里的IP可以递归查询了
match-destinations { any; }; //查询者的目标地址,这里也可以写成{ localhost; acl1; }
recursion yes; //设置进行递归查询
include "/etc/named.rfc1912.zones"; //包含文件,这里也就是载入/etc/named.rfc1912.zones
};