操作系统:cenotos 5.5
安装方式:YUM在线安装
域名:xxx.com
目的:配置本地dns服务器,增加多个MX记录实现后面的测试解决客户在邮件系统升级时不能收到邮件的问题。
本地测试:用VMware安装四个虚拟机。主要使用yum方式在线安装软件件包,编译安装不在讨论之列,所以均使用最小安装,只选择安装上base基本组件。
dns-66:192.168.0.66 《dns服务器》
mx0-150:192.168.0.150 《主邮件服务器》
mx1-151:192.168.0.151 《从1邮件服务器》
mx2-152:192.168.0.152 《从2邮件服务器》
1.yum安装组件包
yum install bind bind-chroot ypbind caching-nameserver bind-libs perl portmap yp-tools wget man
安装完成后应该可以启动named服务器,测试一下 service named start
2.编辑bind的配置文件:named.conf.新版bind服务运行chroot环境下,所有的文件都在/var/named/chroot/目录,对于bind9来说,这里是根目录。
3.
#cd /var/named/chroot/etc/
#ll
total 32
-rw-r--r-- 1 root root 405 Jan 18 17:14 localtime
-rw-r----- 1 root named 1230 Dec 14 02:10 named.caching-nameserver.conf
-rw-r----- 1 root named 1041 Jan 20 21:51 named.rfc1912.zones
-rw-r----- 1 root named 113 Jan 20 17:51 rndc.key \\ 当前目录下有这几个文件
#cp -a named.caching-nameserver.conf named.conf \\将named.caching-nameserver.conf复制为named.conf
#vi named.conf
//
// named.caching-nameserver.conf
//
// Provided by Red Hat caching-nameserver package to configure the
// ISC BIND named(8) DNS server as a caching only nameserver
// (as a localhost DNS resolver only).
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//
// DO NOT EDIT THIS FILE - use system-config-bind or an editor
// to create named.conf - edits to this file will be lost on
// caching-nameserver package upgrade.
//
opti** {
listen-on port 53 { 127.0.0.1; };
listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
// Those opti** should be used carefully because they disable port
// randomization
// query-source port 53;
// query-source-v6 port 53;
4. 编辑named.rfc1912.zones 区域文件
#vi named.rfc1912.zones
// named.rfc1912.zones:
//
// Provided by Red Hat caching-nameserver package
//
// ISC BIND named zone configuration for zones recommended by
// RFC 1912 section 4.1 : localhost TLDs and address zones
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//
zone "." IN {
type hint;
file "named.ca";
};
zone "localdomain" IN {
type master;
file "localdomain.zone";
allow-update { none; };
};
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 "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";
allow-update { none; };
};
zone "255.in-addr.arpa" IN {
type master;
file "named.broadcast";
allow-update { none; };
};
zone "0.in-addr.arpa" IN {
type master;
file "named.zero";
allow-update { none; };
};
zone "xxx.com" IN { \\在文件最后增加这几行内容,xxx.com域解析文件为xxx.com.zone
type master;
file "xxx.com.zone";
allow-update { none; };
};
5.创建xxx.com.zone文件并编辑。
区域的配置文件存放在var/named,因为是在chroot环境下,所以真实的目录应该是/var/named/chroot/var/named/
#cd /var/named/chroot/var/named/
[root@ns named]# ll
total 76
drwxrwx--- 2 named named 4096 Jan 20 22:04 data
-rw-r----- 1 root named 198 Dec 14 02:10 localdomain.zone
-rw-r----- 1 root named 195 Dec 14 02:10 localhost.zone
-rw-r----- 1 root named 427 Dec 14 02:10 named.broadcast
-rw-r----- 1 root named 1892 Dec 14 02:10 named.ca
-rw-r----- 1 root named 424 Dec 14 02:10 named.ip6.local
-rw-r----- 1 root named 426 Dec 14 02:10 named.local
-rw-r----- 1 root named 427 Dec 14 02:10 named.zero
drwxrwx--- 2 named named 4096 Jul 27 2004 slaves
在这里将named.local复制为xxx.com.zone
#vi xxx.con.zone
$TTL 86400
@ IN SOA localhost root (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
IN NS localhost
www IN A 192.168.0.150
mail IN A 192.168.0.150
mx1 IN A 192.168.0.151
mx2 IN A 192.168.0.152
@ IN MX 0 mail
@ IN MX 10 mx1
@ IN MX 20 mx2