配置
四行的含义:
resolv-file:从文件读取 DNSMasq 上游的 DNS 服务器配置。
strict-order:resolv-file 文件中如果指定了多个 DNS 服务器,严格安装 DNS 服务器的先后顺序查询域名。
listen-address:监听地址,配置为本机 IP 即可。
addn-hosts:从文件读取本地 DNS 域名和 IP 的对应关系,格式为
resolv-file=/etc/resolv.conf
strict-order
listen-address=192.168.122.1
addn-hosts=/opt/tools/dns/hosts
1 | systemctl start dnsmasq.service 启动 |
k8s dns
coredns 异常检查以下配置
/etc/kubernetes/manifests/kube-controller-manager.yaml
1 | cat /etc/kubernetes/manifests/kube-controller-manager.yaml | grep cluster- |
cluster-cidr
service-cluster-ip-range
/var/lib/kubelet/config.yaml
1 | $ cat /var/lib/kubelet/config.yaml | grep -A 1 cluster |
clusterDNS
进入pod中 查看/etc/reslove.conf 中nameserver和kube-dns ClusterIP 是否一致
1 | kubectl edit cm kube-proxy -n kube-system |
修改每个Node上kubelet的启动参数,在其中加上以下两个参数:
–cluster-dns=169.169.0.100:为DNS服务的ClusterIP地址。
–cluster-domain=cluster.local:为在DNS服务中设置的域名。
然后重启kubelet服务
nslookup
1 | ❯ kubectl debug -it vault-0 -n vault --image=k8s.org/cs/netshoot -- sh |
Defaulting debug container name to debugger-8z7lk.
If you don’t see a command prompt, try pressing enter.
root $ nslookup vault-internal
Server: 10.96.1.10
Address: 10.96.1.10#53Name: vault-internal.vault.svc.cluster.local
Address: 121.21.64.141
Name: vault-internal.vault.svc.cluster.local
Address: 121.21.80.152
Name: vault-internal.vault.svc.cluster.local
Address: 121.21.48.135
NetworkManager
1 | ❯ cat /etc/resolv.conf |
/etc/network/interfaces
故障
泛域名
配置日志
1 | log-queries |
Aug 29 18:16:12 dnsmasq[28763]: started, version 2.89 cachesize 150
Aug 29 18:16:12 dnsmasq[28763]: compile time options: IPv6 GNU-getopt DBus no-UBus i18n IDN2 DHCP DHCPv6 no-Lua TFTP conntrack ipset nftset auth cryptohash DNSSEC loop-detect inotify dumpfile
Aug 29 18:16:12 dnsmasq[28763]: reading /opt/tools/dns/resolv.dnsmasq.conf
Aug 29 18:16:12 dnsmasq[28763]: ignoring nameserver 192.168.122.1 - local interface
Aug 29 18:16:12 dnsmasq[28763]: using nameserver 202.96.128.86#53
Aug 29 18:16:12 dnsmasq[28763]: using nameserver 202.96.134.33#53
Aug 29 18:16:12 dnsmasq[28763]: read /etc/hosts - 11 names
Aug 29 18:16:12 dnsmasq[28763]: read /opt/tools/dns/hostname - 12 names
没有走dnsmasq
1 | ❯ nslookup es.local.org |
Aug 29 18:16:12 dnsmasq[28763]: read /opt/tools/dns/hostname - 12 names
Aug 29 18:16:21 dnsmasq[28763]: query[A] es.local.org from 127.0.0.1
Aug 29 18:16:21 dnsmasq[28763]: config es.local.org is 192.168.122.1
Aug 29 18:16:21 dnsmasq[28763]: query[AAAA] es.local.org from 127.0.0.1
Aug 29 18:16:21 dnsmasq[28763]: forwarded es.local.org to 202.96.128.86
Aug 29 18:16:21 dnsmasq[28763]: reply es.local.org is NODATA-IPv6
解决方式
NetworkManager 管理网络
1 | ❯ sudo mousepad /etc/NetworkManager/NetworkManager.conf |
[main]
dns=dnsmasq #添加