0) 下载
1)
解压缩
- tar -zxvf bind-9.3.P2.tar.gz –C /tmp
-
cd /tmp/bind-9.3.P2
2) 配置
- ./configure --prefix=/data/sdns/named --enable-threads --with-openssl=no
3) 编译安装
4) 建立配置文件
5) 生成rndc控制命令的key文件
- sbin/rndc-confgen > etc/rndc.conf
6) 从rndc.conf中提取named.conf用的key
- tail -10 etc/rndc.conf | head -9 | sed s/#\ //g > etc/named.conf
7) 配置named.conf加如下代码
- vi /data/sdns/named/etc/named.conf
增加
options {
directory "/data/sdns/zone/";
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; };
};
8) 建立区目录文件
- mkdir /data/sdns/zone
-
cd /data/sdns/zone
建立localhost.zone文件
增加
$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
建立localhost.zone文件
$TTL 86400
@ IN SOA localhost. root.localhost. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS localhost.
1 IN PTR localhost.
#建立test.zone文件
vi test.zone
增加
$ttl 1D
@ IN SOA test.com. root.test.com. (
1053891162
3H
15M
1W
1D )
IN NS ns.test.com.
IN MX 5 test.com.
IN A 3.3.3.3
ns IN A 1.2.3.4
www IN A 220.202.19.82
若是不能连外网的话,执行下面的语句
- echo ". 3600000 IN NS A.ROOT-SERVERS.NET." >> named.root
-
echo "A.ROOT-SERVERS.NET. 3600000 A 198.41.0.4." >> named.root
9) 启动bind
- /data/sdns/named/sbin/named -c /data/sdns/named/etc/named.conf &
10) 重新加载配置文件(常用命令,修改了配置文件,就可以用这个命令来更新)
- /data/sdns/named/sbin/rndc reload
11) 测试
- iptables -A INPUT -p udp -s 0/0 --dport 53 -j ACCEPT
-
iptables -A INPUT -p tcp -s 0/0 --dport 53 -j ACCEPT
end
阅读(14584) | 评论(0) | 转发(0) |