域名服务器搭建主要涉及的文件主要有:
(1)/etc/named.conf,此文件一般是个软链接;
(2)/etc/hosts(非必须)
(3)/etc/host.conf (一般不需要修改,有 order hosts,bind即可)
(4)/var/named/*
此文档只是一个NFS的初级搭建工程,就是能够运行的级别,没有什么高级设置,目的是快速入门。
当然首先要查查系统是否已经安装了DNS的软件工具(BIND),如没有那只有拿来光盘重新安装或者到官方网站下载源码包编译安装,此处是采用系统自带的BIND;
接下来就是进行相关文件的配置了;
相关的配置文件均在/var/named目录下,主要配置为/var/named/chroot/etc/named.conf,域解析文件放在/var/named/chroot/var/named目录下;
此次的目的就是搭建一个简单的DNS服务器,并且设置DNS服务器的主机名;
具体步骤如下:
1、配置named.conf文件
/var/named/chroot/etc/named.conf主要添加的配置内容如下:
zone "osservers.com" IN {
type master;
file "osserver.com.zone";
allow-update { none; };
};
zone "67.20.172.in-addr.arpa" IN {
type master;
file "zone.osserver.com";
allow-update { none; };
};
2、配置相应的解析文件
两个解析文件如下:(/var/named/chroot/var/named)
/var/named/chroot/var/named /osserver.com.zone文件:
$TTL 86400
@ IN SOA dns.osservers.com. root.osservers.com. (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
IN NS dns.osservers.com.
IN NS 172.20.67.203
dns.osservers.com. IN A 172.20.67.203
www IN A 172.20.67.203
/var/named/chroot/var/named /zone.osserver.com文件:
$TTL 86400
@ IN SOA dns.osservers.com. root.osservers.com. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS dns.osservers.com.
203 IN PTR www.osservers.com.
3、重新启动服务
/etc/init.d/named restart
4、测试部分
(本文来源于图老师网站,更多请访问http://m.tulaoshi.com/linux/)(1)设置域名文件/etc/resolve.conf,将nameserver 172.20.67.203加入;
(2)采用nslookup/host/测试:
[root@samba named]# nslookup
172.20.67.203
Server: 172.20.67.203
Address: 172.20.67.203#53
203.67.20.172.in-addr.arpa name = www.osservers.com.
www.osservers.com
Server: 172.20.67.203
Address: 172.20.67.203#53
Name: www.osservers.com
Address: 172.20.67.203
[root@samba named]# host www.osservers.com
www.osservers.com has address 172.20.67.203
[root@samba named]# host 172.20.67.203
203.67.20.172.in-addr.arpa domain name pointer www.osservers.com.
[root@samba named]#
[root@samba named]# dig www.osservers.com
; << DiG 9.3.2 << www.osservers.com
;; global options: printcmd
;; Got answer:
;; -HEADER<<- opcode: QUERY, status: NOERROR, id: 3294
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 1
;; QUESTION SECTION:
;www.osservers.com. IN A
;; ANSWER SECTION:
www.osservers.com. 86400 IN A 172.20.67.203
;; AUTHORITY SECTION:
osservers.com. 86400 IN NS 172.20.67.203.
osservers.com. 86400 IN NS dns.osservers.com.
(本文来源于图老师网站,更多请访问http://m.tulaoshi.com/linux/);; ADDITIONAL SECTION:
dns.osservers.com. 86400 IN A 172.20.67.203
;; Query time: 1 msec
;; SERVER: 172.20.67.203#53(172.20.67.203)
;; WHEN: Wed Apr 25 13:39:31 2007
;; MSG SIZE rcvd: 112
OK,搞定!
简单的DNS服务器完成了。