1,安装DNS
[root@VM_16_17_centos ~]# yum -y install bind
2,配置DNS
[root@VM_16_17_centos ~]# vim /etc/named.conf
options {
listen-on port 53 { 127.0.0.1; 192.168.0.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; any; };
recursion yes;
dnssec-enable no;
dnssec-validation no;
dnssec-lookaside auto;
/* Path to ISC DLV key */
bindkeys-file “/etc/named.iscdlv.key”;
managed-keys-directory “/var/named/dynamic”;
};
logging {
channel default_debug {
file “data/named.run”;
severity dynamic;
};
};
zone “.” IN {
type hint;
file “named.ca”;
};
include “/etc/named.rfc1912.zones”;
include “/etc/named.root.key”;
vim /etc/named.rfc1912.zones
zone “uplooking.com” IN {
type master;
file “uplooking.com.zone”;
allow-update { none; };
};
创建区域文件
[root@VM_16_17_centos ~]# cd /var/named/
[root@VM_16_17_centos ~]# cp -a named.localhost uplooking.com.zone(必须要加-a,否则named用不了这个文件,DNS无效)
[root@VM_16_17_centos ~]# vim uplooking.com.zone
$TTL 86400
@ IN SOA dns.uplooking.com. root.uplooking.com. (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
@ IN NS dns.uplooking.com.
dns IN A 192.168.0.1
www IN A 192.168.0.100
www IN A 192.168.0.101
www IN A 192.168.0.102
www IN A 192.168.0.103
www IN A 192.168.0.104
检查配置文件的语法
[root@VM_16_17_centos ~]# named-checkconf /etc/named.conf
[root@VM_16_17_centos ~]# named-checkzone uplooking.com /var/named/uplooking.com.zone
zone uplooking.com/IN: loaded serial 42
OK
启动DNS服务
[root@VM_16_17_centos ~]# service named start
[root@VM_16_17_centos ~]# chkconfig named on
[root@VM_16_17_centos ~]# netstat -unlp |grep :53
udp 0 0 192.168.0.1:53 0.0.0.0:* 2846/named
udp 0 0 127.0.0.1:53 0.0.0.0:* 2846/named
测试DNS轮询:
[root@VM_16_17_centos ~]# vim /etc/resolv.conf
nameserver 192.168.0.1
[root@VM_16_17_centos ~]#ping www.uplooking.com
PING www.uplooking.com (192.168.0.100) 56(84) bytes of data
[root@VM_16_17_centos ~]# ping www.uplooking.com
PING www.uplooking.com (192.168.0.101) 56(84) bytes of data
[root@VM_16_17_centos ~]#ping www.uplooking.com
PING www.uplooking.com (192.168.0.102) 56(84) bytes of data.
[root@VM_16_17_centos ~]# ping www.uplooking.com
PING www.uplooking.com (192.168.0.103) 56(84) bytes of data.
[root@VM_16_17_centos ~]#ping www.uplooking.com
PING www.uplooking.com (192.168.0.104) 56(84) bytes of data.