智能DNS服務器搭建


 

前期准備

查看IP

[root@localhost ~]# ip a | grep ens

2: ens32: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000

    inet 192.168.200.111/24 brd 192.168.200.255 scope global ens32

3: ens34: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000

    inet 172.16.1.1/24 brd 172.16.1.255 scope global ens34

[root@localhost ~]# systemctl stop firewalld

[root@localhost ~]# iptables -F

[root@localhost ~]# setenforce 0

setenforce: SELinux is disabled

[root@localhost ~]# yum -y install bind

修改主配置文件中為不同運營商的客戶機地址准備不同的zone 區域設置,各自使用獨立的數據文件

[root@localhost ~]# cat /var/named/wangtong.txt

acl wangtong {

172.16.1.3;

};

[root@localhost ~]# cat /var/named/dianxin.txt

acl dianxin {

172.16.1.2;

};

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

options {

directory "/var/named";     

};                         

include "/var/named/dianxin.txt";

include "/var/named/wangtong.txt";

view "dianxin" {

match-clients { dianxin; };

zone "crushlinux.com" IN {

type master;

file "crushlinux.zheng.dianxin";

};

};

view "wangtong" {

match-clients { wangtong; };

zone "crushlinux.com" IN {

        type master;

        file "crushlinux.zheng.wangtong";

};

};

 

分別建立不同的區域數據文件

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

[root@localhost ~]# cat /var/named/crushlinux.zheng.dianxin

$TTL 86400

@INSOAcrushlinux.com.  admin.crushlinux.com. (

2019011001

3H

15M

1W

1D

)

INNSns.crushlinux.com.

INMX 10mail.crushlinux.com.

nsINA172.16.1.1

wwwINA172.16.1.12

mailINA172.16.1.12

 

[root@localhost ~]# cat /var/named/crushlinux.zheng.wangtong

$TTL 86400

@INSOAcrushlinux.com.  admin.crushlinux.com. (

2019011001

3H

15M

1W

1D

)

INNSns.crushlinux.com.

INMX 10mail.crushlinux.com.

nsINA172.16.1.1

wwwINA172.16.1.13

mailINA172.16.1.13

[root@localhost named]# chgrp named crushlinux.zheng.*

[root@localhost named]# ls -l crushlinux.zheng.*

-rw-r--r-- 1 root named 229 1月  10 23:51 crushlinux.zheng.lan

-rw-r--r-- 1 root named 214 1月  10 23:52 crushlinux.zheng.wan

[root@localhost named]# systemctl restart named

 

客戶機設置網絡模式為 vmnet2 IP地址為172.16.1.2 模擬電信用戶,解析測試

C:\Users\Crushlinux>nslookup www.crushlinux.com

服務器:  UnKnown

Address:  172.16.1.1

名稱:    www.crushlinux.com

Address:  172.16.1.12

---------------------------------------------------------------------------------------------------------------------------------

中國各大運營商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

 

 

 

---------------------------------------------------------------------------------------------------------------------------------

腳本編輯

[root@localhost ~]# cat 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 ~]# crontab -e

**/5***/usr/sbin/ntpdate pool.ntp.org > /dev/null 2>&1

050***/bin/bash /root/ispip.sh

[root@localhost ~]# systemctl restart crond

---------------------------------------------------------------------------------------------------------------------------------------------------------------------

 

CDN加速基礎原理

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM