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.

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/312079/viewspace-245868/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/312079/viewspace-245868/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值