知识屋:更实用的电脑技术知识网站
所在位置:首页 > 操作系统 > linux

RHEL5+bind9简单快速搭建DNS服务器

发布时间:2014-09-05 17:19:52作者:知识屋

1,环境:

系统:rhle5.4

服务器IP:192.168.191.3

测试域名:www.baidu.org.tw

2,软件包(用的安装盘自带的RPM包安装):

#rpm -ivh bind-libs-9.3.6-4.P1.el5.rpm
#rpm -ivh bind-utils-9.3.6-4.P1.el5.rpm


#rpm -ivh bind-9.3.6-4.P1.el5.rpm


3,建立bind用到的zone file目录

#mkdir /var/bind

4,安装好程序之后,生成rndc.conf和rndc.key文件

#/usr/sbin/rndc-confgen > /etc/rndc.conf

#cat /etc/rndc.conf
# Start of rndc.conf
key "rndckey" {
algorithm hmac-md5;
secret "kViQTHXyvhfaP8nZsb8kcg==";
};

options {
default-key "rndckey";
default-server 127.0.0.1;
default-port 953;
};
# End of rndc.conf


#cat /etc/rndc.conf > /etc/rndc.key

(然后把之前rndc.conf中没有注释的几行删掉,再把下面的有注释的留下,并取消注释)
#cat /etc/rndc.key

# Start of rndc.conf

# Use with the following in named.conf, adjusting the allow list as needed:
key "rndckey" {
algorithm hmac-md5;
secret "kViQTHXyvhfaP8nZsb8kcg==";
};

controls {
inet 127.0.0.1 port 953
allow { 127.0.0.1; } keys { "rndckey"; };
};
# End of named.conf



5,建立/etc/named.conf文件

#cat /etc/named.conf

options{
directory "/var/bind";
allow-query{any;};
};

zone "."{
type hint;
file "named.ca";
};

zone "baidu.org.tw"{
type master;
file "named.baidu.org.tw";
allow-update {none;};
};

zone "191.168.192.in-addr.arpa"{
type master;
file "named.192.168.191";
};

include "/etc/rndc.key";


6,建立DNS根查询地址文件

#dig > /var/bind/named.ca

#cat /var/bind/named.ca

; <<>> DiG 9.3.6-P1-RedHat-9.3.6-4.P1.el5 <<>> -t NS
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 19763
;; flags: qr rd ra; QUERY: 1, ANSWER: 13, AUTHORITY: 0, ADDITIONAL: 15

;; QUESTION SECTION:
;. IN NS

;; ANSWER SECTION:
. 59186 IN NS c.root-servers.net.
. 59186 IN NS m.root-servers.net.
. 59186 IN NS f.root-servers.net.
. 59186 IN NS d.root-servers.net.
. 59186 IN NS a.root-servers.net.
. 59186 IN NS e.root-servers.net.
. 59186 IN NS g.root-servers.net.
. 59186 IN NS l.root-servers.net.
. 59186 IN NS j.root-servers.net.
. 59186 IN NS b.root-servers.net.
. 59186 IN NS k.root-servers.net.
. 59186 IN NS i.root-servers.net.
. 59186 IN NS h.root-servers.net.

;; ADDITIONAL SECTION:
a.root-servers.net. 145586 IN A 198.41.0.4
b.root-servers.net. 145607 IN A 192.228.79.201
c.root-servers.net. 255305 IN A 192.33.4.12
d.root-servers.net. 299927 IN A 128.8.10.90
e.root-servers.net. 155401 IN A 192.203.230.10
f.root-servers.net. 299837 IN A 192.5.5.241
g.root-servers.net. 247679 IN A 192.112.36.4
h.root-servers.net. 259378 IN A 128.63.2.53
i.root-servers.net. 299747 IN A 192.36.148.17
i.root-servers.net. 479706 IN AAAA 2001:7fe::53
j.root-servers.net. 259611 IN A 192.58.128.30
j.root-servers.net. 145586 IN AAAA 2001:503:c27::2:30
k.root-servers.net. 153654 IN A 193.0.14.129
k.root-servers.net. 153654 IN AAAA 2001:7fd::1
l.root-servers.net. 151716 IN A 199.7.83.42

;; Query time: 5 msec
;; SERVER: 211.162.78.1#53(211.162.78.1)
;; WHEN: Tue Dec 14 12:42:31 2010
;; MSG SIZE rcvd: 504


7,在/var/bind目录下创建以下文件

#vi /var/bind/named.baidu.org.tw

$TTL 600
@ IN SOA baidu.org.tw. root.baidu.org.tw. (
2003061800;serial
28800 ;refresh
14400 ;retry
3600000 ;expire
86400 ) ;minimum
@ IN NS baidu.org.tw. //(这里要注意,这个最后面有一个点)
www IN A 192.168.191.3
ftp IN A 192.168.191.3
mail IN A 192.168.191.3
baidu.org.tw IN A 192.168.191.3
@ IN MX 5 mail


#vi /var/bind/named.192.168.191

$TTL 600
@ IN SOA baidu.org.tw. root.baidu.org.tw. (
2003061800;serial
28800 ;refresh
14400 ;retry
3600000 ;expire
86400 ) ;minimum
@ IN NS baidu.org.tw.
3 IN PTRwww.baidu.org.tw.
3 IN PTRftp.baidu.org.tw.
3 IN PTR mail.baidu.org.tw.


8,启动named服务

#service named start
 
(免责声明:文章内容如涉及作品内容、版权和其它问题,请及时与我们联系,我们将在第一时间删除内容,文章内容仅供参考)
收藏
  • 人气文章
  • 最新文章
  • 下载排行榜
  • 热门排行榜