First, the basic and forward area configuration
1, first install bind (take cnetos6.7 as an example)
[[email protected] ~]# Yum install Bind-y#bind primarily provides DNS resolution services for Linux hosts, the package name is bind, and the program name is named# the main installed package is: Bind,bind-libs ( Provide a shared library), Bind-utils (provides test parsing tools);
2. First back up the master profile, then edit the master profile and configure the cache name server
[[Email protected] ~]# cp /etc/named.conf{,.bak}[[email protected] ~]# vim /etc/named.conf# modifies the listener address in the global configuration, plus the native address (192.168.0.196) that can communicate with the extranet #加上环回地址为可让本机自我解析, and comment out which hosts are allowed to parse options { listen-on port 53 { 192.168.0.196; 127.0.0.1; }; #监听地址 listen-on-v6 port 53 { ::1; }; #ipv6监听地址 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; }; # or change localhost to any recursion yes; #是否允许递归, yes Yes # The following DNSSEC recommendations are closed, directly deleted or commented out [[email protected] ~]# service Named restart Stop named: [OK] Start named: [OK] #修改完配置文件后重启named服务 [[EMAIL PROTECTED] ~]# SS -TUNLP | grep :53udp UNCONN 0 0 192.168.0.196:53 *: * users: (("named", 7494,513) #监听开启, can communicate with the external network host
3. Configuring the Primary DNS name server
(1) Define a zone in the master configuration file
[[email protected] ~]# Vim/etc/named.rfc1912.zoneszone "magedu.com" in {type Master; File "Magedu.com.zone";}; [Email protected] ~]# named-checkconf #自动检查主配置文件是否有语法错误
(2) define the Zone resolution library file
[[email protected] ~]# cd /var/named[[email protected] named]# vim magedu.com.zone$ttl 86400$origin magedu.com. @INSOAns1 .magedu.com.admin.magedu.com (2016091201 ; serial number 1H; refresh time 5M; retry time 7D; expiration time 1 D; negative answer TTL value) innsns1.magedu.com.innsns2.magedu.com.inmx 10mx1inmx 20mx2ns1ina192.168.0.196ns2ina192.168.0.100mx1ina192.168.0.196mx2ina192.168.0.100wwwina192.168.0.196ftpincnamewww [[email protected] named]# named-checkzone "Magedu.com" /var/named/magedu.com.zone zone magedu.com/in: loaded serial 2016091201ok# checks whether the zone resolution library file for the specified range has syntax errors [[email protected] named]# chown :named magedu.com.zone #修改文件属组 [[email protected] named]# chmod 640 magedu.com.zone #修改文件权限, no one else has access to [[email protected] named]# service named restart #重启服务停止 named: [OK] Start named: [OK]
4, the positive parsing zone configuration is complete, test configuration
[[email protected] ~]# dig -t a www.magedu.com @192.168.0.196 # @ for local parsing; <<>> dig 9.8.2rc1-redhat-9.8.2-0.47.rc1.el6 <<>> -t a www.magedu.com @ 192.168.0.196;; global options: +cmd;; Got answer:;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 61816;; flags: qr aa rd ra; query: 1, answer: 1, authority: 2, ADDITIONAL: 2;; QUESTION SECTION:;www.magedu.com.INA;; ANSWER SECTION:www.magedu.com.86400INA192.168.0.196;; AUTHORITY SECTION:magedu.com.86400INNSns2.magedu.com.magedu.com.86400INNSns1.magedu.com.;; ADDITIONAL SECTION:ns1.magedu.com.86400INA192.168.0.196ns2.magedu.com.86400INA192.168.0.100;; Query time: 10 msec;; server: 192.168.0.196#53 (192.168.0.196); WHEN: Mon Sep 12 17:21:32 2016;; msg size rcvd: 116
5. Reread files
[[Email protected] ~]# service named Reload reload named: [OK] #重启服务在生产环境容易造成巨大损失, In general, overload the configuration file to
Second, reverse regional configuration
1. Define the area
[[email protected] named]# vim/etc/named.rfc1912.zones zone "0.168.192.in-addr.arpa" in {type Master; File "192.168.0.zone";};
2. Reverse zone file Configuration
[[email protected] named]# vim 192.168.0.zone $TTL 86400$origin 0.168.192. In-addr.arpa. @INSOAns1 .magedu.com. admin.magedu.com (20160912011h5m7d1d ) Innsns1.magedu.com.innsns2.magedu.com.196inptrns1.magedu.com.196inptrwww.magedu.com.196inptrmx1.magedu.com.100inptrmx2.ma gedu.com.100inptrns2.magedu.com. #注意: MX and A, as well as AAAA records are not required, with PTR records primarily [[Email protected] named]# chown :named 192.168.0.zone [[email protected] named]# chmod 640 192.168.0. zone #检查反向区域的语法 [[email protected] named]# named-checkzone "0.168.192.in-addr.arpa" 192.168.0.zone zone 0.168.192.in-addr.arpa/in: loaded serial 2016091201ok# overloaded files [ [Email protected] named]# service named reload re-loading named: [OK]
3 , Reverse parse zone configuration is complete, test
[[email protected] named]# dig -x 192.168.0.196 @192.168.0.196; << >> dig 9.8.2rc1-redhat-9.8.2-0.47.rc1.el6 <<>> -x 192.168.0.196 @192.168.0.196;; global options: +cmd;; Got answer:;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 14252;; flags: qr aa rd ra; query: 1, answer: 3, authority: 2, ADDITIONAL: 2;; QUESTION SECTION:;196.0.168.192.in-addr.arpa.INPTR;; ANSWER SECTION:196.0.168.192.in-addr.arpa. 86400 Inptrmx1.magedu.com.196.0.168.192.in-addr.arpa. 86400 inptrns1.magedu.com.196.0.168.192.in-addr.arpa . 86400 inptrwww.magedu.com.;; authority section:0.168.192. In-addr.arpa.86400innsns1.magedu.com.0.168.192.in-addr.arpa.86400innsns2.magedu.com.;; additional section:ns1.magedu.com.86400ina192.168.0.196ns2.magedu.com.86400ina192.168.0.100;; Query time: 2 msec;; server: 192.168.0.196#53 (192.168.0.196); WHEN: Mon Sep 12 18:52:45 2016;; msg size rcvd: 172
This article is from the "Linux Sailing" blog, make sure to keep this source http://jiayimeng.blog.51cto.com/10604001/1852025
Bind basic Configuration Detailed