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 named
 systemctl enable named
 firewall-cmd --permanent --add-server=dns
 firewall-cmd --reload
 firewall-cmd --list-all
 netstat -antlupe|grep 53

4配置其他两台机器dns

vim /etc/resolve.conf
    nameserver 172.25.254.117
• 进行测试
– dig www.baidu.com

这里写图片描述
这里写图片描述
DNS正向解析

vim /etc/named.conf
    forwarders { 172.25.254.250; };     ##删除这一行自己搭建一个DNS
vim /etc/named.rfc1912.zones
    zone "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.zone
  1 $TTL 1D
  2 @       IN SOA   westos.com.zone. root.westos.com. (    ##@如果后面不加. 自动补齐westos.com
  3                                         0       ; serial
  4                                         1D      ; refresh
  5                                         1H      ; retry
  6                                         1W      ; expire
  7                                         3H )    ; minimum
  8         NS      dns.westos.com.
  9 dns     A       172.25.254.117
 10 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.ptr

  1 $TTL 1D
  2 @       IN SOA  dns.westos.com. root.westos.com. (
  3                                         0       ; serial
  4                                         1D      ; refresh
  5                                         1H      ; retry
  6                                         1W      ; expire
  7                                         3H )    ; minimum
  8         NS      dns.westos.com.
  9 dns     A       172.25.254.117
 10 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; };   ##这里填的是localhost
 60         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

没有更多推荐了,返回首页