DNS试图:将一个域名解析成2中不同的地址。实现多个不同运营商的客户端都能快速访问网站。作为一台缓存服务器。当客户请求后根据客户IP来确定解析那一台服务器地址
allow-recursion {};指定某个网段是都递归
allow-query {}; 只允许谁来查询
allow-transfer {}; 指定某个网段可以传送
sxfr
ixfr
如果同时有多个网段的话。可以定义acl。类似脚本里的函数function,一般定义在options之前
allow-query { 172.16.0.0/16; 127.0.0.0/8; 10.0.0.0/8; };
acl innet {
172.16.0.0/16;
127.0.0.0/8;
10.0.0.0/8;
}
allow-query { innet ;};
none;所有的
any;任意
------------------------------------------
view VIEW_NAME {
};
view VIEW_NAME {
};
所有的区域都必须定义在试图中
vi /etc/named.conf
acl innet { 定义acl
127.0.0.0/8;
192.168.10.0/24;
};
options {
directory "/var/named";
allow-recursion { innet; }; 只允许cal地址递归
};
view telecom {
match-clients { innet; }; acl内的地址使用这个视图
zone "mylinux.com" IN {
type master; 定义为主服务器
file "telecom.mylinux.com.zone";
};
};
view unicom {
match-clients { any; }; 其他任意地址都使用这个视图
zone "mylinux.com" IN {
type master;
file "unicom.mylinux.com.zone";
};
};
[[email protected] named]# cd /var/named
[[email protected] named]# vim telecom.mylinux.com.zone
$TTL 3333
@ IN SOA ns1.mylinux.com. admin.mylinux.com. (
2016071001
1H
5M
1D
3H
)
IN NS ns1
IN MX 8 mail
ns1 IN A 192.168.10.2
mail IN A 192.168.10.100
www IN A 192.168.10.3
[[email protected] named]# chmod 640 telecom.mylinux.com.zone
[[email protected] named]# chown root:named telecom.mylinux.com.zone
[[email protected] named]# cp telecom.mylinux.com.zone unicom.mylinux.com.zone -p
[[email protected] named]# vim unicom.mylinux.com.zone
$TTL 3333
@ IN SOA ns1.mylinux.com. admin.mylinux.com. (
2016071001
1H
5M
1D
3H
)
IN NS ns1
IN MX 8 mail
ns1 IN A 192.168.10.2 都是同一台DNS服务器 所以ns1不变
mail IN A 172.168.10.10
www IN A 172.168.10.30 acl以外的地址都访问这个网站地址
-------------------------------------------------------------------
假如需要来自a.net域的主机解析都一样。只要提供域数据文件和域定义 无论多少个域 都可以在一个主机上实现解析
[[email protected] named]# vim /etc/named.conf
allow-recursion { innet; };
};
view telecom {
match-clients { innet; };
zone "mylinux.com" IN {
type master;
file "telecom.mylinux.com.zone";
};
zone "a.net" IN { 新增一个域文件
type master;
file "a.net.zone";
};
};
view unicom {
match-clients { any; };
zone "mylinux.com" IN {
type master;
file "unicom.mylinux.com.zone";
};
zone "a.net" IN { 新增一个域文件
type master;
file "a.net.zone";
};
};
[[email protected] named]# vim a.net.zone
$TTL 4000
@ IN SOA ns1.a.net. admin.a.net. (
20160710
1H
5M
1D
5H
)
IN NS ns1
ns1 IN A 192.168.10.2
www IN A 192.168.10.100
[[email protected] named]# chmod 640 a.net.zone
[[email protected] named]# chown root:named a.net.zone