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