本文主要是介绍linux DNS高速缓存,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
配置名称服务器(本机ip:172.25.254.117)
1 安装 bind 软件包
– yum install -y bind
2 编辑 /etc/named.conf
listen-on port 53 { any; }; ##开启端口allow-query { any; }; ##允许访问forwarders { 172.25.254.250; }; ##如果服务器没有这个地址就去访问250
3 启动并启用 DNS 服务器
systemctl start namedsystemctl enable namedfirewall-cmd --permanent --add-server=dnsfirewall-cmd --reloadfirewall-cmd --list-allnetstat -antlupe|grep 53
4配置其他两台机器dns
vim /etc/resolve.confnameserver 172.25.254.117
• 进行测试
– dig www.baidu.com
DNS正向解析
vim /etc/named.confforwarders { 172.25.254.250; }; ##删除这一行自己搭建一个DNS
vim /etc/named.rfc1912.zoneszone "westos.com" IN {type master;file "westos.com.zone";allow-update { none; };
cd /var/named/
cp -p named.localhost westos.com.zone
vim westos.com.zone1 $TTL 1D2 @ IN SOA westos.com.zone. root.westos.com. ( ##@如果后面不加. 自动补齐westos.com3 0 ; serial4 1D ; refresh5 1H ; retry6 1W ; expire7 3H ) ; minimum8 NS dns.westos.com.9 dns A 172.25.254.11710 www A 172.25.254.111
systemctl restart named
测试:dig www.westos.com
@@@如果想让DNS服务器实现轮询:
vim westos.com.zone
10 www CNAME sjw.westos.com.
11 sjw A 172.25.254.111
12 sjw A 172.25.254.222
systemctl restart named
DNS反向解析
vim /etc/named.rfc1912.zones 47 zone "254.25.172.in-addr.arpa" IN {48 type master;49 file "westos.com.ptr";50 allow-update { none; };51 };
cp -p named.loopback westos.com.ptr
vim westos.com.ptr1 $TTL 1D2 @ IN SOA dns.westos.com. root.westos.com. (3 0 ; serial4 1D ; refresh5 1H ; retry6 1W ; expire7 3H ) ; minimum8 NS dns.westos.com.9 dns A 172.25.254.11710 111 PTR www.westos.com.11 222 PTR sjw.westos.com.
systemctl restart named
测试:dig -x 172.25.254.111
dig -x 172.25.254.222
双向解析
cp -p westos.com.zone westos.com.inter
vim westos.com.inter %s/172.25.254/192.25.254/g
cp /etc/named.rfc1912.zones /etc/named.rfc1912.zones.inter -p
vim named.rfc1912.zones.inter 24 zone "westos.com" IN {25 type master;26 file "westos.com.inter";27 allow-update { none; };28 };
vim named.conf 50 #zone "." IN {51 # type hint;52 # file "named.ca";53 #};54 #55 #include "/etc/named.rfc1912.zones";56 #include "/etc/named.root.key";57 #58 view localnet{59 match-clients {172.25.254.117; }; ##这里填的是localhost60 zone "." IN{61 type hint;62 file "named.ca";63 };64 include "/etc/named.rfc1912.zones.inter";65 };66 67 view internet{68 match-clients {any; };69 zone "." IN{70 type hint;71 file "named.ca";72 };73 include "/etc/named.rfc1912.zones";74 };vim /etc/resolv.conf
nameserver 172.25.254.217
测试:
在内网和外网测试dig www.westos.com
这篇关于linux DNS高速缓存的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!