DNS Server配置示例:
注: 以上示例文件仅作演示用,于实际内容有所出入,会与实际测试有出入 DNS基础知识请参考本人制作的PowerPoint幻灯片文件,URL同上, 文件名为dns.ppt.
1. 首先应确认你的上级域名服务器已正确指向你的DNS Server, 如我设置的子域为net.dlut.edu.cn,则应在dlut.edu.cn的域名服务器上有到作net.dlut.edu.cn子域名服务器的LINUX机器的的NS记录,以下是在dlut.edu.cn域名服务器相应文件内容:
(1)BIND 4.9.x的配置文件
--------------------------/etc/named.boot----------------------
directory /etc/namedb
;
primary dlut.edu.cn db.dlut
primary 66.118.202.in-addr.arpa db.202.118.66
;
;
primary 0.0.127.in-addr.arpa localhost.rev
secondary net.dlut.edu.cn 202.118.65.1 db.net.dlut
secondary 65.118.202.in-addr.arpa 202.118.65.1 db.202.118.65
;
; load the cache data last
cache . named.root
(2)Bind-8.x 配置文件 /etc/named.conf
// generated by named-bootconf.pl
options {
directory "/etc/namedb";
/*
* If there is a firewall between you and nameservers you want
* to talk to, you might need to uncomment the query-source
* directive below. Previous versions of BIND always asked
* questions using port 53, but BIND 8.1 uses an unprivileged
* port by default.
*/
// query-source address * port 53;
};
// type domain source host/file backup file
zone "." {
type hint;
file "named.root";
};
zone "0.0.127.IN-ADDR.ARPA" {
type master;
file "localhost.rev";
};
zone "66.118.202.IN-ADDR.ARPA" {
type master;
file "db.202.118.66";
};
zone "dlut.edu.cn" {
type master;
file "db.dlut";
};
zone "net.dlut.edu.cn" {
type slave;
file "db.net.dlut";
masters {
202.118.65.1;
}
};
zone "65.118.202.IN-ADDR.ARPA" {
type slave;
file "db.202.118.65";
masters {
202.118.65.1;
}
};
-------------------------/etc/namedb/db.dlut-------------------
@ IN SOA cedrus.dlut.edu.cn. hbwork.dlut.edu.cn.
99060205 10800 4800 604800 432000 )
IN NS cedrus.dlut.edu.cn.
IN NS gingko.dlut.edu.cn.
IN NS olive.dlut.edu.cn.
IN MX 1 gingko.dlut.edu.cn.
localhost IN A 127.0.0.1
cedrus IN MX 1 gingko.dlut.edu.cn.
IN A 202.118.66.6
linden IN A 202.118.66.88
IN MX 1 linden.dlut.edu.cn.
ftp IN CNAME linden.dlut.edu.cn.
banyan IN CNAME linden.dlut.edu.cn.
gingko IN MX 10 gingko.dlut.edu.cn.
IN A 202.118.66.8
mail IN CNAME gingko.dlut.edu.cn.
rose IN MX 1 rose.dlut.edu.cn.
IN A 202.118.66.5
IN A 202.118.69.6
bbs IN CNAME rose.dlut.edu.cn.
bbs1 IN A 202.118.69.6
lib 604800 IN NS ns.lib.dlut.edu.cn.
ns.lib 604800 IN A 202.118.68.241
net 26000 IN NS dns.net.dlut.edu.cn.
IN NS cedrus.dlut.edu.cn.
dns.net IN A 202.118.65.1
IN A 202.118.66.13
olive IN A 202.118.70.1
IN A 202.118.71.1
IN A 202.118.66.16
IN A 202.118.68.1
IN A 202.118.69.1
IN MX 1 olive.dlut.edu.cn.
peony IN A 202.118.66.18
www IN CNAME peony.dlut.edu.cn.
mirror IN CNAME peony.dlut.edu.cn.
可通过nslookup 确认是否已正确设定,如下:
> net.dlut.edu.cn
Server: cedrus.dlut.edu.cn
Address: 202.118.66.6
Non-authoritative answer:
net.dlut.edu.cn nameserver = dns.net.dlut.edu.cn
net.dlut.edu.cn nameserver = cedrus.dlut.edu.cn
Authoritative answers can be found from:
dns.net.dlut.edu.cn internet address = 202.118.65.1
dns.net.dlut.edu.cn internet address = 202.118.66.13
cedrus.dlut.edu.cn internet address = 202.118.66.6
** 如果只想作本地的DNS Server或者你与Internet没有连接,可以忽略此步。
2。编辑net.dlut.edu.cn DNS服务器的相应文件,
(1)Bind 4.9.x /etc/named.boot内容如下,其中以引号开始的内容为注释:
directory /etc/namedb ;指定named初始化文件目录,
;最好为一单独文件系统,如
;/var/namedb /usr/local/namedb
;cache 指向顶级域名服务器列表
cache . root.cache
;primary 表明是子域net.dlut.edu.cn和反向域65.118.202.IN-ADDR.ARPA
;的主域名服务器,其初始化文件分别为/etc/namedb/db.net.dlut和
;/etc/namedb/db.202.118.65
primary net.dlut.edu.cn db.net.dlut
primary 65.118.202.IN-ADDR.ARPA db.202.118.65
;本地回环域0.0.127.IN-ADDR.ARPA的主域名服务器
primary 0.0.127.IN-ADDR.ARPA localhost.rev
;子域dlut.edu.cn的备份域名服务器,从域名服务器202.118.66.6(primary
; server for domain dlut.edu.cn)和202.118.66.8(secondary server for
; domain dlut.edu.cn)申请相关数据,备份文件名为dlut.bak
; 如不做备份域名服务器则无须下列行
secondary dlut.edu.cn 202.118.66.6 202.118.66.8 dlut.bak
secondary 66.118.202.IN-ADDR.ARPA 202.118.66.6 202.118.66.8 dlut.rev.bak
(2) bind-8.x,可用其提供的namedboot-conf.pl将上面的文件内容转换为bind8所需的named.conf, 其中namedboot-conf.pl在redhat上可以在/usr/doc/bind*/下找到,也可从bind8的代码包中拿到,其用法如下:
$namedboot-conf.pl named.boot > named.conf
将生成的named.conf文件复制到/etc目录下即可。
3.创建文件/etc/namedb/db.net.dlut,可从bind软件包携带的示例文件进行修改而成,文件内容如下:
-----------------------------------------------------------------------
;
; Data file of hostnames in this zone.
;
@ IN SOA dns.net.dlut.edu.cn. hbwork.dlut.edu.cn. (
960072601 ; Serial
300 ; Refresh - 5 minutes
60 ; Retry - 1 minute
38400 ; Expire - 2 weeks
43200 ) ; Minimum - 12 hours
IN NS ns.net.dlut.edu.cn.
IN NS cedrus.dlut.edu.cn.
; Define localhost
;
localhost IN A 127.0.0.1
ns IN A 202.118.65.1