建構一個"test.com"的域名伺服器
主域名伺服器為:ns1 IP:192.168.1.2
從域名伺服器為:ns2 IP:192.168.1.3
郵件伺服器名為:host1 IP:192.168.1.10
WEB伺服器名為:host2 IP:192.168.1.12
1.在主域名伺服器上安裝DNS(bind)
檢查是否裝有bind :rpm -q bind
安裝:rpm -ivh bind-....
安裝cacheing-namedserver :rpm -ivh cacheing-namedserver...
檢查named.conf :cat /etc/named.conf
檢查named.ca :cat /var/named/named.ca
去掉named.ca的注釋 :grep -v '^;' /var/named/named.ca | head
啟動named server :service named start
2.設定test.com的正向和反向區域
vi/etc/named.conf 添加如下内容
.............................
zone "test.com" {
type master;
file "test.com.zone";
}
zone "1.168.192.in-addr.arpa"{
type master;
file "192.168.1.rev";
}
.............................
3.編輯正向區域檔案:
vi /var/named/test.com.zone
$TTL 86400
@ IN SOA ns1.test.com. hostmaster.test.com. (
42 ;serial (d. adams)
3H ;refresh
15M ;retry
1W ;expiry
1D ) ;minimum
@ IN NS ns1.test.com.
@ IN NS ns2.test.com.
ns1 IN A 192.168.1.2
ns2 IN A 192.168.1.3
host1 IN A 192.168.1.10
host2 IN A 192.168.1.12
mail IN CNAME host1
www IN CNAME host2
@ IN MX 5 mail.test.com.
4.編輯反向區域檔案:
vi /var/named/192.168.1.rev
$TTL 86400
@ IN SOA ns1.test.com. hostmaster.test.com. (
42 ;serial (d. adams)
3H ;refresh
15M ;retry
1W ;expiry
1D ) ;minimum
@ IN NS ns1.test.com.
@ IN NS ns2.test.com.
2 IN PTR ns1.test.com.
3 IN PTR ns2.test.com.
10 IN PTR host1.test.com.
12 IN PTR host2.test.com.
檢測檔案文法是否正确:named-checkconf
5.在從域名伺服器上安裝DNS(bind)
6.設定test.com的正向和反向區域
vi/etc/named.conf 添加如下内容
.............................
zone "test.com" {
type slave;
file "slaves/test.com.zone";
masters {192.168.1.2;};
}
zone "1.168.192.in-addr.arpa"{
type slave;
file "slaves/192.168.1.rev";
masters {192.168.1.2;};
}
.............................
檢測檔案文法是否正确:named-checkconf
從域名伺服器在啟動後,在var/named/slave下應該能看到test.com.zone與192.168.1.rev二個檔案.
測試是否成功:nslookup
dig