0.DNS设置:
http://wp.tanguu.com/wp-admin/post.php?post=1181&action=edit
1. 参考
设置动态DNS参考:
http://www.cnblogs.com/qlight/archive/2012/08/28/2660314.html
http://blog.csdn.net/zhu_tianwei/article/details/45128079
- 公司内网安装DNS服务器软件(不作为DNS节点)
yum -y install bind bind-chroot bind-util bind-libs - 内网服务器DNS更新脚本
因为公司使用的宽带无固定IP,所以应该在公司内网的主动更新公网IP才方便
a.用到的文件,配合脚本,5个:
add-file delete-file old-ip
auto-update-dns.sh
up-record.txtb.除了脚本文件,其他四个文件为空
auto-update-dns.sh内容
#!/bin/bash
oldip=$(cat /data/script/old-ip)
wlanip=$(curl http://members.3322.org/dyndns/getip) #获取公司出口IP
deletefile="/var/named/ns-delete.txt"
addfile="/var/named/ns-add.txt"
#判断是否IP改变,如果相同,则退出
if [ $wlanip = $oldip ]; then
echo "(0)wlanip eq oldip:$(date)" >> /data/script/up-record.txt
exit
else
echo $wlanip > /data/script/old-ip
fi
#delete old dns-record
echo "server 120.24.228.37" > $deletefile
echo "zone xxxx.cn" >> $deletefile
echo "update delete test.xxxx.cn A" >> $deletefile
echo "send" >> $deletefile
echo "quit" >> $deletefile
#add new dns-record
echo "server 120.24.228.37" > $addfile
echo "zone xxxx.cn" >> $addfile
echo "update add test.xxxx.cn 6000 IN A $wlanip" >> $addfile
echo "send" >> $addfile
echo "quit" >> $addfile
#执行删除旧DNS记录
nsupdate $deletefile
#执行添加新DNS记录
nsupdate $addfile
echo "(1)dns is updated,$wlanip:$(date)" >> /data/script/up-record.txt
- 定时更新DNS
每5分钟检查一次公网IP是否改变
*/5 * * * * sh /data/script/auto-update-dns.sh
注意:
1.在服务器端需要设置成可以更新ds,
在定义zone节点内:allow-update {any;};
2.不需要重启服务端及客户端服务