linux上bind服务安装配置

环境redhat6.4 64bit

1.安装bind包:
yum install  bind  bind-libs bind-utils bind-chroot  -y
[root@rhel64-64bit Desktop]# rpm -qa|grep bind|grep '^bind'
bind-chroot-9.8.2-0.62.rc1.el6.x86_64
bind-libs-9.8.2-0.62.rc1.el6.x86_64
bind-utils-9.8.2-0.62.rc1.el6.x86_64
bind-9.8.2-0.62.rc1.el6.x86_64

2.配置/etc/named.conf文件,修改下面参数:
listen-on port 53 { any; };
directory  "/var/named";
allow-query     { any; };


3.修改/etc/named.rfc1912.zones,加上正向解析和反向解析的文件:
zone "yoyo.com" IN {
 type master;
 file "yoyo.com.zone";
};
zone "12.3.2.in-addr.arpa" IN {
 type master;
 file "12.3.2.zone";
};

4.配置解析文件

创建并配置正向解析文件/var/named/yoyo.com.zone
$TTL 1D
yoyo.com. IN SOA yoyo.com. root (0 1H 15M 1W 1D)
yoyo.com. IN NS dns1.yoyo.com.
dns1.yoyo.com. IN A 127.0.0.1
www.yoyo.com. IN A 2.3.12.13
创建并配置反向解析文件/var/named/12.3.2.zone
$TTL 1D
@ IN SOA 12.3.2.in-addr.arpa. root (0 1H 15M 1W 1D)
@ IN NS dns1.yoyo.com.
127.0.0.1 IN PTR dns1.yoyo.com.
13 IN PTR www.yoyo.com.

5.named-checkconf检查配置文件是否有误
   service named start 启动DNS服务

6.测试可以修改linux的DNS服务器指向安装的bind服务
1>setup图形化界面配置
2>/etc/sysconfig/network-scripts/ifcfg-eth0添加DNS1
3>/etc/resolv.conf 添加nameserver   生效顺序是ifcfg-eth0->resolv.conf文件

7.这里测试就不重置linux的DNS了,直接测试:

正向解析:
[root@rhel64-64bit named]# dig @127.0.0.1 www.yoyo.com

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.62.rc1.el6 <<>> @127.0.0.1 www.yoyo.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 48400
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1

;; QUESTION SECTION:
;www.yoyo.com.			IN	A

;; ANSWER SECTION:
www.yoyo.com.		86400	IN	A	2.3.12.13

;; AUTHORITY SECTION:
yoyo.com.		86400	IN	NS	dns1.yoyo.com.

;; ADDITIONAL SECTION:
dns1.yoyo.com.		86400	IN	A	127.0.0.1

;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Wed May 16 01:25:46 2018
;; MSG SIZE  rcvd: 81
反向解析:
[root@rhel64-64bit named]# dig @127.0.0.1 -x 2.3.12.13

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.62.rc1.el6 <<>> @127.0.0.1 -x 2.3.12.13
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 47242
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1

;; QUESTION SECTION:
;13.12.3.2.in-addr.arpa.		IN	PTR

;; ANSWER SECTION:
13.12.3.2.in-addr.arpa.	86400	IN	PTR	www.yoyo.com.

;; AUTHORITY SECTION:
12.3.2.in-addr.arpa.	86400	IN	NS	dns1.yoyo.com.

;; ADDITIONAL SECTION:
dns1.yoyo.com.		86400	IN	A	127.0.0.1

;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Wed May 16 01:24:02 2018
;; MSG SIZE  rcvd: 101
或使用nslookup解析测试:
[root@rhel64-64bit named]# nslookup
> server 127.0.0.1
Default server: 127.0.0.1
Address: 127.0.0.1#53
> www.yoyo.com
Server:		127.0.0.1
Address:	127.0.0.1#53

Name:	www.yoyo.com
Address: 2.3.12.13
> 2.3.12.13
Server:		127.0.0.1
Address:	127.0.0.1#53

13.12.3.2.in-addr.arpa	name = www.yoyo.com.



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值