怎么建立slave类型的dns服务器

DNS服务器的类型:

Master:     提供dns服务,并且本身含有区域文档。

Slave:      和Master一起提供dns服务,当Master服务器上的名字地址对更改的时候,会自动更新Slave服务器来达到同步。

Cache-only: 没有自己的区域文档,只是帮助客户段向外部dns请求查询,然后将查到的结果保存到他的缓存中。

[@more@]

1,pre-configuration check

dig -t axfr example.com  @192.168.0.254

host -l example.com  192.168.0.254

2,安装包

yum install -y bind bind-utils bind-chroot caching-nameserver

3,编辑named.conf

zone "example.com"  IN {

type slave;

masters { 192.168.0.254; };

file "slaves/example.com.zone";

forwarders {};

};

4, 修改文件权限

[root@station10 etc]# ls -lZ

-rw-r–r–  root root  system_u:object_r:locale_t       localtime

-rw-r—–  root named system_u:object_r:named_conf_t   named.caching-nameserver.conf

-rw-r—–  root root  root:object_r:named_conf_t       named.conf

-rw-r—–  root named system_u:object_r:named_conf_t   named.rfc1912.zones

-rw-r–r–  root named system_u:object_r:dnssec_t       rndc.key

[root@station10 etc]# chown root:named named.conf

[root@station10 etc]# chmod 640 !$

chmod 640 named.conf

[root@station10 etc]# ls -lZ

-rw-r–r–  root root  system_u:object_r:locale_t       localtime

-rw-r—–  root named system_u:object_r:named_conf_t   named.caching-nameserver.conf

-rw-r—–  root named root:object_r:named_conf_t       named.conf

-rw-r—–  root named system_u:object_r:named_conf_t   named.rfc1912.zones

-rw-r–r–  root named system_u:object_r:dnssec_t       rndc.key

[root@station10 etc]#

5,启动服务

[root@station10 etc]# service named configtest

zone localdomain/IN: loaded serial 42

zone localhost/IN: loaded serial 42

zone 0.0.127.in-addr.arpa/IN: loaded serial 1997022700

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

zone 255.in-addr.arpa/IN: loaded serial 42

zone 0.in-addr.arpa/IN: loaded serial 42

[root@station10 etc]# service named restart

6,查看产生的文件

[root@station10 etc]# cd /var/named/chroot/var/named/slaves/

[root@station10 slaves]# ls -lZ

-rw-r–r–  named named root:object_r:named_cache_t      example.com.zone

[root@station10 slaves]# cat example.com.zone

7,测试

[root@station10 slaves]# host -r station10.example.com localhost

Using domain server:

Name: localhost

Address: 127.0.0.1#53

Aliases:

station10.example.com has address 192.168.0.10

[root@station10 slaves]# dig +norecurse station10.example.com @localhost

; <<>> DiG 9.3.3rc2 <<>> +norecurse station10.example.com @localhost

; (1 server found)

;; global options:  printcmd

;; Got answer:

;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 11983

;; flags: qr aa ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1

;; QUESTION SECTION:

;station10.example.com.         IN      A

;; ANSWER SECTION:

station10.example.com.  86400   IN      A       192.168.0.10

;; AUTHORITY SECTION:

example.com.            86400   IN      NS      server1.example.com.

;; ADDITIONAL SECTION:

server1.example.com.    86400   IN      A       192.168.0.254

;; Query time: 14 msec

;; SERVER: 127.0.0.1#53(127.0.0.1)

;; WHEN: Fri Oct 10 00:55:54 2008

;; MSG SIZE  rcvd: 93

[root@station10 slaves]#

原创文章,作者:GKOJZ,如若转载,请注明出处:http://www.wangzhanshi.com/n/13883.html

(0)
GKOJZ的头像GKOJZ
上一篇 2025年1月1日 17:04:47
下一篇 2025年1月1日 17:04:49

相关推荐

发表回复

登录后才能评论