公司新购两台Sun ultra 20 工作站和两台DELL server 作为公司对外提供的DNS server, 这是我第一次自己动手安装 solaris 10 x86 系统,并在上面配置DNS server.其实我是一头雾水,好在公司有位强人Davy Shen,他在技术方面建树颇多,玩转DNS自然不在话下,我在他的指导下也装成一台。现把安装流程写下来与大家分享!
1、在安装solaris 10 时选择DNS,这样就省去专门安装bind 9 。也可以在安装好的系统下查看是否存在以下文件,如果有,表明bind 9 已经安装。
# ls /usr/sbin
named
nsupdate
rndc
dnssec-keygen
nslookup
dig
dnssec-makekeyset
dnssec-signkey
dnssec-signzone
named-checkconf
named-checkzone
rndc-confgen
host
2、接下来进行具体设置
一个配置完整的DNS server 包括以下配置文件:
# ls -l /var/named
total 28
-rw-r--r-- 1 root root 200 Aug 3 14:20 16.168.192.in-addr.arpa.dns
-rw-r--r-- 1 root root 265 Aug 3 15:26 21vianet.biz
-rw-r--r-- 1 root root 264 Aug 3 14:20 21vianet.com.cn
-rw-r--r-- 1 root root 199 Aug 3 14:20 35.152.211.in-addr.arpa.dns
drwxr-xr-x 2 root root 512 Aug 3 15:02 data
-rw-r--r-- 1 root root 198 Aug 3 14:20 localdomain.zone
-rw-r--r-- 1 root root 195 Aug 3 14:20 localhost.zone
-rw-r--r-- 1 root root 415 Aug 3 14:20 named.broadcast
-rw-r--r-- 1 root root 2518 Aug 3 14:20 named.ca
-rw-r--r-- 1 root root 432 Aug 3 14:20 named.ip6.local
-rw-r--r-- 1 root root 433 Aug 3 14:20 named.local
-rw-r--r-- 1 root root 416 Aug 3 14:20 named.zero
和/etc 目录下的。
/etc/named.conf
/etc/rndc.conf
以上内容就是构成一个DSN server的全部文件。
3、接下来分析每个文件的内容。
1> named.conf
# less /etc/named.conf
//
// named.conf for Red Hat caching-nameserver
//
options {
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
/*
* 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;
};
//
// a caching only nameserver config
//
controls {
inet 127.0.0.1 allow { localhost; } keys { rndc-key; };
};
zone "." IN {
type hint;
file "named.ca";
};
zone "localdomain" IN {
type master;
file "localdomain.zone";
allow-update { none; };
};
zone "localhost" IN {
type master;
file "localhost.zone";
allow-update { none; };
};
zone "0.0.127.in-addr.arpa" IN {
type master;
file "named.local";
allow-update { none; };
};
zone "255.in-addr.arpa" IN {
type master;
file "named.broadcast";
allow-update { none; };
};
zone "0.in-addr.arpa" IN {
type master;
file "named.zero";
allow-update { none; };
};
key "rndc-key" {
algorithm hmac-md5;
secret "7kI4jWYxAqYfyCyDfJ17hA==";
};
zone "21vianet.com.cn" IN {
type master;
file "21vianet.com.cn";
};
zone "16.168.192.in-addr.arpa" IN {
type master;
file "16.168.192.in-addr.arpa.dns";
};
zone "21vianet.biz" IN {
type master;
file "21vianet.biz";
};
zone "35.152.211.in-addr.arpa" IN {
type master;
file "35.152.211.in-addr.arpa.dns";
};
2>rndc.conf
# less /etc/rndc.conf
options {
default-server localhost;
default-key "rndc-key";
};
server localhost {
key "rndc-key";
};
key "rndc-key" {
algorithm hmac-md5;
secret "7kI4jWYxAqYfyCyDfJ17hA==";
};
注:以上这两个文件中的key 部分用以下方法生成,并替换到文件。
# rndc-confgen -a
# less /etc/rndc.key
key "rndc-key" {
algorithm hmac-md5;
secret "x4w3LrgqIdLCUB0JQ1Xctg==";
};
3> # less 16.168.192.in-addr.arpa.dns
$TTL 1d
@ 1d IN SOA ns.16.168.192.in-addr.arpa. root.16.168.192.in-addr.arpa. (
1
1h
10m
1d
1h )
@ 1d IN NS ns.16.168.192.in-addr.arpa.
59 86400 IN PTR test1.21vianet.com.cn.
4> # less 21vianet.biz
$TTL 1d
@ 1d IN SOA ns.21vianet.biz. root.21vianet.biz. (
1
1h
10m
1d
1h )
@ 1d IN NS ns1.21vianet.com.cn.
@ 1d IN NS ns2.21vianet.com.cn.
service 86400 IN A 211.152.35.61
bugzilla 86400 IN A 211.152.35.61
cacti 86400 IN A 211.152.48.180
5> # less 21vianet.com.cn
$TTL 1d
@ 1d IN SOA ns.21vianet.com.cn. root.21vianet.com.cn. (
1
1h
10m
1d
1h )
@ 1d IN NS ns.21vianet.com.cn.
test1 86400 IN A 192.168.16.59
www 86400 IN A 211.152.48.175
www1 86400 IN A 211.152.48.175
service 86400 IN A 211.152.35.61
6> # less 35.152.211.in-addr.arpa.dns
$TTL 1d
@ 1d IN SOA ns.35.152.211.in-addr.arpa. root.35.152.211.in-addr.arpa. (
1
1h
10m
1d
1h )
@ 1d IN NS ns.35.152.211.in-addr.arpa.
61 86400 IN PTR service.21vianet.biz.
7> # less localdomain.zone
$TTL 86400
@ IN SOA localhost root (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
IN NS localhost
localhost IN A 127.0.0.1
8># less localhost.zone
$TTL 86400
@ IN SOA @ root (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
IN NS @
IN A 127.0.0.1
IN AAAA ::1
#
9> less named.broadcast
$TTL 86400
@ IN SOA localhost root (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
IN NS localhost
#
10> # less named.ca
; This file holds the information on root name servers needed to
; initialize cache of Internet domain name servers
; (e.g. reference this file in the "cache . <file>"
; configuration file of BIND domain name servers).
;
; This file is made available by InterNIC
; under anonymous FTP as
; file /domain/named.cache
; on server FTP.INTERNIC.NET
; -OR- RS.INTERNIC.NET
;
; last update: Jan 29, 2004
; related version of root zone: 2004012900
;
;
; formerly NS.INTERNIC.NET
;
. 3600000 IN NS A.ROOT-SERVERS.NET.
A.ROOT-SERVERS.NET. 3600000 A 198.41.0.4
;
; formerly NS1.ISI.EDU
;
. 3600000 NS B.ROOT-SERVERS.NET.
B.ROOT-SERVERS.NET. 3600000 A 192.228.79.201
;
; formerly C.PSI.NET
#
11> # less named.ip6.local
$TTL 86400
@ IN SOA localhost. root.localhost. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS localhost.
1 IN PTR localhost.
12># less named.local
$TTL 86400
@ IN SOA localhost. root.localhost. (
1997022701 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expir
86400 ) ; Minimum
IN NS localhost.
1 IN PTR localhost.
#
13> # less named.zero
$TTL 86400
@ IN SOA localhost root (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
IN NS localhost
14> 并且不要忘记自己手动创建目录 #mkdir /var/named/data
好了,文件内容已经贴完,其中无用文件请自己删除。
15> # vi /etc/resolv.conf 修改这个文件内容如下。
domain 21vianet.com.cn
nameserver localhost
4.完成以上工作,我们可以启动服务进行测试了。
启动服务:正常情况下,
# svcs | grep dns
online 17:04:14 svc:/network/dns/client:default
online 17:04:15 svc:/network/dns/server:default
DNS server 已经启动。如果未启动,可用如下命令启动之
#svcadm enable network/dns/server
#svcadm enable network/dns/client
5.测试
#vi /var/named/21vianet.biz 添加一条A记录如下:
aaa 86400 IN A 211.152.48.2
#rndc reload
之后视dns 刷新情况而定,就可以通过PC机。以公网上的DNS 解析到新增加的二级域名。
ping aaa.21vianet.biz
Pinging bbb.21vianet.biz [211.152.48.2] with 32 bytes of data:
Reply from 211.152.48.2: bytes=32 time=4ms TTL=254
Reply from 211.152.48.2: bytes=32 time=3ms TTL=254
Reply from 211.152.48.2: bytes=32 time=3ms TTL=254
Reply from 211.152.48.2: bytes=32 time=3ms TTL=254
Ping statistics for 211.152.48.2:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 3ms, Maximum = 4ms, Average = 3ms