搭建本地dns服务
1、安装bind9
yum -y install bind
2、修改配置文件
2.1、主配置文件
[root@k8s-master ~]# vim /etc/named.conf
# 修改下面两行
listen-on port 53 { 192.168.112.128; };
allow-query { any; };
# 加一行
forwarders { 192.168.112.254; };
# 删除一行
listen-on-v6 port 53 { ::1; };
# 要确保
recursion yes; #递归查询
# 为节省资源,可将下面两行改为 no
dnssec-enable no;
dnssec-validation no;
[root@hdss7-11 ~]# named-checkconf #检查配置,没有输出信息即为正确
2.2、配置区域文件
增加一个zone配置,ts-it.cn为业务域
[root@k8s-master ~]# vim /etc/named.rfc1912.zones
# 添加至最后
zone "ts-it.cn" IN {
type master;
file "ts-it.cn.zone";
allow-update { 192.168.112.128; };
};
配置业务域文件
[root@k8s-master ~]# vim /var/named/ts-it.cn.zone
$ORIGIN ts-it.cn.
$TTL 600 ; 10 minutes
@ IN SOA dns.ts-it.cn. dnsadmin.ts-it.cn. (
20210816 ; serial
10800 ; refresh (3 hours)
900 ; retry (15 minutes)
604800 ; expire (1 week)
86400 ; minimum (1 day)
)
NS dns.ts-it.cn.
$TTL 60 ; 1 minute
dns A 192.168.112.128
a A 192.168.112.128
b A 192.168.112.128
* A 192.168.112.128
[root@hdss7-11 ~]# named-checkconf #检查配置,没有输出信息即为正确
3、启动服务
[root@hdss7-11 ~]# systemctl start named
验证解析是否正确
[root@k8s-master ~]# dig -t A a.ts-it.cn +short
192.168.112.128
[root@k8s-master ~]# dig -t A c.ts-it.cn +short
192.168.112.128

浙公网安备 33010602011771号