linux dns

1、 生成 named.conf 文件

软件列表
yum install  bind*
yum install  caching-nameserver- 9.4.0 -6.fc7
如果您升级过系统,则软件的版本会略有不同。其中的 bind-chroot 可以增加 DNS 服务器的安全,不安装也能工作。
redhat
上的 bind 软件和别的 linux 结构有所不同,没有了以前的 /etc/named.conf
/var/named/chroot/etc/named.conf(
前者是后者的符号链接 ) ,导致很多朋友一时不知道该如何配置 DNS 服务器了,经过简单研究,终于总结出了 DNS 服务器的配置方法。
/var/named/chroot/etc 下执行
cat named.caching-nameserver.conf named.rfc1912.zones > named.conf
rm named.caching-nameserver.conf named.rfc1912.zones
[root@maluyao ~]ln -s   /var/named/chroot/etc/named.conf /etc/named.conf
上面的步骤是合并 named.caching-nameserver.conf
named.rfc1912.zones
合并到一个文件 (/var/named/chrrot/etc/named.conf) 中,然后将其删除。实际操作的时候,最好不要删除,而是将这俩个文件移动到其他位置备份。并且为了方便起见,在 /etc 下作了一个符号链接。
修改 named.conf 文件:
options {
        directory       "/var/named";
};
 
controls {
inet 127.0.0.1 allow {localhost;} keys {rndckey;};
};
 
zone "." IN {
        type hint;
        file "named.ca";
};
 
zone "test.com" IN {
        type master;
        file "test.com.zone";
        allow-update {none;};
};
zone "1.168.192.in-addr.arpa" IN {
type master;
file "test.com.local";
allow-update { none; };
};
include "/etc/rndc.key";
 
重新启动 BIND
#service named restart
2 编辑正向区域和反向区域文件
进入到 /var/named/chroot/var/named 下;
Cp localhost.zone test.com.zone   正向区域文件
Cp name.local  test.com.local    反向区域文件
 
正向区域文件原来的内容是这样的:
$TTL 86400
@ IN SOA localhost. root.localhost. (
1997022700 ; Serial 配置文件的修改版本
28800 ; Refresh 刷新频率
14400 ; Retry 重试时间
3600000 ; Expire 过期时间
86400 ) ; Minimum
IN NS localhost.
1 IN PTR localhost.
 
修改后如下
$TTL 86400
@ IN SOA test.com. root.test.com. (
20090520 ; serial
28800 ; refresh
14400 ; retry
3600000 ; expire
86400 ) ; minimum
IN        NS        abc.com.
www     IN         A         192.168.1.150
保存退出,之后 [root@localhost named]# vi abc.local 修改反向区域数据文件
$TTL 86400
@ IN SOA test.com. root.test.com. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN     NS      test.com.
150     IN     PTR     www.test.com.
然后把 test.com.zone test.com.local 属组全都改为 named
chgrp named  test.com.zone
chgrp named  test.com.local
 
 
3 、重启服务
[root@localhost named]# service named restart
停止 named [ 失败 ]
启动 named [ 确定 ]
 
4 、测试一下:
[root@mail named]# nslookup www.test.com
Server:         127.0.0.1
Address:        127.0.0.1#53
 
Name:   www.test.com
Address: 192.168.1.150
ok 正向解析成功
[root@localhost named]# nslookup 192.168.1.150
Server: 127.0.0.1
Address: 127.0.0.1#53
150.1.168.192.in-addr.arpa name = www.test.com.
You have new mail in /var/spool/mail/root
ok 反向解析成功
 

你可能感兴趣的:(linux,职场,dns,休闲)