环境介绍
[root@dns ~]# cat /etc/centos-release
CentOS release 6.6 (Final)
[root@dns ~]# ifconfig eth0|sed -rn ‘s/.*dr:(.*) B.*/\1/p‘
192.168.30.149
安装部署
[root@dns ~]# yum install -y bind bind-libs bind-utils
[root@dns ~]# cp /etc/named.conf{,.bak}
[root@dns ~]# vim /etc/named.conf
options {
// listen-on port 53 { 127.0.0.1; }; # 或【listen-on port 53 { 192.168.30.149; 127.0.0.1; };】
// listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
// allow-query { localhost; }; # 或【allow-query { any; };】
recursion yes;
// dnssec-enable yes;
// dnssec-validation yes;
/* Path to ISC DLV key */
// bindkeys-file "/etc/named.iscdlv.key";
// managed-keys-directory "/var/named/dynamic";
};
[root@dns ~]# named-checkconf
[root@dns ~]# /etc/init.d/named start
[root@dns ~]# ss -lntup4|grep named
略
客户端
[root@user ~]# cat /etc/centos-release
CentOS release 6.6 (Final)
[root@user ~]# ifconfig eth0
[root@user ~]# ifconfig eth0|sed -rn ‘s/.*dr:(.*) B.*/\1/p‘
192.168.30.151
[root@user ~]# cat /etc/resolv.conf
; generated by /sbin/dhclient-script
search localdomain
# nameserver 192.168.30.2
[root@user ~]# ping -c 1 baidu.com &>/dev/null && echo ok || echo false
false
[root@user ~]# echo "nameserver 192.168.30.149" >>/etc/resolv.conf
[root@user ~]# ping -c 1 baidu.com &>/dev/null && echo ok || echo false
ok
原文地址:https://www.cnblogs.com/liming-linux-python/p/10421085.html