linux7.3搭建dns,Centos7.3搭建DNS服务器--BIND
1、系統環境說明
[[email?protected] etc]# cat /etc/redhat-release
CentOS Linux release7.3.1611(Core)
防火墻和Selinux關閉
[[email?protected]-server etc]# systemctl status firewalld.service
● firewalld.service- firewalld -dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs:man:firewalld(1)
Oct11 09:46:22 localhost.localdomain systemd[1]: Starting firewalld -dynamic firewall daemon...
Oct11 09:46:23 localhost.localdomain systemd[1]: Started firewalld -dynamic firewall daemon.
Oct11 09:48:35 localhost.localdomain systemd[1]: Stopping firewalld -dynamic firewall daemon...
Oct11 09:48:35 localhost.localdomain systemd[1]: Stopped firewalld -dynamic firewall daemon.
[[email?protected]-server etc]# getenforce
Permissive
[[email?protected]-server etc]# hostname -I10.0.3.57
2、安裝bind
[[email?protected] ~]# yum install bind* -ql bind/etc/named.conf # 主配置文件/etc/named.rfc1912.zones # 區域解析庫文件/var/log/named.log #日志文件/var/named #服務根目錄
3、修改配置文件
[[email?protected] ~]# cp /etc/named.conf{,.bak}
[[email?protected]-server ~]# vim /etc/named.conf
#刪除IPv6地址,修改監聽地址options { listen-on port 53 { 10.0.3.57; };
.... allow-query { localhost;any; }; //允許DNS查詢客戶端
...
}
4、啟動bind服務
named.conf
#啟動bind服務
[[email?protected]-server ~]# systemctl start named
[[email?protected]-server ~]# netstat -lntup|grep 53tcp0 0 10.0.3.57:53 0.0.0.0:* LISTEN 8053/named
tcp0 0 127.0.0.1:953 0.0.0.0:* LISTEN 8053/named
tcp60 0 ::1:953 :::* LISTEN 8053/named
udp0 0 10.0.3.57:53 0.0.0.0:* 8053/named
#測試DNS服務器 dig @表示指定NDS服務器
[[email?protected]-server ~]# dig baidu.com @10.0.3.57;<<>> DiG 9.9.4-RedHat-9.9.4-61.el7_5.1 <<>> baidu.com @10.0.3.57;; global options:+cmd
;; Got answer:
;;->>HEADER<
; EDNS: version:0, flags:; udp: 4096;; QUESTION SECTION:
;baidu.com. IN A
;; ANSWER SECTION:
baidu.com.600 IN A 123.125.115.110baidu.com.600 IN A 220.181.57.216;; AUTHORITY SECTION:
baidu.com.172082IN NS ns2.baidu.com.
baidu.com.172082IN NS ns7.baidu.com.
baidu.com.172082IN NS dns.baidu.com.
baidu.com.172082IN NS ns4.baidu.com.
baidu.com.172082IN NS ns3.baidu.com.
;; ADDITIONAL SECTION:
dns.baidu.com.172082 IN A 202.108.22.220ns2.baidu.com.172082 IN A 61.135.165.235ns3.baidu.com.172082 IN A 220.181.37.10ns4.baidu.com.172082 IN A 220.181.38.10ns7.baidu.com.172082 IN A 119.75.219.82;; Querytime: 6msec
;; SERVER:10.0.3.57#53(10.0.3.57)
;; WHEN: Thu Oct11 16:51:46 CST 2018;; MSG SIZE rcvd:240
5、搭建內網DNS服務器
讓當前的DNS解析qipai.com域名
/etc/named.conf
include"/etc/named.rfc1912.zones";
include"/etc/named.root.key";
主配置文件中指定了/etc/named.rfc1912.zones文件
01.將域名 IP 關系存儲在DNS上,在/etc/named.rfc1912.zones 文件中進行添加
[[email?protected]~]# vim /etc/named.rfc1912.zones
zone"qipai.com"IN { # qipai.com是域名
type master; # 表示權威DNS,即第一個file "qipai.com.zone"; # 域數據庫,默認位于/var/named/下面,只需告知文件名qipai.com.zone是庫文件名
};
02.以/var/named目錄下的named.localhost為模板,創建nmtui.com.zone文件,創建區域數據庫
[[email?protected] ~]# cd /var/named/
[[email?protected] named]#cp -av named.localhost qipai.com.zone‘named.localhost‘ -> ‘nmtui.com.zone‘ ## 注意cp -a 保持原有屬性
03.解析區域數據庫格式,存放域名與IP的對應關系[[email?protected] named]# catqipai.com.zone$TTL 1D
@ IN SOA @ qipai.top. (30; serial 1M ; refresh 1M ; retry 1M ; expire 3M ) ; minimum NS @ admin A10.0.3.10gm2.admin A10.0.3.10@ A10.0.3.10
6、檢查配置文件,重啟bind服務
[[email?protected] named]# named-checkzone qipai.com /var/named/qipai.com.zone
zone qipai.com/IN: loaded serial 30
7、測試DNS是否生效
Linux測試
[[email?protected] named]# dig qipai.com @10.0.3.57;<<>> DiG 9.9.4-RedHat-9.9.4-61.el7_5.1 <<>> qipai.com @10.0.3.57;; global options:+cmd
;; Got answer:
;;->>HEADER<
; EDNS: version:0, flags:; udp: 4096;; QUESTION SECTION:
;qipai.com. IN A
;; ANSWER SECTION:
qipai.com.86400 IN A 10.0.3.10;; AUTHORITY SECTION:
qipai.com.86400IN NS qipai.com.
;; Querytime: 1msec
;; SERVER:10.0.3.57#53(10.0.3.57)
;; WHEN: Thu Oct11 18:26:21 CST 2018;; MSG SIZE rcvd:68
修改網卡配置文件(/etc/sysconfig/network-scripts/ifcfg-eth0)或/etc/resolv.conf 指定DNS解析
Windows測試,指定DNS服務器
更多詳情參考 bind9中文手冊https://www.centos.bz/manual/BIND9-CHS.pdfhttps://www.linuxprobe.com/set-up-dns-server.html
總結
以上是生活随笔為你收集整理的linux7.3搭建dns,Centos7.3搭建DNS服务器--BIND的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux系统下vim可以不用鼠标,真的
- 下一篇: 如果政府强制开发linux应用,Linu