您的位置:首页>>系统应用>>Unix/Linux>>阅读资讯:Linux操作系统下配置DNS服务器的方法介绍有两台邮件服务器分别为192.168.1.1(windows下主机名为b.test.cn)和192.168.1.3(linux下主机名为a.test.com)。
在linux下配置DNS服务器,下面是配置过程中设置过的一些文件, 字串8
/etc/hosts 文件的具体内容如下:
# Do not remove the following line, or various programs 月落网
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost fc4 字串6
192.168.1.3 a.test.com a 字串8
192.168.1.1 b.test.cn b 月落网
/etc/host.conf 文件:
order hosts,bind
字串5
表示先用hosts文件做解析,在用DNS解析 yueluo.net
/etc/resolv.conf 文件: 字串7
; generated by NetworkManager, do not edit! 月落网
search test.com
字串6
nameserver 127.0.0.1
字串8
search test.cn
字串8
nameserver 192.168.1.1
nameserver 61.144.56.100
/etc/named.conf 文件:
// 字串6
// named.conf for Red Hat caching-nameserver
// 字串9
options { 字串9
directory "/var/named"; 月落网
dump-file "/var/named/data/cache_dump.db"; yueluo.net
statistics-file "/var/named/data/named_stats.txt"; 字串7
/* 月落
* If there is a firewall between you and nameservers you want 字串8
* to talk to, you might need to uncomment the query-source 字串6
* directive below. Previous versions of BIND always asked 字串5
* questions using port 53, but BIND 8.1 uses an unprivileged
* port by default. 月落网
*/
字串5
// query-source address * port 53; 字串8
}; 字串5
//
// a caching only nameserver config
// 字串7
controls {
www.yueluo.net
inet 127.0.0.1 allow { localhost; } keys { rndckey; };
};
zone "." IN { 月落网
type hint; 字串6
file "named.ca";
www.yueluo.net
};
月落
zone "test.com"IN {
字串8
type master; 字串7
file "test.com"; 字串9
allow-update { none; };
月落
};
字串6
zone "1.168.192.in-addr.arpa"IN { 字串9
type master;
file "192.168.1.rev"; www.yueluo.net
allow-update { none; }; www.yueluo.net
};
yueluo.net
zone "test.cn"IN {
月落
type master; 字串7
file "test.cn";
allow-update { none; }; 字串9
}; 字串6
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 {
月落网
type master;
file "named.ip6.local";
yueluo.net
allow-update { none; };
月落
}; 字串7
zone "255.in-addr.arpa" IN {
type master;
字串6
file "named.broadcast"; yueluo.net
allow-update { none; };
};
字串8
zone "0.in-addr.arpa" IN {
type master;
月落
file "named.zero";
字串7
allow-update { none; }; 字串5
}; www.yueluo.net
include "/etc/rndc.key";
在/var/name/test.com 文件下:
$TTL 86400 字串9
@ IN SOA a.test.com. root.a.test.com ( yueluo.net
42 ; serial (d. adams)
字串9
3H ; refresh www.yueluo.net
15M ; retry
1W ; expiry
1D ) ; minimum
IN NS a.test.com. 字串7
IN MX 10 mail.test.com. yueluo.net
a IN A 192.168.1.3 字串8
mail IN A 192.168.1.3
//其中root.a.test.com的含义是管理员的邮箱 yueluo.net
/var/name/test.cn 文件下:
月落网
$TTL 86400 字串6
@ IN SOA b.test.cn. root.a.test.com ( yueluo.net
42 ; serial (d. adams) 字串9
3H ; refresh 字串5
15M ; retry www.yueluo.net
1W ; expiry
1D ) ; minimum
字串9
IN NS b.test.cn.
IN MX 10 mail.test.cn.
b IN A 192.168.1.1 字串8
mail IN A 192.168.1.1 字串8
/var/name/192.168.1.rev 文件下:
字串5
$TTL 86400 月落
@ IN SOA 1.168.192.in-addr.arpa. root.test.com. (
1997022700 ; Serial
28800 ; Refresh www.yueluo.net
14400 ; Retry
字串6
3600000 ; Expire
字串5
86400 ) ; Minimum
字串8
IN NS a.test.com.
字串8
IN NS b.test.cn.
字串5
IN MX 10 mail.test.com.
IN MX 10 mail.test.cn. www.yueluo.net
3 IN PTR a.test.com.
3 IN PTR mail.test.com.
1 IN PTR b.test.cn. 字串5
1 IN PTR mail.test.cn. 字串6
然后用/etc/init.d/named restart重启DNS服务,在重启过程中,我曾经出现过好几次的错误,按照出错的提示,会提示是named.conf文件第几行出错的。或者提示在那些包含文件例如test.cn这些文件里面的问题,然后一个一个排除。 字串9
最后还有一些nslookup的命令比较有用: 月落
set all用于显示使用nslookup工具这台机器上的DNS服务器的一些信息 字串7
set type=any会显示完整信息包括域中邮件服务器和主从DNS服务器的名字和IP地址 字串7
server 192.168.0.1更换查询的DNS服务器地址。 字串6