dns 源码安装:
1)、tar zxf bind-9.9.2.tar.gz
2)、编译安装
cd bind-9.9.2
./configure
--prefix=/usr/local/named --enable-threads
make && make install
3)、生成 named.conf 配置文件以及需要的 rndc 的 key 值
cd /usr/
local
/named
sbin/rndc-confgen > etc/rndc.conf
cd etc
tail -10 rndc.conf | head -9 | sed s/#\ //g >named.conf
4)、配置 named.conf 配置文件
vim etc/named.conf 添加:
options {
listen-on port 53 { any; };
directory "/var/named";
pid-file "named.pid";
#query-source port 53;
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; };
allow-recursion { any; };
forward first;
forwarders { 202.101.172.35;202.101.172.47; };
interface-interval 0;
datasize 5M;
max-cache-size 10M;
recursive-clients 1000;
tcp-clients 100;
allow-transfer { 192.168.32.86; }; # 从服务器上面去掉
max-transfer-time-in 2;
max-transfer-time-out 2;
serial-query-rate 10;
recursion yes;
};
logging
{
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
zone "." IN {
type hint;
file "named.ca";
};
zone "localhost" IN {
type master;
file "named.localhost";
allow-update { none; };
};
zone "zjtest8.com" IN {
type master;
file "zjtest8.com.zone";
allow-update { none; };
};
5)、配置 named.localhost 域名
vim /var/named/named.ca
dig -t NS .>/var/named/named.ca
vim /var/named/named.localhost
$TTL 1D
@ IN SOA @ root (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS @
A 127.0.0.1
AAAA ::1
vim /var/named/zjtest8.com.zone
$TTL 1D
@ IN SOA zjtest8.com. rname.invalid.(
2016011201 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
IN NS @
IN A 127.0.0.1
www IN A 192.168.32.76
6)、安装 dig 命令
yum -y install bind-utils
7)、启动 named 服务
/usr/local/named/sbin/named -c /usr/local/named/etc/named.conf
8)、测试 named 服务
dig localhost
dig www.zjtest8.com
测试外网
dig www.baidu.com
9)、配置从服务器
zone "zjtest8.com" IN {
type slave;
file "slaves/zjtest8.com.zone";
masters {192.168.32.85; };
};
10)、添加开机启动
注:各种 permission deny 请修改相关权限
chown -R root:named /var/named/data/
chown -R root:named /var/named/slaves/