- options {
- directory "/var/named"; # 定义存放的目录
- allow-recursion { 172.16.0.0/16; }; # 定义要递归的网段
- };
- zone "." {
- type hint; # 区域的类型
- file "named.ca"; # 区域数据文件
- };
- zone "localhost" {
- type master;
- file "named.localhost";
- allow-transfer { none; }; # 不允许区域传送
- };
- zone "0.0.127.in-addr.arpa" {
- type master;
- file "named.loopback";
- allow-transfer { 172.16.13.2; }; # 允许传送的辅助区域
- };
- zone "abc.com" {
- type master;
- file "abc.com.zone";
- allow-transfer { 172.16.13.2; };
- };
- zone "13.16.172.in-addr.arpa" {
- type master;
- file "172.16.13.zone";
- allow-transfer { 172.16.13.2; };
- };
- key "rndc-key" { #见下边注释
- algorithm hmac-md5;
- secret "7oJ+Gsf3HCYYaq9DbpRWvw==";
- };
- controls {
- inet 127.0.0.1 port 953
- allow { 127.0.0.1; } keys { "rndc-key"; };
- };
注:实现rndc(dns远程控制工具)在本机控制dns服务器1、生成key配置文件# rndc-confgen > /etc/rndc.conf2、将配置文件中的注释掉的后半段复制到/etc/named.conf文件中,并去掉注释符3、重启一下网络服务4、可执行rndc -h 命令显示出来的所有命令。
- $TTL 600
- @ IN SOA ns1.abc.com. admin.abc.com (
- 2013040103
- 1H
- 5M
- 1D
- 6H ) # SOA记录,@引用主配置文件中定义的区域名
- IN NS ns1 #主服务器的ns,ns1(空格默认与其上的域名相同)
- IN NS ns2 # 从服务器的ns,ns2
- IN MX 10 mail # 邮件服务器的ns记录,mail
- ns1 IN A 172.16.13.1 # ns记录对应的A记录
- ns2 IN A 172.16.13.2
- mail IN A 172.16.13.2
- www IN A 172.16.13.1 # www的A记录
- www IN A 172.16.13.3
- ftp IN CNAME www # www的ftp别名
- *.abc.com. IN A 172.16.13.4 # abc.com.域中,除了以上定义的所有主机的A记录
- $TTL 600
- @ IN SOA ns1.abc.com. admin.abc.com (
- 2013040501
- 1H
- 5M
- 1D
- 6H ) # SOA记录,@引用主配置文件中定义的区域名
- IN NS ns1.abc.com.
- IN NS ns2.abc.com. # 主从服务器的NS反向解析
- 1 IN PTR ns1.abc.com. # IP地址为172.16.13.1的指针PTR记录
- 2 IN PTR ns2.abc.com.
- 1 IN PTR www.abc.com.
- 2 IN PTR mail.abc.com.
- 3 IN PTR www.abc.com.
- options {
- directory "/var/named";
- allow-recursion { 172.16.0.0/16; };
- };
- zone "." {
- type hint;
- file "named.ca";
- };
- zone "localhost" {
- type master;
- file "named.localhost";
- allow-transfer { none; };
- };
- zone "0.0.127.in-addr.arpa" {
- type master;
- file "named.loopback";
- masters { 172.16.13.1; };
- allow-transfer { 172.16.13.2; };
- };
- zone "abc.com" {
- type slave; # 文件类型为从区域:slave
- file "slaves/abc.com.zone"; # 区域数据文件在/var/named/slaves下
- masters { 172.16.13.1; }; # 指定主服务器
- allow-transfer { 172.16.13.2; };
- };
- zone "13.16.172.in-addr.arpa" {
- type slave;
- file "slaves/172.16.13.zone";
- masters { 172.16.13.1; };
- allow-transfer { 172.16.13.2; };
- };
此时,主从服务器便能实现数据同步。在主服务器上修改任意内容,都将自动同步至从服务器上。可在修改完成并重新写入后,使用日志查看同步信息。