前期准备
查看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加速基础原理