首页 > 代码库 > CentOS实例项目之三(一)--ZZSRV1上的DNS配置
CentOS实例项目之三(一)--ZZSRV1上的DNS配置
DNS的配置相对于来说是花费时间较多的,所以写得也比较认真,详细。
1. ZZSRV1上的主DNS配置
1.1. 安装BIND
# yum -y install bind bind-utils bind-chroot # rpm -qc bind /etc/logrotate.d/named /etc/named.conf /etc/named.iscdlv.key /etc/named.rfc1912.zones /etc/named.root.key /etc/rndc.conf /etc/rndc.key /etc/sysconfig/named /var/named/named.ca /var/named/named.empty /var/named/named.localhost /var/named/named.loopback # rpm -qc bind-chroot /var/named/chroot/etc/named.conf
1.2. 配置BIND
[root@zzsrv1 ~]# cd /etc [root@zzsrv1 etc]# cp named.conf named.conf.origin
1.2.1. Cache Only Server
做这个目的是对DNS基本功能 进行检查
[root@zzsrv1 etc]# vi /etc/named.conf
修改配置
//listen-on port 53 { 127.0.0.1; };
listen-on port 53 { any; };
//allow-query { localhost; };
allow-query { any; };
//dnssec-enable yes;
dnssec-enable no;
//dnssec-validation yes;
dnssec-validation no;
添加
forwarders {202.102.224.68; 202.102.227.68;};
allow-transfer { 192.168.188.11; 192.168.188.12; };
# service named start Redirecting to /bin/systemctl start named.service Aug 11 11:46:13 zzsrv1 systemd: Starting Generate rndc key for BIND (DNS)...
会很慢,在日志中看到是在生成key
# rndc status version: 9.9.4-RedHat-9.9.4-14.el7 <id:8f9657aa> CPUs found: 1 worker threads: 1 UDP listeners per interface: 1 number of zones: 101 debug level: 0 xfers running: 0 xfers deferred: 0 soa queries in progress: 0 query logging is OFF recursive clients: 2/0/1000 tcp clients: 0/100 server is up and running [root@zzsrv1 etc]# nslookup > server 192.168.188.11 切换到本机 Default server: 192.168.188.11 Address: 192.168.188.11#53 > www.g.cn. Server: 192.168.188.11 Address: 192.168.188.11#53 Non-authoritative answer: Name: www.g.cn Address: 203.208.46.179 Name: www.g.cn Address: 203.208.46.177 Name: www.g.cn Address: 203.208.46.180 Name: www.g.cn Address: 203.208.46.176 Name: www.g.cn Address: 203.208.46.178 > exit
Cache Only 服务器配置完毕,现在添加自定义的zone
1.2.2. 添加自定义Zone
# vi /etc/named.conf
添加如下zone信息
zone "bigcloud.local" IN {
type master;
file "bigcloud.local.zone";
};
zone "188.168.192.in-addr.arpa" IN {
type master;
file "192.168.188.zone";
};
zone "189.168.192.in-addr.arpa" IN {
type master;
file "192.168.189.zone";
};
# cd /var/named/
# vi bigcloud.local.zone
$TTL 3H @ IN SOA zzsrv1.bigcloud.local. tom_chen.126.com ( 0 ; serial 1D ; refresh 1H ; retry 1W ; expire 3H ) ; minimum IN NS zzsrv1.bigcloud.local. IN NS zzsrv2.bigcloud.local. zzsrv1 IN A 192.168.188.11 zzsrv2 IN A 192.168.188.12 ftp IN A 192.168.188.11 mailsrv1 IN A 192.168.188.22 smtp IN CNAME mailsrv1.bigcloud.local. pop3 IN CNAME mailsrv1.bigcloud.local. www IN A 192.168.188.11 crm IN A 192.168.188.11 |
# vi 192.168.188.zone
$TTL 3H @ IN SOA zzsrv1.bigcloud.local. tom_chen.126.com ( 0 ; serial 1D ; refresh 1H ; retry 1W ; expire 3H ) ; minimum IN NS zzsrv1.bigcloud.local. IN NS zzsrv2.bigcloud.local. 11 IN PTR zzsrv1.bigcloud.local. 11 IN PTR ftp.bigcloud.local. 12 IN PTR zzsrv2.bigcloud.local. 12 IN PTR mailsrv1.bigcloud.local. |
# vi 192.168.189.zone
$TTL 3H @ IN SOA zzsrv1.bigcloud.local. tom_chen.126.com ( 0 ; serial 1D ; refresh 1H ; retry 1W ; expire 3H ) ; minimum IN NS zzsrv1.bigcloud.local. IN NS zzsrv2.bigcloud.local. |
启动服务 # service named restart Redirecting to /bin/systemctl restart named.service 查看日志,检查是否有报错信息。(建议在启动时,就在另外一个会话时就打开) # tail -f /var/log/messages # rndc status version: 9.9.4-RedHat-9.9.4-14.el7 <id:8f9657aa> CPUs found: 1 worker threads: 1 UDP listeners per interface: 1 number of zones: 104 debug level: 0 xfers running: 0 xfers deferred: 0 soa queries in progress: 0 query logging is OFF recursive clients: 0/0/1000 tcp clients: 0/100 server is up and running 设置为自动启动 # systemctl enable named # systemctl status named named.service - Berkeley Internet Name Domain (DNS) Loaded: loaded (/usr/lib/systemd/system/named.service; enabled) Active: active (running) since Tue 2014-08-12 10:11:26 CST; 4min 9s ago Main PID: 5513 (named) CGroup: /system.slice/named.service 5513 /usr/sbin/named -u named named[5513]: zone localhost/IN: loaded serial 0 named[5513]: zone 188.168.192.in-addr.arpa/IN: loaded serial 0 named[5513]: zone bigcloud.local/IN: loaded serial 0 named[5513]: zone localhost.localdomain/IN: loaded serial 0 named[5513]: all zones loaded named[5513]: running systemd[1]: Started Berkeley Internet Name Domain (DNS). named[5513]: zone bigcloud.local/IN: sending notifies (serial 0) named[5513]: zone 188.168.192.in-addr.arpa/IN: sending notifies (serial 0) named[5513]: zone 189.168.192.in-addr.arpa/IN: sending notifies (serial 0)
1.3. 测试
# nslookup > server 192.168.188.11 Default server: 192.168.188.11 Address: 192.168.188.11#53 > www.bigcloud.local. Server: 192.168.188.11 Address: 192.168.188.11#53 Name: www.bigcloud.local Address: 192.168.188.11 > smtp.bigcloud.local. Server: 192.168.188.11 Address: 192.168.188.11#53 smtp.bigcloud.local canonical name = mailsrv1.bigcloud.local. Name: mailsrv1.bigcloud.local Address: 192.168.188.22 > 192.168.188.11 Server: 192.168.188.11 Address: 192.168.188.11#53 11.188.168.192.in-addr.arpa name = ftp.bigcloud.local. 11.188.168.192.in-addr.arpa name = zzsrv1.bigcloud.local. > exit
在Windows服务器上测试,尝试列出zone数据
> ls -d bigcloud.local [[192.168.188.11]] *** 无法列出域 bigcloud.local: Query refused DNS 服务器拒绝将区域 bigcloud.local 传送到您的计算机。如果这不正确 请检查 IP 地址 192.168.188.11 的 DNS 服务器上 bigcloud.local 的 区域传送安全设置。 |
本文出自 “刘琼@天道酬勤” 博客,请务必保留此出处http://lqiong.blog.51cto.com/8170814/1559059
CentOS实例项目之三(一)--ZZSRV1上的DNS配置