基于dns实现主从服务器
配置dns主从服务器解析qq.com域下的所有主机名例如:www.qq.com aaa.qq.com bbb.qq.com
dns主服务器
[root@localhost named]# vim /etc/named.conf
options {
listen-on port 53 { 192.168.159.130; };
directory “/var/named”;//正反向解析的区域文件路径
allow-transfer { 192.168.159.133; };
};
zone “qq.com” IN {
type master; //缓存服务器 hint
file “named.qq.com”;
};
[root@localhost named]# vim /var/named/named.qq.com
;主机名 TTL Class type(SOA) 数据
$TTL 1D
@ IN SOA @ admin.admin.com. (
2021071301 ;版本号
1D ;检查时间
2H ;重试时间
1D ;过期时间
1D ) ;否定答案的缓存时长
IN NS dns.qq.com.
dns IN A 192.168.159.130
www IN A 192.168.159.111
aaa IN A 192.168.159.100
bbb IN A 192.168.159.250
dns从服务器
修改dns nameserver
nameserver 192.168.159.130
[root@localhost slaves]# vim /etc/resolv.conf
; generated by /usr/sbin/dhclient-script
search localdomain
nameserver 192.168.159.130 ----写主服务器的IP 地址
[root@localhost slaves]# vim /etc/named.conf
options {
listen-on port 53 { 192.168.159.133; };
directory “/var/named/slaves”;
};
zone “qq.com” IN {
type slave;
file “named.qq”;
masters { 192.168.159.130; };
};
测试