如何使用Docker搭建私有的DNSServer
编译
git clone https://github.com/fyec/dns-docker.git
cd dns-docker
docker build -t dns .
配置
我们假设会建立repos.rd这个域名为例,
IP为 218.8.7.6,配置文件在 /path/to/dns-docker/config/bind的路径下。
db.rd
;
; BIND data file for local loopback interface
;
$TTL 86400
@ INSOA ns.rd. root.rd. (
2014032802 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
@ INNSns.rd.
@ INA 218.8.7.6
nsINA 218.8.7.6
www INA 218.8.7.6
repos IN A 218.8.7.6
db.218.8.7
;
; BIND reverse data file for local loopback interface
;
$TTL 604800
@ IN SOA ns.rd. root.rd. (
2014032801 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
@ IN NS ns.rd.
6 IN PTR ns.rd.
6 IN PTR www.rd.
6 IN PTR repos.rd.
named.conf.options
options {
directory "/etc/bind/cache";
forwarders {
8.8.8.8;
8.8.4.4;
114.114.114.114;
};
allow-query { any; };
allow-query-cache { any; };
dnssec-validation auto;
allow-transfer{ none; };
auth-nxdomain no; # conform to RFC1035
listen-on-v6 { any; };
};
named.conf.local
zone "rd" {
type master;
file "/etc/bind/db.rd";
};
zone "7.8.218.in-addr.arpa" {
type master;
file "/etc/bind/db.218.8.7";
};
运行
docker run -d -v /path/to/dns-docker/config/bind:/etc/bind -p 53:53 -p 53:53/udp dns
客户端配置
将 218.8.7.6 作为nameserver放到 /etc/resolv.conf 文件里,我们也可以在路由器里配置相关的信息,这样整个局域网的用户就都可以不做任何配置就可以使用这个DNS服务了。
检查
$ nslookup repos.rd
Server: 218.8.7.6
Address: 218.8.7.6
Name: repos.rd
Address: 218.8.7.6
其他问题
如果在配置过程中遇到 rndc.key 的问题,
可参考
http://tecadmin.net/configure-rndc-for-bind9/
http://wujunfeng.blog.iyunv.com/3041/1012409
版权声明:本文为博主原创文章,未经博主允许不得转载。
页:
[1]