DNS
1.部署dns
yum install bind.x86_64 -y
systemctl start named ##敲键盘,以生成/etc/rndc.key
systemctl stop firewalld
systemctl disable firewalld
主配置文件: /etc/named.conf
子配置文件: /etc/name.rfc1912.zones
数据目录: /var/named
2.高速缓存DNS
listen-on port 53 { any; }; 53号端口开放给any
allow-query { 172.25.254.49 }; 当本机查不到时,转发给49号主机
systemctl restart named 重启服务
测试
dig www.baidu.com
3.权威dns的正向解析
vim /etc/named.rfc1912.zones
zone “westos.com” IN {
type master;
file “westos.com.zone”;
allow-update { none; };
}; 当访问westos.com这个域名时,去找westos.com.zone这个文件
cd /var/named/
cp -p named.localhost westos.com.zone #同时复制权限
vim westos.com.zone
systemctl restart named
0 serial #用来表示更改信息
1D ; refresh #1天刷新
1H ; retry #1小时重试
1W ; expire #1周失效
3H ) ; minimum #3小时问答(防止ddos攻击)
测试:在其他主机上
dig www.westos.com
4.反向解析
vim /etc/named.rfc1912.zones
zone “254.25.172.in-addr.arpa” IN {
type master;
file “westos.com.ptr”;
allow-update { none; };
};
以172.25.254开头的访问westos.com.ptr这个文件
vim westos.com.ptr
测试:在其他主机上
dig -x 172.25.254.107
5.双向解析
vim /etc/named.conf
localnet表示一类,就是172.25.254.49那类访问.zones文件
any表示其他类,就是后面的any类,访问.inter文件
cp /etc/named.rfc1912.zones
/etc/named.rfc1912.zones.inter -p
vim /etc/named.rfc1912.zones.inter
cp -p westos.com.zone westos.com.inter
vim westos.com.inter
systemctl restart named
测试:在49主机上
dig www.westos.com
在其他主机上
dig www.westos,com
6.辅助dns
*)主dns设定
vim /etc/named.rfc1912.zone.inter
slso-notify表示服务重启的时候,通知172.25.254.125
systemctl restart named
*)辅助dns设定
yum install bind -y
systemctl restart named
systemctl stop firewalld
vim /etc/named.conf
vim /etc/named.rfc1912.zones
westos.com 的域名,访问slaves/westos.com.inter文件
systemctl restart named
会在/var/named/slaves中自动同步一个文件
测试:
在远程主机上访问副dns服务器
结果:
7.dns远程更新
*)基于IP的
在主dns上
vim /etc/named.rfc1912.zone.inter
allow
allow-update表示允许172.25.254.125修改我的dns服务
systemctl restart named
chmod g+w /var/named
在slave上
[[email protected] ~]# nsupdate
测试:
dig www.bbs.westos.com
基于KEY的
cp /etc/rndc.key /etc/westos.key -p
dnssec-****** -a HMAC-MD5 -b 123 -n HOST westos
cat Kwestos.+157+47910.key
vim /etc/westos.key
vim /etc/named.conf
vim /etc/named.rfc1912.zones.inter
scp Kwestos.+157+47910.* [email protected]:/mnt
nsupdate -k Kwestos.+157+47910.private
server 172.25.254.111
update add bbs.westos.com 86400 A 5.5.5.5
send
quit
测试: