kubernetes集群公共服务 DNS
原创
©著作权归作者所有:来自51CTO博客作者嘉式年华的原创作品,请联系作者获取转载授权,否则将追究法律责任
一、软件安装
二、软件配置
# vim /etc/named.conf
# cat -n /etc/named.conf
1 //
2 // named.conf
3 //
4 // Provided by Red Hat bind package to configure the ISC BIND named(8) DNS
5 // server as a caching only nameserver (as a localhost DNS resolver only).
6 //
7 // See /usr/share/doc/bind*/sample/ for example named configuration files.
8 //
9 // See the BIND Administrator's Reference Manual (ARM) for details about the
10 // configuration located in /usr/share/doc/bind-{version}/Bv9ARM.html
11
12 options {
13 listen-on port 53 { 127.0.0.1;any; }; 添加any;
14 listen-on-v6 port 53 { ::1; };
15 directory "/var/named";
16 dump-file "/var/named/data/cache_dump.db";
17 statistics-file "/var/named/data/named_stats.txt";
18 memstatistics-file "/var/named/data/named_mem_stats.txt";
19 recursing-file "/var/named/data/named.recursing";
20 secroots-file "/var/named/data/named.secroots";
21 allow-query { localhost;any; }; 添加any;允许接收所有主机的查询
# vim /etc/named.rfc1912.zones
# tail -5 /etc/named.rfc1912.zones
zone "jiage.com" IN { # 申请注册jiage.com的域名
type master;
file "jiage.com.zone"; #记录该域名的文件
allow-update { none; };
};
# cd /var/named
# cp -p named.localhost jiage.com.zone
# # vim jiage.com.zone
# cat jiage.com.zone
$TTL 1D
@ IN SOA jiage.com admin.jiage.com. ( # @表示本地、jiage.com 表示域名、admin.jiage.com 表邮箱
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
@ NS ns.jiage.com.
ns A 192.168.10.135
三、开启服务
# systemctl enable --now named
四、主机网络DNS服务器配置
# vim /etc/sysconfig/network-scripts/ifcfg-ens33
# tail -5 /etc/sysconfig/network-scripts/ifcfg-ens33
IPADDR="192.168.10.135"
PREFIX="24"
GATEWAY="192.168.10.2"
DNS1="192.168.10.135" 添加本地DNS
DNS2="119.29.29.29"
# systemctl restart network
五、域名解析
# nslookup
> server 输入server,查看本地DNS server服务器
Default server: 192.168.10.135
Address: 192.168.10.135#53
Default server: 119.29.29.29
Address: 119.29.29.29#53
六、K8S集群主机网络DNS配置
# vim /etc/sysconfig/network-scripts/ifcfg-ens33
# tail -5 /etc/sysconfig/network-scripts/ifcfg-ens33
IPADDR="192.168.10.13X"
PREFIX="24"
GATEWAY="192.168.10.2"
DNS1="192.168.10.135" 添加本地DNS
DNS2="119.29.29.29"