首先要成功安装Centos操作系统,最新版本是Centos 6.4版本,最小化安装。
[root@localhost named]# ifconfig -a
0 1 |
eth1 Link encap:Ethernet HWaddr 00:15:5D:01:69:2C inet addr:192.168.1.251 Bcast:192.168.1.255 Mask:255.255.255.0 |
设置本机的dns。SourceByrd's Weblog-https://note.t4x.org/system/centos-bind-config/
0 1 2 |
[root@localhost named]# cat /etc/resolv.conf nameserver 8.8.8.8 #DNS服务器 nameserver 8.8.4.4 #备用DNS服务器 |
yum安装:SourceByrd's Weblog-https://note.t4x.org/system/centos-bind-config/
0 1 2 3 4 5 6 7 8 9 10 11 |
[root@localhost ~]# yum install bind Downloading Packages: (1/4): bind-9.8.2-0.17.rc1.el6_4.5.i686.rpm | 4.0 MB 00:03 (2/4): bind-chroot-9.8.2-0.17.rc1.el6_4.5.i686.rpm | 71 kB 00:00 (3/4): bind-libs-9.8.2-0.17.rc1.el6_4.5.i686.rpm | 890 kB 00:04 (4/4): bind-utils-9.8.2-0.17.rc1.el6_4.5.i686.rpm | 181 kB 00:00 [root@localhost ~]# service named restart #启动bind服务 Generating /etc/rndc.key: 新开窗口输入: [root@localhost ~]# rndc-confgen -r /dev/urandom -a #创建rndk.key wrote key file "/etc/rndc.key" [root@localhost ~]# service named restart #重新启动bind服务 |
######在安装bind-chroot的情况下,配置文件保存在/var/named/chroot/etc/目录下,其实是做了软链接过去。SourceByrd's Weblog-https://note.t4x.org/system/centos-bind-config/
配置信息:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
[root@localhost ~]# cd /var/named/chroot/etc/ [root@localhost etc]# cat named.conf named.conf的配置文件如下: // // named.conf // // Provided by Red Hat bind package to configure the ISC BIND named(8) DNS // server as a caching only nameserver (as a localhost DNS resolver only). // // See /usr/share/doc/bind*/sample/ for example named configuration files. // options { listen-on port 53 { any; }; listen-on-v6 port 53 { ::1; }; 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 { any; }; #可查询主机 allow-query-cache { any; }; #缓存 recursion yes; #是否允许递归查询 dnssec-enable yes; dnssec-validation yes; dnssec-lookaside auto; /* Path to ISC DLV key */ bindkeys-file "/etc/named.iscdlv.key"; managed-keys-directory "/var/named/dynamic"; }; logging { channel default_debug { file "data/named.run"; severity dynamic; }; channel gsquery { file "data/query.log" versions 3 size 20m; severity info; print-time yes; print-category yes; print-severity yes; }; category queries { gsquery; }; }; zone "." IN { type hint; file "named.ca"; }; include "/etc/named.rfc1912.zones"; include "/etc/named.root.key"; |
到此基本上DNS服务器可以跑起来了。哦,不要忘记去把/etc/resolv.conf修改为自己这台服务器的IP哦!~下面开始创建域以及域文件。SourceByrd's Weblog-https://note.t4x.org/system/centos-bind-config/
可以直接修改named.conf,也可以在named.rfc1912.zones下面创建,我喜欢在named.rfc1912.zones下面创建。SourceByrd's Weblog-https://note.t4x.org/system/centos-bind-config/
0 1 2 3 4 5 6 7 8 9 10 |
[root@localhost etc]# vi /var/named/chroot/etc/named.rfc1912.zones OR [root@localhost etc]# vi /etc/named.rfc1912.zones [/shell] 均可修改,我们创建一个a.com的域 [shell] zone "a.com" IN { type master; file "a.com.zone"; allow-update { none; }; }; |
然后在SourceByrd's Weblog-https://note.t4x.org/system/centos-bind-config/
0 1 2 |
[root@localhost etc]# cd /var/named/chroot/var/named/ OR [root@localhost etc]# cd /var/named/ |
创建一个文件名为a.com.zone的正向区域文件。SourceByrd's Weblog-https://note.t4x.org/system/centos-bind-config/
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
[root@localhost named]# cat /var/named/a.com.zone $TTL 1D $TTL 600 @ IN SOA ns.a.com. admin.a.com. ( 0 ; serial 1D ; refresh 1H ; retry 1W ; expire 3H ) ; minimum IN NS ns IN A 192.168.1.250 IN AAAA ::1 www IN A 192.168.1.191 ns IN A 192.168.1.250 qwer IN A 4.3.2.1 |
注意第二行哦!!@ IN SOA a.com admin.a.com.是非常重要的哦!~
然后我们再来创建一个反向区域文件。
首先在named.rfc1912.zones创建一个反向区域SourceByrd's Weblog-https://note.t4x.org/system/centos-bind-config/
0 1 2 3 4 5 6 7 8 9 |
zone "a.com" IN { #这个是正向 type master; file "a.com.zone"; allow-update { none; }; }; zone "1.168.192.in-addr.arpa" IN { #这个是反向 type master; file "192.168.1.zone"; allow-update { none; }; }; |
然后再来创建一个名字为192.168.1.zone的文件。SourceByrd's Weblog-https://note.t4x.org/system/centos-bind-config/
0 1 2 3 4 5 6 7 8 9 10 11 12 |
[root@localhost named]# cat /var/named/192.168.1.zone $TTL 1D @ IN SOA a.com. admin.a.com. ( 0 ; serial 1D ; refresh 1H ; retry 1W ; expire 3H ) ; minimum NS @ A 127.0.0.1 AAAA ::1 250 IN PTR ns.a.com. 1.2.3.4 IN PTR qwer.a.com. |
基本创建完成,经过测试正向、反向都正确。参考了很多网络文章,不一一列举,本地配置成功。SourceByrd's Weblog-https://note.t4x.org/system/centos-bind-config/
哦,对了。不要忘记开启防火墙的TCP、UDP 53端口哦!!
[root@localhost ~]# vi /etc/sysconfig/iptables
添加如下内容:SourceByrd's Weblog-https://note.t4x.org/system/centos-bind-config/
0 1 |
-A INPUT -m state --state NEW -m tcp -p tcp --dport 53 -j ACCEPT -A INPUT -m state --state NEW -m udp -p udp --dport 53 -j ACCEPT |
完整版本:https://note.t4x.org/service/configuration-intelligence-dns-bases/
参考:Non-existent domain解决方法
参考:(Centos 辅助DNS配置)
参考文章如下:
1:http://dns-learning.twnic.net.tw/dns/main.html
2:http://www.linuxidc.com/ 这个网站下面相关bind的文章全部看过
3:http://blog.sina.com.cn/s/blog_bd846d6e0101dw5q.html
4:http://yuanbin.blog.51cto.com/363003/108578/
5:http://docs.oracle.com/cd/E24847_01/html/E22302/dnsref-13.html
6:http://www.chinaz.com/web/2011/0513/179982.shtml
申明:本文由BYRD原创(基于Centos6.4 X64),未经许可禁止转载!
Trackbacks