标签:要求 技术 mamicode image 系统 sys doc 空格 listen
#安装bind
yum install bind -y
#查看是否安装成功
[root@yn101-21 ~]# rpm -qa bind
#输出如下
bind-9.11.4-9.P2.el7.x86_64
vi /etc/named.conf
#文件内容:
options {
listen-on port 53 { 192.168.101.21; }; #修改为本机ip地址
listen-on-v6 port 53 { ::1; }; #删除ipv6地址
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; }; #改为any,允许所有ip进行查询
forwarders { 192.168.101.1; }; #增加该行配置,上一级DNS地址,网关地址
recursion yes; #DNS采用递归的算法
dnssec-enable yes; #改为no
dnssec-validation yes; #改为no
named-checkconf /etc/named.conf
vi /etc/named.rfc1912.zones
#新增内容
zone "host.com" IN {
type master;
file "host.com.zone";
allow-update { 192.168.101.21; };
};
zone "yn.com" IN {
type master;
file "yn.com.zone";
allow-update { 192.168.101.21; };
};
named-checkzone /etc/named.rfc1912.zones
vi /var/named/host.com.zone
#将以下配置文件粘贴到新建文件里面,;表示注释
$ORIGIN host.com.
$TTL 600 ; 10 minutes
@ IN SOA dns.host.com. dnsadmin.host.com. (
2020021501 ; serial
10800 ; refresh (3 hours)
900 ; retry (15 minutes)
604800 ; expire (1 week)
86400 ; minimum (1 day)
)
NS dns.host.com.
$TTL 60 ; 1 minute
dns A 192.168.101.21
YN101-21 A 192.168.101.21
YN101-22 A 192.168.101.22
YN101-31 A 192.168.101.31
YN101-32 A 192.168.101.32
YN101-100 A 192.168.101.100
vi /var/named/yn.com.zone
#将以下配置文件粘贴到新建文件里面,;表示注释
$ORIGIN yn.com.
$TTL 600 ; 10 minutes
@ IN SOA dns.yn.com. dnsadmin.yn.com. (
2020021501 ; serial
10800 ; refresh (3 hours)
900 ; retry (15 minutes)
604800 ; expire (1 week)
86400 ; minimum (1 day)
)
NS dns.yn.com.
$TTL 60 ; 1 minute
dns A 192.168.101.21
[root@yn101-21 ~]# named-checkzone host.com /var/named/host.com.zone
zone host.com/IN: loaded serial 2020021501
OK
[root@yn101-21 ~]# named-checkzone yn.com /var/named/yn.com.zone
zone yn.com/IN: loaded serial 2020021501
OK
systemctl start named
systemctl enable named
#配置文件错误,启动报错
#systemctl status named查看报错信息
[root@yn101-21 ~]# systemctl start named
Job for named.service failed because the control process exited with error code. See "systemctl status named.service" and "journalctl -xe" for details.
#查看DNS服务是否启动
[root@yn101-21 ~]# netstat -luntp|grep 53
tcp 0 0 192.168.101.21:53 0.0.0.0:* LISTEN 26587/named
tcp 0 0 127.0.0.1:953 0.0.0.0:* LISTEN 26587/named
tcp6 0 0 :::53 :::* LISTEN 26587/named
tcp6 0 0 ::1:953 :::* LISTEN 26587/named
udp 0 0 192.168.101.21:53 0.0.0.0:* 26587/named
udp6 0 0 :::53 :::* 26587/named
[root@yn101-21 ~]# dig -t A YN101-22.host.com @192.168.101.21 +short
192.168.101.22
cat /etc/resolv.conf
#Generated by NetworkManager
search host.com #新增
nameserver 192.168.101.21
修改DNS1,将所有服务器的DNS1改为192.168.101.21,分别ping YN101-22(所有服务器都能ping通)和baidu.com,如果能ping通说明配置成功。
window配置,修改VMnet8的DNS服务为192.168.101.21,因为项目要在浏览器中进行访问。设置完成后ping yn101-22.host.com,ping通配置成。
如果ping不通,修改本地网络的DNS。
项目环境搭建【Docker+k8s】五 || 部署自建DNS系统
标签:要求 技术 mamicode image 系统 sys doc 空格 listen
原文地址:https://www.cnblogs.com/kevin-ying/p/12343654.html