软件:Bind
bind下载地址 http://www.isc.org/downloads/
系统:CentOs7.0
(bind编译安装需要gcc,请确保你的机器上已经安装gcc)
1.执行命令 tar -xvzf Bind-9.10.1.tar.gz
2.进入到解压后的文件夹
执行命令 ./configure --prefix=/usr/local/named (指定安装目录)
如果提示需要 openssl。 执行命令 yum install openssl。
安装完成,继续执行./configure --prefix=/usr/local/named
发现还是失败 执行命令 yum install openssl-devel
安装完成,继续执行./configure --prefix=/usr/local/named
发现还是失败,根据提示需要安装perl
执行命令 yum install perl
安装完成,继续执行./configure --prefix=/usr/local/named
发现已经没有错误
继续执行命令 make
然后执行命令 make install
安装完成
3.配置Bind;
进入到Bind安装目录 /usr/local/named/ 可以看到如下目录结构
1.执行命令 /usr/local/named/sbin/rndc-confgen > /usr/local/named/etc/rndc.conf
2.执行命令 tail -10 rndc.conf | head -9 | sed s/#\ //g > /usr/local/namde/etc/named.conf
执行完上述两条命令可以看到
3.执行命令 vi named.conf 加入以下内容
options {
directory "/usr/local/named/var";
pid-file "named.pid";
};
zone "." IN {
type hint;
file "named.root";
};
zone "localhost" IN {
type master;
file "localhost.zone";
allow-update { none; };
};
zone "0.0.127.in-addr.arpa" IN {
type master;
file "named.local";
allow-update { none; };
};
zone "test.com" IN {
type master;
file "test.zone";
allow-update { none; };
};
zone "1.168.192.in-addr.arpa" in {
type master;
file "test.local";
allow-update { none; };
};
执行命令 vi named.local 加入如下内容
$TTL 86400
@ IN SOA localhost. root.localhost. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS localhost.
1 IN PTR localhost.
$TTL 86400
$ORIGIN localhost.
@ 1D IN SOA @ root (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
1D IN NS @
1D IN A 127.0.0.1
执行命令 vi test.local 加入如下内容
$TTL 86400
@ IN SOA ns1.test.com. root.test.com.(
20031001;
7200;
3600;
43200;
86400);
@ IN NS ns1.test.com.
168 IN PTR ns1.test.com.
$TTL 86400 ; 1 day
@ IN SOA ns1.test.com. root.test.com. (
2008050122 ; serial
28800 ; refresh (8 hours)
7200 ; retry (2 hours)
604800 ; expire (1 week)
86400 ; minimum (1 day)
)
NS ns1.test.com.
A 192.168.1.168
MX 10 mail.test.com.
www A 192.168.1.168
mail A 192.168.1.168
ns1 A 192.168.1.168
5 测试,执行命令 nslookup test.com
执行命令 nslookup www.test.com
6 dig测试 ,执行命令 dig @192.168.108.180 test.com (192.168.108.180是我本机ip)