目的
配置内部DNS
版本
Debian 9
bind 9
网络配置
- 192.168.11.200(hogehoge.com)
- 192.168.11.205(fugafuga.info)- DNS服务器
必须的文件
- configuration file
- /etc/bind/named.conf.local
- zone file
- hogehoge.com.internal-zone
- fugafuga.info.internal-zone
- 168.192.in-addr.arpa.zone
named.conf设置
named.conf.default-zones文件无效化
include "/etc/bind/named.conf.options";
include "/etc/bind/named.conf.local";
// include "/etc/bind/named.conf.default-zones";
named.conf.local设置
view "internal"{
match-clients {
localhost;
192.168.0.0/16;
};
zone "fugafuga.info" {
type master;
file "/etc/bind/fugafuga.info.internal-zone";
};
zone "hogehoge.com" {
type master;
file "/etc/bind/hogehoge.com.internal-zone";
};
zone "168.192.in-addr.arpa" {
type master;
file "/etc/bind/168.192.in-addr.arpa.zone";
};
};
view
使用view,一部分客户被提供DNS。"matchclients"设置那个客户。
hogehoge.com.internal-zone设置
$TTL 3600
@ IN SOA hogehoge.com. hogehogemail.com.(
20180723 ;Serial
3600 ;Refresh
1800 ;Retry
604800 ;Expire
86400 ;Minimum TTL
)
@ IN NS fugafuga.info.
hogehoge.com. IN A 192.168.11.200
TTL
Time To Live - 生存时间
SOA
在SOA的后面写域名和电子邮件地址。
NS
设置DNS服务器。
A
设置域名和IP地址。
fugafuga.info.internal-zone设置
$TTL 3600
@ IN SOA fugafuga.info. hogehogemail.com.(
20180723 ;Serial
3600 ;Refresh
1800 ;Retry
604800 ;Expire
86400 ;Minimum TTL
)
@ IN NS fugafuga.info.
fugafuga.info. IN A 192.168.11.205
168.192.in-addr.arpa.zone设置
$TTL 3600
@ IN SOA fugafuga.info. hogehogemail.com.(
20180723 ;Serial
3600 ;Refresh
1800 ;Retry
604800 ;Expire
86400 ;Minimum TTL
)
@ IN NS fugafuga.info.
11.200 IN PTR hogehoge.com.
11.205 IN PTR fugafuga.info.
PTR
设置IP地址和域名。
语法检查
用named-checkconf命令检查configuration file和zone file。
$ /usr/sbin/named-checkconf
$ /usr/sbin/named-checkconf -z
zone fugafuga.info/IN: loaded serial 20180723
zone hogehoge.com/IN: loaded serial 20180723
zone 168.192.in-addr.arpa/IN: loaded serial 20180723
重新启动bind
$ sudo service bind9 restart
网络设置和重新启动网略
$ sudo vim /etc/network/interfaces
(中略)
dns-nameservers 192.168.11.205 8.8.8.8
(中略)
sudo ifdown enp3s0
sudo ifup enp3s0