[root@localhost root]# vi /var/named/zzvips.com
$TTL 86400
$ORIGIN zzvips.com.
@ 1D IN SOA zzvips.com. root.zzvips.com. (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
1D IN NS @
1D IN MX 5 mail.zzvips.com.
www 1D IN A 172.18.121.35
mail 1D IN A 172.18.121.35
ftp 1D IN A 172.18.121.35
pop3 IN CNAME mail.zzvips.com.
smtp IN CNAME mail.zzvips.com.
[root@localhost root]# vi /var/named/172.18.121.rev
$TTL 86400
@ IN SOA zzvips.com. root.zzvips.com. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS zzvips.com.</p> <p>35 IN PTR www.zzvips.com.
35 IN PTR mail.zzvips.com.
35 IN PTR ftp.zzvips.com.
配置本机DNS的一个主文件,安装好后它有一个模板,修改它,修改的部分是粗线表示
代码如下:
[root@localhost root]# vi /etc/named.conf
// generated by named-bootconf.pl
options {
directory "/var/named";
/*
* If there is a firewall between you and nameservers you want
* to talk to, you might need to uncomment the query-source
* directive below. Previous versions of BIND always asked
* questions using port 53, but BIND 8.1 uses an unprivileged
* port by default.
*/
// query-source address * port 53;
};
//
// a caching only nameserver config
//
controls {
inet 127.0.0.1 allow { localhost; } keys { rndckey; };
};
zone "." IN {
type hint;
file "named.ca";
};
zone "localhost" IN {
type master;
file "localhost.zone";
allow-update { none; };
};
zone "0.0.127.in-addr.arpa" IN {
type master;
file "named.local";
allow-update { none; };
};
zone "zzvips.com"IN{
type master;
file "zzvips.com";
};
zone "121.18.172.in-addr.arpa"IN{
type master;
file "172.18.121.rev";
};
include "/etc/rndc.key";
"/etc/named.conf" [已转换] 45L, 894C
配置本机的域名转换程序的顺序
代码如下:
[root@localhost root]# vi /etc/host.conf
order bind,hosts
multi off
trim zzvips.com
[root@localhost root]# vi /etc/resolv.conf
nameserver 172.18.121.35
nameserver 218.196.42.2
namedsever 218.196.42.2
domain zzvips.com
search www.zzvips.com zzvips.com
option nochecknames rotate
4.启动named服务.
代码如下:
[root@localhost root]#service named start
5.检查配置是否成功
代码如下:
[root@localhost root]# nslookup
Note: nslookup is deprecated and may be removed from future releases.
Consider using the `dig' or `host' programs instead. Run nslookup with
the `-sil[ent]' option to prevent this message from appearing.
> www.zzvips.com
Server: 172.18.121.35
Address: 172.18.121.35#53Name: www.zzvips.com
Address: 172.18.121.35
> 172.18.121.35
Server: 172.18.121.35
Address: 172.18.121.35#53
35.121.18.172.in-addr.arpa name = ftp.zzvips.com.
35.121.18.172.in-addr.arpa name = www.zzvips.com.
35.121.18.172.in-addr.arpa name = mail.zzvips.com.
>
ctrl +D退出
若出现上面的情况的文字表示已经配置成功.
6.其实在配置的过程中,查看自己是否配置正确可以通过named –g 进行查看你的配置文件到底错在那个地方,再进行修改 PS:DNS相关配置文件说明
. /etc/host.conf
当系统中同时存在DNS域名解析和/etc/hosts主机表机制时,由该/etc/host.conf确定主机名解释顺序。示例:
order hosts,bind #名称解释顺序
multi on #允许主机拥有多个IP地址
nospoof on #禁止IP地址欺骗
order是关键字,定义先用本机hosts主机表进行名称解释,如果不能解释,再搜索bind名称服务器(DNS)。
127.0.0.1 localhost localhost.localdomain
192.168.1.1 debian debian
192.168.0.2 t02 t02.tiger
192.168.0.4 t04 t04.tiger
./etc/name.conf
// generated by named-bootconf.pl</p> <p>options {
directory "/var/named";
/*
* If there is a firewall between you and nameservers you want
* to talk to, you might need to uncomment the query-source
* directive below. Previous versions of BIND always asked
* questions using port 53, but BIND 8.1 uses an unprivileged
* port by default.
*/
// query-source address * port 53;
};</p> <p>//
// a caching only nameserver config
//</p> <p>zone "." IN {
type hint;
file "named.ca";
};</p> <p>zone "0.0.127.in-addr.arpa" IN {
type master;
file "named.local";
allow-update { none; };
};
zone "zzvips.com" IN {
type master;
file "named.zzvips.com";
allow-update { none; };
};
zone "0.0.10.in-addr.arpa" IN {
type master;
file "named.zzvips.com.rev";
allow-update { none; };
};
这一部分是手工添加的。定义了“zzvips.com”这个域和对应的反向查询域。“type master”说明本机是“zzvips.com”和“0.0.10.in-addr.arpa”这两个域的主dns服务器(primary name server)。“named.zzvips.com”和“named.zzvips.com.rev”是域的记录文件。这两个文件也是自己创建的,下面我们就来看看这两个文件。
./var/named/naemd.***.com
资源记录文件,位于/var/named目录下。这个目录是named.conf中定义的。
1、named.zzvips.com文件内容如下:
代码如下:
@ IN SOA netfinity.zzvips.com. root.netfinity.zzvips.com. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS netfinity.zzvips.com.
IN MX 10 netfinity.zzvips.com.</p> <p>netfinity IN A 10.0.0.211
lily IN A 10.0.0.139
www IN CNAME netfinity.zzvips.com.
pop3 IN CNAME netfinity.zzvips.com.
smtp IN CNAME netfinity.zzvips.com.
在这个记录文件中,出现了5种类型的记录。SOA 是授权起始(Start Of Authority)的缩写,后面接着写你的dns服务器的主机名,这里是“netfinity.zzvips.com.”。(注意,主机名称后面的小圆点。凡是出现在记录文件了的主机名,记得都要加上这各小圆点。)NS 是名称服务器资源记录,指明域中的名称服务器,这里就是dns服务器。MX是邮件交换者资源记录,指明这个域的邮件服务器。你可以写多个MX记录,指明多个邮件服务器,优先级别由MX后的数字决定,数字越小,邮件服务器优先权越高。A是主机记录,把主机和ip地址对应起来。CNAME是别名记录,它赋予一个主机不同的名称,如www.zzvips.com、pop3.zzvips.com其实都是指向同一台主机netfinity.zzvips.com。 ./var/named/naemd.***.com.rev
named.zzvips.com.rev文件内容:
代码如下:
@ IN SOA netfinity.zzvips.com. root.netfinity.zzvips.com. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS netfinity.zzvips.com.
211 IN PTR netfinity.zzvips.com.
139 IN PTR lily.zzvips.com.