1.DNS原理看这篇文章
https://www.cnblogs.com/kubixuesheng/p/6260195.html
2.服务器准备
192.168.1.100 DNS服务器
192.168.1.101 DNS客户端
192.168.1.102 DNS客户端
3.安装DNS服务
DNS服务端执行
yum install -y bind bind-utils
DNS客户端要是想使用nslookup命令执行
yum install -y bind-utils
4.修改/etc/named.conf配置
options { listen-on port 53 { any; }; //此处修改为any listen-on-v6 port 53 { ::1; }; 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
5.修改/etc/named.rfc1912.zones配置,在文件末尾加上如下代码
#DNS正向解析
zone "k8s.com" IN { type master; file "k8s.com.zone"; allow-update { none; }; };
#DNS反向解析 zone "1.168.192.in-addr.arpa" IN { type master; file "k8s.com.local"; allow-update { none; }; };
6.进入/var/named/目录,创建k8s.com.zone和k8s.com.local两个文件,名称对应上面的file
k8s.com.zone文件
$TTL 1D
@ IN SOA @ rname.invalid. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS @
A 192.168.1.100
www IN A 192.168.1.100
node1 IN A 192.168.1.101
node2 IN A 192.168.1.102
k8s.com.local文件
$TTL 1D @ IN SOA @ rname.invalid. ( 0 ; serial 1D ; refresh 1H ; retry 1W ; expire 3H ) ; minimum NS @ A 192.168.1.100 101 IN PTR node1.k8s.com. 102 IN PTR node2.k8s.com.
7.修改服务端和客户端的DNS配置,修改为DNS服务器ip地址
vim /etc/sysconfig/network-scripts/ifcfg-enp0s3
8.重启服务器和客户端的网卡,服务器启动named服务并设置开机自启
systemctl restart network
systemctl start named systemctl enable named
9.验证DNS服务
正向解析:
反向解析:
10.设置DNS主从看这篇文章
https://blog.csdn.net/qq_40707090/article/details/123561997
标签:named,file,Centos,192.168,DNS,服务器,k8s,com From: https://www.cnblogs.com/whjblog/p/17047263.html