sudo nano /etc/systemd/resolved.conf
# 更改成如下内容
# 假设docker-bind所在服务器IP地址为192.168.3.37
[Resolve]
DNS=192.168.3.37
#FallbackDNS=
#Domains=
#LLMNR=no
#MulticastDNS=no
#DNSSEC=no
#DNSOverTLS=no
#Cache=no
DNSStubListener=no
#ReadEtcHosts=yes
sudo ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf
复制代码
参考 怎样释放systemd-resoved
使用的53端口html
配置后,此时/etc/resolv.conf
的内容为git
# This file is managed by man:systemd-resolved(8). Do not edit.
#
# This is a dynamic resolv.conf file for connecting local clients directly to
# all known uplink DNS servers. This file lists all configured search domains.
#
# Third party programs must not access this file directly, but only through the
# symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,
# replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.
nameserver 192.168.3.37
nameserver 192.168.3.1
复制代码
/etc/resolv.conf
并从新执行sudo ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf
/run/systemd/resolve/resolv.conf
文件,说明执行了systemctl disable systemd-resolved
或service systemd-resolved stop
,所以执行systemctl enable systemd-resolved
和service systemd-resolved start
并重启便可选定集群中用做搭建DNS服务器的服务器执行下列命令github
# 在关闭本机解析服务以前拉取镜像
docker pull sameersbn/bind:9.16.1-20200524
# 使用docker容器部署bind服务
docker run \
--name bind \
-d \
--restart=always \
--publish 53:53/tcp \
--publish 53:53/udp \
--publish 10000:10000/tcp \
--volume docker-bind:/data \
sameersbn/bind:9.16.1-20200524
复制代码
假设服务器IP地址为192.168.3.37
,本地根域名为dev
。web
访问Webmin管理界面,地址为:https://192.168.3.37:10000/,默认用户名:`root`,密码:`password`,相关设置以下:docker
更新本机nameservers设置,设定为服务器IP地址,并执行如下命令检查DNS服务器工做是否正常bash
nslookup www.baidu.com
nslookup a.dev
nslookup b.dev
复制代码
若是出现;; Got recursion not available from 192.168.3.37, trying next server
的问题,执行下述操做(更方便的作法是按照文件的内容 在dashboard中进行修改:Servers → BIND DNS Server → Global Server Options → Edit Config File)服务器
docker cp bind:/etc/bind/named.conf.options ./
docker cp bind:/etc/bind/named.conf ./
# 分别对两文件进行修改
# named.conf
acl trusted {
192.168.0.0/16;
10.153.154.0/24;
localhost;
localnets;
};
// This is the primary configuration file for the BIND DNS server named.
//
// Please read /usr/share/doc/bind9/README.Debian.gz for information on the
// structure of BIND configuration files in Debian, *BEFORE* you customize
// this configuration file.
//
// If you are just adding zones, please do that in /etc/bind/named.conf.local
include "/etc/bind/named.conf.options";
include "/etc/bind/named.conf.local";
include "/etc/bind/named.conf.default-zones";
# named.conf.options
options {
directory "/var/cache/bind";
// If there is a firewall between you and nameservers you want
// to talk to, you may need to fix the firewall to allow multiple
// ports to talk. See http://www.kb.cert.org/vuls/id/800113
// If your ISP provided one or more IP addresses for stable
// nameservers, you probably want to use them as forwarders.
// Uncomment the following block, and insert the addresses replacing
// the all-0's placeholder. // forwarders { // 0.0.0.0; // }; //======================================================================== // If BIND logs error messages about the root key being expired, // you will need to update your keys. See https://www.isc.org/bind-keys //======================================================================== dnssec-validation auto; listen-on-v6 { any; }; forwarders { 8.8.8.8; 8.8.4.4; }; allow-query { any; }; allow-recursion { trusted; }; allow-query-cache { trusted; }; }; # 写回到容器中 docker cp ./named.conf.options bind:/etc/bind/named.conf.options docker cp ./named.conf bind:/etc/bind/named.conf # 重启容器 docker restart bind 复制代码
参考 issuemarkdown