Linux DNS分离解析与构建智能DNS服务器

一 构建DNS分离解析

方法一 :

[root@localhost ~]# vim /etc/named.conf 

[root@localhost ~]# cd /var/named/

[root@localhost named]# vim crushlinux.zheng.wan

[root@localhost named]# chgrp named crushlinux.zheng.*   //授予权限

[root@localhost named]# systemctl restart named

测试

 出现这则成功

方法二 : 修改主配置文件

方法三: 修改主配置文件并创建两个新的文件

[root@localhost ~]# vim /var/named/wan.txt

[root@localhost ~]# vim /etc/named.conf

1:这是链接文件所在的位置  若是lan.txt 在/etc/named/lan.txt   

则 是 include “/etc/named/lan.txt”

2: 同上

3:这个  lan   是 lan.txt中  acl  所指的   名

4:同上

二:构建智能DNS域名解析服务器

 [root@localhost named]# vim /etc/named.conf 

网通用户ip地址是 172.16.1.2

电信用户ip地址是 172.16.1.3

[root@localhost ~]# cd /var/named/

[root@localhost named]# vim crushlinux.zheng.wangtong

//www.crushlinux.com  的ip地址 172.16.1.12是网通缓存服务器

//172.16.1.13  是电信缓存服务器地址

[root@localhost named]# chgrp named crushlinux.zheng.*    //赋予wangtong,dianxin 权限   赋予到named组中

root@localhost named]# systemctl restart named

实验

 模拟网通用户

 模拟电信用户

成功

方法二

完事

三 

获取不同运营商的IP地址范围   脚本执行

[root@localhost ~]# vim ispip.sh

#!/bin/bash

 

url="http://ispip.clang.cn/"

for i in chinatelecom unicom_cnc cmcc crtc cernet othernet

do

         wget $url$i.html -O /tmp/$i.txt

         sed -n '/^[0-9]/ s/<br>/;/gp' /tmp/$i.txt | sed "1iacl $i {" | sed '$a};' > /var/named/$i.txt

done

[root@localhost ~]# chmod +x ispip.sh

 

[root@localhost ~]# bash ispip.sh  //执行脚本    前提是 虚拟机能上网

[root@localhost named]# vim chinatelecom.txt

这是某 电信或网通用户的网段

https://github.com/clangcn/everyday-update-cn-isp-ip

根据APNIC的最新IP地址列表及whois信息,每日0点(北京时间)生成的各主要运营商IP地址段。

中国电信 IP地址段:(http://ispip.clang.cn/chinatelecom.html)

中国联通(网通)IP地址段:(http://ispip.clang.cn/unicom_cnc.html)

中国移动 IP地址段:(http://ispip.clang.cn/cmcc.html)

中国铁通 IP地址段:(http://ispip.clang.cn/crtc.html)

中国教育网 IP地址段:(http://ispip.clang.cn/cernet.html)

中国其他ISP IP地址段:(http://ispip.clang.cn/othernet.html)

原文地址:https://www.cnblogs.com/canflyfish/p/11409321.html