一、需求
随着线上机器增多,管理/etc/hosts的IP与主机名映射,就成了一个瓶劲,虽然,也可利用批量工具来维护,但相比dns管理,效率会更高点
二、以本机实验环境
IP地址:
10.1.2.214 master 主DNS服务器端 10.1.2.215 slave-one 从DNS服务器端
2、我已经搭建好了一个本地DNS服务器,能够实现正向反向解析,那么我们只需要加入一台从DNS服务器即可完成,我们来开始配置主从服务器
3、主DNS服务器上面的额外配置:
/var/named/abc.com.zone
$TTL 600 @ IN SOA ns.abc.com. admin.abc.com. ( 2016021803 2H 10m 3D 1D ) IN NS ns IN MX 10 mail ns IN A 10.1.2.214 ns1 IN A 10.1.2.215 mail IN A 10.1.2.214 mail IN A 10.1.2.215 www IN A 10.1.2.214 www IN A 10.1.2.215 vm9 IN A 10.1.2.199 vm1 IN A 10.1.2.191 vm2 IN A 10.1.2.192 vm3 IN A 10.1.2.193 vm4 IN A 10.1.2.194 vm5 IN A 10.1.2.195
三、从服务器的配置
1、主DNS服务器的主配置文件/etc/named.conf复制一份到从DNS服务器上
[[email protected] named]#scp /etc/named.conf slave-one:/etc/
2、从服务器区域配置文件:/etc/named.rfc1912.zones
zone "abc.com" IN { type slave; file "slaves/abc.com.zone"; masters { 10.1.2.214; }; allow-transfer { none; }; }; zone "2.1.10.in-addr.arpa" IN { type slave; file "slaves/10.1.2.zone"; masters { 10.1.2.214; }; allow-transfer { none; }; };
4、检查一下语法正确与否
#named-checkconf /etc/named.rfc1912.zones
5、重启named服务,排错,需根据日志/var/log/message
四、注意事项
1、每更改正向区域解析库文件时,序列号一定要加1
2、打算放在线上环境,我作了区域传送安全机制
<code>allow-transfer { IP; } </code>
五、验证
1、nslookup验证
[[email protected] named]# nslookup
> mail.abc.com Server:10.1.2.214 Address:10.1.2.214#53 Name:mail.abc.com Address: 10.1.2.215 Name:mail.abc.com Address: 10.1.2.214
> 10.1.2.215 Server:10.1.2.214 Address:10.1.2.214#53 215.2.1.10.in-addr.arpaname = mail.abc.com. 215.2.1.10.in-addr.arpaname = www.abc.com. 215.2.1.10.in-addr.arpaname = ns1.abc.com.
> 10.1.2.214 Server:10.1.2.214 Address:10.1.2.214#53 214.2.1.10.in-addr.arpaname = ns.abc.com. 214.2.1.10.in-addr.arpaname = mail.abc.com. 214.2.1.10.in-addr.arpaname = www.abc.com.
2、dig进行测试,-t选项指定类型
[[email protected] named]# dig -t axfr abc.com @127.0.0.1 ; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.37.rc1.el6_7.6 <<>> -t axfr abc.com @127.0.0.1 ;; global options: +cmd abc.com.600INSOAns.abc.com. admin.abc.com. 2016021803 7200 600 259200 86400 abc.com.600INNSns.abc.com. abc.com.600INMX10 mail.abc.com. mail.abc.com.600INA10.1.2.214 mail.abc.com.600INA10.1.2.215 ns.abc.com.600INA10.1.2.214 ns1.abc.com.600INA10.1.2.215 vm1.abc.com.600INA10.1.2.191 vm2.abc.com.600INA10.1.2.192 vm3.abc.com.600INA10.1.2.193 vm4.abc.com.600INA10.1.2.194 vm5.abc.com.600INA10.1.2.195 vm9.abc.com.600INA10.1.2.199 www.abc.com.600INA10.1.2.214 www.abc.com.600INA10.1.2.215 abc.com.600INSOAns.abc.com. admin.abc.com. 2016021803 7200 600 259200 86400 ;; Query time: 0 msec ;; SERVER: 127.0.0.1#53(127.0.0.1) ;; WHEN: Wed Mar 16 20:19:22 2016 ;; XFR size: 16 records (messages 1, bytes 369)
3、去连内网其中一台机器vm3时,一定以.abc.com结尾,连接上后,原来机器主机名还是保持不变的
[[email protected] named]# ssh vm3.abc.com The authenticity of host ‘vm2.abc.com (10.1.2.192)‘ can‘t be established. RSA key fingerprint is 8f:b2:be:e9:06:55:47:87:ab:6b:d8:3e:42:a3:72:ed. Are you sure you want to continue connecting (yes/no)? [email protected]‘s password: Last login: Fri Mar 11 04:05:07 2016 from 10.1.2.209 [[email protected] ~]# ls [[email protected] ~]# hostname vm3
时间: 2024-10-24 05:45:26