linux bind dns簡單配置

操作系統版本:
[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記錄:
www.example.com. 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 www.example.com.
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
> www.example.com
Server: 172.25.1.114
Address: 172.25.1.114#53

Name: www.example.com
Address: 172.25.1.111
> exit

[root@test named]#


9,修改反向解析的配置文件,把最後兩行更改爲:
111.1 IN PTR www.example.com.
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 = www.example.com.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章