//主题:主DND域名服务器配置
//内容:通过配置named文件族使服务器能够解析域名itbenet.com
/////////////////////////////
// 实验内容操作步骤 ////
/////////////////////////////
// 查询bind安装情况
[root@localhost root]# rpm -q bind
bind-9.2.1-16
// 查询named守护进程的系统启动等级
[root@localhost root]# chkconfig --list named
named 0:off 1:off 2:off 3:off 4:off 5:off 6:off
// 开启named守护进程
[root@localhost root]# chkconfig named on
// 验证操作
[root@localhost root]# chkconfig --list named
named 0:off 1:off 2:on 3:on 4:on 5:on 6:off
// 备份named.conf
[root@localhost root]# cp -av /etc/named.conf /etc/named.conf-
`/etc/named.conf' -> `/etc/named.conf-'
// 使用vi编辑named.conf
[root@localhost root]# vi /etc/named.conf
1 // generated by named-bootconf.pl
2
3 options {
4 directory "/var/named";
5 /*
6 * If there is a firewall between you and nameservers you want
7 * to talk to, you might need to uncomment the query-source
8 * directive below. Previous versions of BIND always asked
9 * questions using port 53, but BIND 8.1 uses an unprivileged
10 * port by default.
11 */
12 // query-source address * port 53;
13 };
14
15 //
16 // a caching only nameserver config
17 //
18 controls {
19 inet 127.0.0.1 allow { localhost; } keys { rndckey; };
20 };
21 zone "." IN {
22 type hint;
23 file "named.ca";
24 };
25
26 zone "localhost" IN {
27 type master;
28 file "localhost.zone";
29 allow-update { none; };
30 };
31
32 zone "0.0.127.in-addr.arpa" IN {
33 type master;
34 file "named.local";
35 allow-update { none; };
36 };
37
//新增正向区域itbenet.com
38 zone "itbenet.com" IN {
39 type master;
40 file "itbenet.com.zone";
41 allow-update { none; };
42 };
43
//新增反向区域itbenet.com
44 zone "1.168.192.in-addr.arpa" IN {
45 type master;
46 file "named.1.168.192";
47 allow-update { none; };
"/etc/named.conf" 49L, 957C written
// 查看修改后的named.conf与原始文件的差异
[root@localhost root]# diff /etc/named.conf /etc/named.conf-
38,48d37
< zone "itbenet.com" IN {
< type master;
< file "itbenet.com.zone";
< allow-update { none; };
< };
<
< zone "1.168.192.in-addr.arpa" IN {
< type master;
< file "named.1.168.192";
< allow-update { none; };
< };
// 名称配置文件语法测试
[root@localhost root]# named-checkconf
// 目录跳转至/var/named/
[root@localhost root]# cd /var/named/
// 浏览当前目录
[root@localhost named]# ll
total 12
-rw-r--r-- 1 named named 195 Jan 25 2003 localhost.zone
-rw-r--r-- 1 named named 2499 Jan 25 2003 named.ca
-rw-r--r-- 1 named named 433 Jan 25 2003 named.local
// 创建itbenet.com.zone文件
[root@localhost named]# cp -av localhost.zone itbenet.com.zone
`localhost.zone' -> `itbenet.com.zone'
// 创建named.1.168.192文件
[root@localhost named]# cp -av named.local named.1.168.192
`named.local' -> `named.1.168.192'
// 修改文件访问权限
[root@localhost named]# chown named:named *
// 查看目录
[root@localhost named]# ll
total 20
-rw-r--r-- 1 named named 195 Jan 25 2003 itbenet.com.zone
-rw-r--r-- 1 named named 195 Jan 25 2003 localhost.zone
-rw-r--r-- 1 named named 433 Jan 25 2003 named.1.168.192
-rw-r--r-- 1 named named 2499 Jan 25 2003 named.ca
-rw-r--r-- 1 named named 433 Jan 25 2003 named.local
// 编辑itbenet.com.zone
[root@localhost named]# vi itbenet.com.zone
$TTL 86400
$ORIGIN itbenet.com.
@ 1D IN SOA dns.itbenet.com root.mail.itbenet.com (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
1D IN NS dns.itbenet.com
1D IN MX 10 mail.itbenet.com
dns 1D IN A 192.168.1.100
mail 1D IN A 192.168.1.100
ftp 1D IN A 192.168.1.100
www 1D IN A 192.168.1.100
~
~
~
~
~
~
~
~
"itbenet.com.zone" 15L, 369C written
// 编辑named.1.168.192
[root@localhost named]# vi named.1.168.192
$TTL 86400
@ IN SOA dns.itbenet.com. root.mail.itbenet.com. (
2006091001 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS itbenet.com.
100 IN PTR dns.itbenet.com.
100 IN PTR
www.itbenet.com.
100 IN PTR
ftp.itbenet.com.
100 IN PTR mail.itbenet.com.
~
~
~
~
~
~
~
~
~
~
"named.1.168.192" 13L, 586C written
// 编辑resolv.conf
[root@localhost named]# vi /etc/resolv.conf
nameserver 192.168.1.100
search itbenet.com
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
"/etc/resolv.conf" 2L, 44C written
// 检查zone文件:itbenet.com.zone的语法有效性和文件完整性
[root@localhost root]# named-checkzone itbenet.com /var/named/itbenet.com.zone
zone itbenet.com/IN: loaded serial 42
OK
// 启动named服务
[root@localhost root]# service named start
// 检查named服务的状态
[root@localhost root]# service named status
number of zones: 6
debug level: 0
xfers running: 0
xfers deferred: 0
soa queries in progress: 0
query logging is OFF
server is up and running
// 重载配置文件和zone
[root@localhost root]# rndc reload
//域名查询
[root@localhost root]# nslookup
Note: nslookup is deprecated and may be removed from future releases.
Consider using the `dig' or `host' programs instead. Run nslookup with
the `-sil[ent]' option to prevent this message from appearing.
>
www.itbenet.com
Server: 192.168.1.100
Address: 192.168.1.100#53
Name:
ftp.itbenet.com
Address: 192.168.1.100
> mail.itbenet.com
Server: 192.168.1.100
Address: 192.168.1.100#53
Name: mail.itbenet.com
Address: 192.168.1.100
> dns.itbenet.com
Server: 192.168.1.100
Address: 192.168.1.100#53
Name: dns.itbenet.com
Address: 192.168.1.100
> 192.168.1.100
Server: 192.168.1.100
Address: 192.168.1.100#53
100.1.168.192.in-addr.arpa name = dns.itbenet.com.
100.1.168.192.in-addr.arpa name =
ftp.itbenet.com.
100.1.168.192.in-addr.arpa name =
www.itbenet.com.
100.1.168.192.in-addr.arpa name = mail.itbenet.com.
> set type=MX
> itbenet.com
Server: 192.168.1.100
Address: 192.168.1.100#53
itbenet.com mail exchanger = 10 mail.itbenet.com.itbenet.com.