首先定义/etc/hosts文件,我的ip地址是192.168.91.128,我的主机名字是codfei
[root@codfei ~]# more /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 Codfei
192.168.91.128 Codfei
再修改/etc/name.conf文件加入如下两行
设置我的域名为doit.com.cn在name.doit里定义,反向域名在name.do里定义
zone "doit.com.cn" IN {
type master;
file "name.doit";
allow-update { none; };
};
zone "91.168.192.in-addr.arpa" IN {
type master;
file "name.do";
allow-update { none; };
};
到/var/named/chroot/var/named里编写创建上述两个文件,这里面之所以到chroot目录里看是利用了chroot技术,具体的说明参见百度或者google。
[root@codfei named]# more name.doit
$TTL 86400
@ IN SOA doit.com.cn. Codfei.doit.com.cn. (
42 ; serial (d. adams)
30 ; refresh
15000 ; retry
1000 ; expiry
10000 ) ; minimum
IN NS Codfei.doit.com.cn.
Codfei IN A 192.168.91.128
[root@codfei named]# more name.do
$TTL 86400
@ IN SOA doit.com.cn. Codfei.doit.com.cn. (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
IN NS Codfei.doit.com.cn.
128 IN PTR Codfei.doit.com.cn.
现在配置好了,做一下测试
[root@codfei named]# nslookup
> server
Default server: 192.168.91.2
Address: 192.168.91.2#53
> server 192.168.91.128
Default server: 192.168.91.128
Address: 192.168.91.128#53
> codfei.doit.com.cn
Server: 192.168.91.128
Address: 192.168.91.128#53
Name: codfei.doit.com.cn
Address: 192.168.91.128