如何配置使得BIND只解析特定域名?

轉自https://www.oschina.net/question/102022_12089?sort=default&p=2
bind配置內網解析部分子域名,其它子域名轉發。以下以m.xxx.com和admin.xxx.com由內網dns解析,其它*.xxx.com轉發給外網dns解析爲例配置。
文件/etc/named.conf:
options {

listen-on port 53 { 127.0.0.1; }; #註釋表示監聽所有端口
listen-on-v6 port 53 { ::1; };
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";
recursing-file "/var/named/data/named.recursing";
secroots-file "/var/named/data/named.secroots";
allow-query { any; };
forwarders { 202.96.134.133;8.8.8.8; };#這裏指定本地找不到解析轉發的服務器列表

recursion yes;

dnssec-enable yes;
dnssec-validation yes;

/ Path to ISC DLV key /
bindkeys-file "/etc/named.iscdlv.key";

managed-keys-directory "/var/named/dynamic";

pid-file "/run/named/named.pid";
session-keyfile "/run/named/session.key";
};

logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};

zone "." IN {
type hint;
file "named.ca";
};
#配置m.xxx.com內網解析
zone "m.xxx.com" IN{
type master;
file "m.xx.com.zone";
allow-update { none; };
};
#配置admin.xxx.com內網解析
zone "admin.xxx.com" IN{
type master;
file "admin.xxx.com.zone";
allow-update { none; };
};
include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";

文件 /var/named/m.xx.com.zone:
$TTL 1D
@ IN SOA @ m.xxx.com. (
2019032015; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
IN NS dns1
dns1 600 IN A 192.168.1.229
m.xxx.com. 600 IN A 192.168.1.223

文件 /var/named/admin.xx.com.zone:
$TTL 1D
@ IN SOA @ admin.xxx.com. (
2019032017; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
IN NS dns1
dns1 600 IN A 192.168.1.229
admin.xxx.com. 600 IN A 192.168.1.224

注意,關鍵說明:
1,每個資源文件要設置權限,如:chown root:named /var/named/admin.xxx.com.zone ,切記,否則有可能不能加載,導致配置無效。
2,配置完成named-checkzone admin.xxx.com /var/named/admin.xxx.com.zone 和 named-checkconf /etc/named.conf 進行配置檢查。

3,注意域名配置後面的有的有點".",有的沒有,不要弄差了。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章