一、環(huán)境準(zhǔn)備
創(chuàng)新互聯(lián)是一家集網(wǎng)站建設(shè),灌陽企業(yè)網(wǎng)站建設(shè),灌陽品牌網(wǎng)站建設(shè),網(wǎng)站定制,灌陽網(wǎng)站建設(shè)報(bào)價(jià),網(wǎng)絡(luò)營銷,網(wǎng)絡(luò)優(yōu)化,灌陽網(wǎng)站推廣為一體的創(chuàng)新建站企業(yè),幫助傳統(tǒng)企業(yè)提升企業(yè)形象加強(qiáng)企業(yè)競爭力??沙浞譂M足這一群體相比中小企業(yè)更為豐富、高端、多元的互聯(lián)網(wǎng)需求。同時(shí)我們時(shí)刻保持專業(yè)、時(shí)尚、前沿,時(shí)刻以成就客戶成長自我,堅(jiān)持不斷學(xué)習(xí)、思考、沉淀、凈化自己,讓我們?yōu)楦嗟钠髽I(yè)打造出實(shí)用型網(wǎng)站。
虛擬機(jī):vmware workstation 11
linux系統(tǒng):centos7.3,centos6.8
bind安裝:yum install bind
DNS主服務(wù)器A:環(huán)境:centos7.3 IP:172.16.252.35 DNS主機(jī)名:dns1.ilinux.io.
DNS從服務(wù)器B: 環(huán)境:centos6.8 IP:10.0.0.68 DNS主機(jī)名:dns2.ilinux.io (為后續(xù)實(shí)驗(yàn)準(zhǔn)備)
虛擬域名:www.ilinux.io
bind主配置文件修改(centos7.3,6.8皆修改):
#注:僅列出options{}中更改的內(nèi)容,其余不變 vi /etc/named.conf options { //listen-on port 53 { 127.0.0.1; }; #默認(rèn)允許所有IP監(jiān)聽53端口 //listen-on-v6 port 53 { ::1; }; // allow-query { localhost; }; #關(guān)閉僅允許本機(jī)解析 dnssec-enable no; #為了方便,關(guān)閉DNS安全功能 dnssec-validation no; };
1 正向解析
步驟
第一步:編輯解析數(shù)據(jù)庫文件
vi /var/named/ilinux.io.zone $TTL 600 ilinux.io. IN SOA ilinux.io. nsadmin.ilinux.io. ( 2017052301 1H 5M 1W 6H ) IN NS dns1.ilinux.io. IN NS dns2.ilinux.io. IN MX10 mx1.ilinux.io. dns1.ilinux.io. IN A 172.16.252.35 dns2.ilinux.io. IN A 10.0.0.68 mx1.ilinux.io. IN A 10.10.1.1 www.ilinux.io. IN A 172.16.1.1 web IN CNAME www ftp IN A 172.16.0.111
第二步:編輯bind輔助配置文件
vi /etc/named.rfc1912.zones ...(省略部分內(nèi)容) #最后一行加入如下內(nèi)容 zone "ilinux.io" IN { type master; file "ilinux.io.zone"; };
第三步:指定解析服務(wù)器IP
vi /etc/resolv.conf nameserver 172.16.252.35
第四步:權(quán)限及屬組修改(基于安全考慮)
chmod o= /var/named/ilinux.io.zone chown :named /var/named/ilinux.io.zone ls -l /var/named/ilinux.io.zone -rw-r-----. 1 root named 454 May 28 10:17 /var/named/ilinux.io.zone
第五步:檢查語法錯(cuò)誤
named-checkconf named-checkzone ilinux.io ilinux.io.zone zone ilinux.io/IN: loaded serial 2017052301 OK #驗(yàn)證正確
第六步:重新加載解析數(shù)據(jù)庫文件和配置文件
rndc reload server reload successful systemctl restart named.service
第七步:測試域名解析
dig www.ilinux.io ; <<>> DiG 9.9.4-RedHat-9.9.4-37.el7 <<>> www.ilinux.io ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 17242 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 3 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 4096 ;; QUESTION SECTION: #查詢部分 ;www.ilinux.io.INA ;; ANSWER SECTION: #回答部分 www.ilinux.io.600INA172.16.1.1 ;; AUTHORITY SECTION: #權(quán)威解析部分 ilinux.io.600INNSdns1.ilinux.io. ilinux.io.600INNSdns2.ilinux.io. ;; ADDITIONAL SECTION: #附加信息部分 dns1.ilinux.io.600INA172.16.252.35 dns2.ilinux.io.600INA10.0.0.68 ;; Query time: 1 msec ;; SERVER: 172.16.252.35#53(172.16.252.35) ;; WHEN: Sun May 28 11:16:29 CST 2017 ;; MSG SIZE rcvd: 128
2 反向解析
步驟
第一步:編輯解析數(shù)據(jù)庫文件
vi /var/named/172.16.zone $TTL 1D @IN SOAilinux.io. nsadmin.ilinux.io. ( 2017052301; serial 1D ; refresh 1H ; retry 1W ; expire 3H ) ; minimum @INNSdns1.ilinux.io. @INNSdns2.ilinux.io. 35.252INPTRdns1.ilinux.io. 68.0INPTRdns2.ilinux.io. 1.1INPTRwww.ilinux.io. 111.0INPTRftp.ilinux.io.
第二步:編輯bind輔助配置文件
vi /etc/named.rfc1912.zones #最后一行加入如下信息 zone "16.172.in-addr.arpa" IN { type master; file "172.16.zone"; };
第三步:指定解析服務(wù)器IP
vi /etc/resolv.conf nameserver 172.16.252.35
第四步:權(quán)限及屬組修改(安全考慮)
chmod o= 172.16.zone chown :named 172.16.zone ll 172.16.zone -rw-r-----. 1 root named 298 May 28 10:58 172.16.zone
第五步:檢查語法錯(cuò)誤
named-checkconf named-checkzone 16.172.in-addr.arpa 172.16.zone zone 16.172.in-addr.arpa/IN: loaded serial 2017052301 OK #驗(yàn)證成功
第六步:重新加載解析數(shù)據(jù)庫文件和配置文件
rndc reload server reload successful systemctl restart named.service
第七步:測試域名解析
dig -x 172.16.1.1 ; <<>> DiG 9.9.4-RedHat-9.9.4-37.el7 <<>> -x 172.16.1.1 ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 17034 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 3 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 4096 ;; QUESTION SECTION: ;1.1.16.172.in-addr.arpa.INPTR ;; ANSWER SECTION: 1.1.16.172.in-addr.arpa. 86400INPTRwww.ilinux.io. ;; AUTHORITY SECTION: 16.172.in-addr.arpa.86400INNSdns1.ilinux.io. 16.172.in-addr.arpa.86400INNSdns2.ilinux.io. ;; ADDITIONAL SECTION: dns1.ilinux.io.600INA172.16.252.35 dns2.ilinux.io.600INA10.0.0.68 ;; Query time: 0 msec ;; SERVER: 172.16.252.35#53(172.16.252.35) ;; WHEN: Sun May 28 11:45:36 CST 2017 ;; MSG SIZE rcvd: 149
3 主從DNS服務(wù)器配置(包含正反向域名解析)
步驟
第一步:編輯bind輔助配置文件
1.DNS主服務(wù)器正反向解析文件配置上面已有配置,不再介紹
2.DNS從服務(wù)器正反向解析區(qū)域配置文件
環(huán)境:centos6.8 IP:10.0.0.68 DNS主機(jī)名:dns2.ilinux.io
vi /etc/named.rfc1912.zones #最后一行加入如下信息 zone "ilinux.io" IN { type slave; file "slaves/ilinux.io.zone"; masters { 172.16.252.35; }; }; zone "16.172.in-addr.arpa" IN { type slave; file "slaves/172.16.zone"; masters { 172.16.252.35; }; };
第二步:檢查語法錯(cuò)誤
named-checkconf
第三步:重新加載配置文件
rndc reload server reload successful systemctl restart named.service
第四步:查看是否配置成功
cat /var/log/messages | grep "Transfer completed" May 28 08:46:20 localhost named[2224]: transfer of 'ilinux.io/IN' from 172.16.252.35#53: Transfer completed: 1 messages, 11 records, 271 bytes, 0.002 secs (135500 bytes/sec) May 28 08:54:58 localhost named[2224]: transfer of '16.172.in-addr.arpa/IN' from 172.16.252.35#53: Transfer completed: 1 messages, 7 records, 227 bytes, 0.004 secs (56750 bytes/sec)
第五步:測試從服務(wù)域名解析
正向解析測試 [root@god named]#dig www.ilinux.io @10.0.0.68 ; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.47.rc1.el6 <<>> www.ilinux.io @10.0.0.68 ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 51468 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 2 ;; QUESTION SECTION: ;www.ilinux.io.INA ;; ANSWER SECTION: www.ilinux.io.600INA172.16.1.1 ;; AUTHORITY SECTION: ilinux.io.600INNSdns2.ilinux.io. ilinux.io.600INNSdns1.ilinux.io. ;; ADDITIONAL SECTION: dns1.ilinux.io.600INA172.16.252.35 dns2.ilinux.io.600INA10.0.0.68 ;; Query time: 1 msec ;; SERVER: 10.0.0.68#53(10.0.0.68) ;; WHEN: Sun May 28 10:51:34 2017 ;; MSG SIZE rcvd: 117
反向解析測試
dig -x 172.16.1.1 @10.0.0.68 ; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.47.rc1.el6 <<>> -x 172.16.1.1 @10.0.0.68 ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 21780 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 2 ;; QUESTION SECTION: ;1.1.16.172.in-addr.arpa.INPTR ;; ANSWER SECTION: 1.1.16.172.in-addr.arpa. 86400INPTRwww.ilinux.io. ;; AUTHORITY SECTION: 16.172.in-addr.arpa.86400INNSdns2.ilinux.io. 16.172.in-addr.arpa.86400INNSdns1.ilinux.io. ;; ADDITIONAL SECTION: dns1.ilinux.io.600INA172.16.252.35 dns2.ilinux.io.600INA10.0.0.68 ;; Query time: 0 msec ;; SERVER: 10.0.0.68#53(10.0.0.68) ;; WHEN: Sun May 28 10:49:23 2017 ;; MSG SIZE rcvd: 138
4 總結(jié)
本文中DNS域名解析服務(wù)是基于bind來實(shí)驗(yàn)操作的。
文中僅分享了如何配置DNS域名解析服務(wù),至于配置bind服務(wù)中相關(guān)的知識(shí)點(diǎn)可以參考如下:
https://www.isc.org/downloads/bind/doc/ 官方文檔
《鳥哥的Linux私房菜服務(wù)器架設(shè)篇(第三版)》
本文實(shí)驗(yàn)包含DNS正向解析服務(wù)部署,DNS反向解析服務(wù)部署,DNS主從服務(wù)部署。
想要掌握DNS域名解析服務(wù),深刻了解DNS域名解析知識(shí)必不可少,多多動(dòng)手操作配置服務(wù)必不可少。