linux bind dns簡單配置

tonykorn97發表於2008-04-14

作業系統版本:
[root@test ~]# cat /etc/issue
Red Hat Enterprise Linux AS release 4 (Nahant Update 4)
Kernel r on an m


核心:
[root@test ~]# uname -a
Linux test 2.6.9-42.EL #1 Wed Jul 12 23:16:43 EDT 2006 i686 i686 i386 GNU/Linux
[root@test ~]#


需要安裝的軟體:
[root@test ~]# rpm -aq | grep bind
bind-9.2.4-16.EL4
bind-utils-9.2.4-16.EL4
bind-chroot-9.2.4-16.EL4
bind-libs-9.2.4-16.EL4
ypbind-1.17.2-8
[root@test ~]# rpm -aq | grep caching-nameserver
caching-nameserver-7.3-3
[root@test ~]#


1,修改配置檔案:
[root@test etc]# pwd
/var/named/chroot/etc
[root@test etc]# vi named.conf

新增如下行到配置檔案中
zone "example.com" IN{
type master;
file "example.com.zone";
};

zone "25.172.in-addr.arpa" IN {
type master;
file "example.com.local";
};

2,新增zone檔案:
[root@test etc]# cd ../var/named/
[root@test named]# pwd
/var/named/chroot/var/named
[root@test named]# ls
data localdomain.zone localhost.zone named.broadcast named.ca named.ip6.local named.local named.zero slaves
[root@test named]# cp localdomain.zone example.com.zone
[root@test named]# cp named.local example.com.local
[root@test named]#

3,修改example.com.zone檔案,在檔案末尾新增A記錄:
. IN A 172.25.1.111
bbs IN A 172.25.1.112

第一行是完整寫法,第二行是省略寫法,效果一樣。

4,修改example.com.local檔案,在檔案末尾新增PTR記錄:
111.1.25.172.IN-ADDR-ARPA IN PTR .
112 IN PTR bbs.example.com.

5,修改這個兩個檔案的許可權。
[root@test named]# chmod 644 example.com.*
[root@test named]#

6,啟動named.
[root@test named]# service named start
Starting named: [ OK ]
[root@test named]#

啟動的日誌資訊:
Apr 14 13:21:19 test named[22327]: starting BIND 9.2.4 -u named -t /var/named/chroot
Apr 14 13:21:19 test named[22327]: using 1 CPU
Apr 14 13:21:19 test named[22327]: loading configuration from '/etc/named.conf'
Apr 14 13:21:19 test named[22327]: listening on IPv4 interface lo, 127.0.0.1#53
Apr 14 13:21:19 test named[22327]: listening on IPv4 interface eth0, 172.25.1.114#53
Apr 14 13:21:19 test named[22327]: command channel listening on 127.0.0.1#953
Apr 14 13:21:19 test named[22327]: zone 0.in-addr.arpa/IN: loaded serial 42
Apr 14 13:21:19 test named[22327]: zone 0.0.127.in-addr.arpa/IN: loaded serial 1997022700
Apr 14 13:21:19 test named[22327]: zone 25.172.in-addr.arpa/IN: loaded serial 1997022700
Apr 14 13:21:19 test named[22327]: zone 255.in-addr.arpa/IN: loaded serial 42
Apr 14 13:21:19 test named[22327]: zone 0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa/IN: loaded serial 1997022700
Apr 14 13:21:19 test named[22327]: zone example.com/IN: loaded serial 42
Apr 14 13:21:19 test named[22327]: zone localdomain/IN: loaded serial 42
Apr 14 13:21:19 test named[22327]: zone localhost/IN: loaded serial 42
Apr 14 13:21:19 test named[22327]: running
Apr 14 13:21:19 test named: named startup succeeded


7, 配置dns客戶機.
[root@test named]# cat /etc/resolv.conf
search example.com
nameserver 172.25.1.114
[root@test named]#

8, 測試:
正向解析可以,逆向解析有問題:
[root@test named]# nslookup
> 172.25.1.111
Server: 172.25.1.114
Address: 172.25.1.114#53

** server can't find 111.1.25.172.in-addr.arpa: NXDOMAIN
>
Server: 172.25.1.114
Address: 172.25.1.114#53

Name:
Address: 172.25.1.111
> exit

[root@test named]#


9,修改反向解析的配置檔案,把最後兩行更改為:
111.1 IN PTR .
112.1 IN PTR bbs.example.com.
這個是簡單配置。


重啟named服務,然後測試就可以了。
[root@test named]# nslookup
> 172.25.1.111
Server: 172.25.1.114
Address: 172.25.1.114#53

111.1.25.172.in-addr.arpa name = .

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/312079/viewspace-245868/,如需轉載,請註明出處,否則將追究法律責任。

相關文章