Linux下配置DNS服务器完全文档

下载http://down.zhanghong.org.cn/bind-9.8.5-P2.tar.gz
我下载的文件放在/root目录下 
进入目录解压缩 
[root@tiejiang root]#tar xfz bind-9.3.1rc1.tar.gz 
进如刚解压出来的目录 
[root@tiejiang root]# cd bind-9.3.1rc1 
编译配置 
[root@tiejiang bind-9.3.1rc1]#./configure –prefix=/usr/local/named –enable-threads #–enable-threads开启多线程处理能力 
[root@tiejiang bind-9.3.1rc1]#make 
[root@tiejiang bind-9.3.1rc1]#make install 
进入/usr/local/named 建立etc目录 
[root@tiejiang bind-9.3.1rc1]#cd /usr/local/named 
[root@tiejiang named]# mkdir etc 
生成rndc控制命令的key文件 
[root@tiejiang named]# sbin/rndc-confgen > etc/rndc.conf 
从rndc.conf文件中提取named.conf用的key 
root@linux named]# cd etc 
[root@tiejiang etc]# tail -10 rndc.conf | head -9 | sed s/#\ //g > named.conf 
自动在/usr/local/named/etc 生成named,conf文件 
建立区文件目录 
[root@tiejiang etc]# mkdir /var/named 
进入/var/named 
[root@tiejiang etc]# cd /var/named 
建立localhost.zone文件 
[root@tiejiang named]#vi localhost.zone 
$TTL    86400 
$ORIGIN localhost. 
@                       1D IN SOA       @ root ( 
                                       42              ; serial (d. adams) 
                                       3H              ; refresh 
                                       15M             ; retry 
                                       1W              ; expiry 
                                       1D )            ; minimum 
                       1D IN NS        @ 
                       1D IN A         127.0.0.1 
建立named.local文件 
[root@tiejiang named]#vi named.local 
$TTL    86400 
@       IN      SOA     localhost. root.localhost.  ( 
                                     1997022700 ; Serial 
                                     28800      ; Refresh 
                                     14400      ; Retry 
                                     3600000    ; Expire 
                                     86400 )    ; Minimum 
             IN      NS      localhost. 
1       IN      PTR     localhost. 

dig命令直接生成named.root文件 
[root@tiejiang named]#dig > named.root 
建立test.com域名正向解析文件 
[root@tiejiang named]#vi test.zone 
$ttl    1D 
@               IN SOA  test.com.  root.test.com. ( 
                                      1053891162 
                                       3H 
                                       15M 
                                       1W 
                                       1D ) 
                       IN NS          test.com. 
                       IN MX    5    test.com. 
www                IN A          220.202.19.82 
建立test.com域名反向解析文件 
[root@tiejiang named]#vi test.local 
$TTL 86400 
@ IN SOA test.com. root.test.com.( 
20031001; 
7200; 
3600; 
43200; 
86400); 
@ IN NS test.com. 
82 IN PTR DNS.test.com. 
配置named.conf加如以下代码 
[root@tiejiang etc]# vi named.conf 
options { 
directory “/var/named”; #named区文件目录 
pid-file “named.pid”; #进程id文件名 
}; 
controls { 
       inet 127.0.0.1 allow { localhost; } keys { rndckey; }; 
}; 
zone “.” IN { 
       type hint; 
       file “named.root”; 
}; 
zone “localhost” IN { 
       type master; 
       file “localhost.zone”; 
       allow-update { none; }; 
}; 
zone “0.0.127.in-addr.arpa” IN { 
       type master; 
       file “named.local”; 
       allow-update { none; }; 
}; 
zone “test.com” IN { 
       type master; 
       file “test.zone”; 
       allow-update { none; }; 
}; 

zone “19.202.220.in-addr.arpa” IN { 
       type master; 
       file “test.local”; 
       allow-update { none; }; 
}; 

现在配置完了可以启动BIND了 
/usr/local/named/sbin/named -c /usr/local/named/etc/named.conf & 
只要显示 
runing表示运行成功 
测试DNS 
[root@tiejiang etc]# host 220202.19.82 
89.19.202.220.in-addr.arpa domain name pointer DNS.test.com. 
如上显示表示DNS反向解析正常 
[root@tiejiang etc]# ping www.test.com 
PING www.test.com (220.202.19.82) 56(84) bytes of data. 
如上显示表示正向解析正常 
DNS配置完成。

from: http://www.chinaunix.net/jh/16/500422.html 

 

rndc 是配合bind的好帮手.使用帮助如下:

[root@rh9 named]# rndc -V
Usage: rndc [-c config] [-s server] [-p port]
        [-k key-file ] [-y key] [-V] command

command is one of the following:

  reload        Reload configuration file and zones.
  reload zone [class [view]]
                Reload a single zone.
  refresh zone [class [view]]
                Schedule immediate maintenance for a zone.
  reconfig      Reload configuration file and new zones only.
  stats         Write server statistics to the statistics file.
  querylog      Toggle query logging.
  dumpdb        Dump cache(s) to the dump file (named_dump.db).
  stop          Save pending updates to master files and stop the server.
  halt          Stop the server without saving pending updates.
  trace         Increment debugging level by one.
  trace level   Change the debugging level.
  notrace       Set debugging level to 0.
  flush         Flushes all of the server’s caches.
  flush [view]  Flushes the server’s cache for a view.
  status        Display status of the server.
  *restart      Restart the server.

* == not yet implemented
Version: 9.2.1
[root@rh9 named]# rndc stats
[root@rh9 named]# rndc status
number of zones: 5
debug level: 0
xfers running: 0
xfers deferred: 0
soa queries in progress: 0
query logging is OFF
server is up and running

 

1. 本站所有资源来源于用户上传和网络,因此不包含技术服务请大家谅解!如有侵权请邮件联系客服!10210454@qq.com
2. 本站不保证所提供所有下载的资源的准确性、安全性和完整性,资源仅供下载学习之用!如有链接无法下载、失效或广告,请联系客服处理,有奖励!
3. 您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容资源!如用于商业或者非法用途,与本站无关,一切后果请用户自负!
4. 如果您也有好的资源或教程,您可以投稿发布,成功分享后有RB奖励和额外RMB收入!

磊宇堂正在使用的服务器 维护管理由磊宇云服务器提供支持

磊宇堂 » Linux下配置DNS服务器完全文档

提供最优质的资源集合

立即查看 了解详情