Sendmail 中继配置
环境: virtualbox或vmware
named(sina.com)+sendmail: Redhat1 eth0 :192.168.142.3
named(163.com)+sendmail: Redhat2 eht0:192.168.142.2
测试机: windows2003
要求:让两个邮件服务器利用两个dns服务器来进行相互收发邮件
一.Redhat1 dns 配置
1. 挂载光盘,进行软件安装
[root@localhost ~]# mount -o loop /dev/cdrom /mnt/cdrom
[root@localhost ~]# cd /mnt/cdrom/Server/
[root@localhost Server]# rpm -ivh bind-9.3.6-4.P1.el5.i386.rpm bind-chroot-9.3.6-4.P1.el5.i386.rpm caching-nameserver-9.3.6-4.P1.el5.i386.rpm
warning: bind-9.3.6-4.P1.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:bind ########################################### [ 33%]
2:bind-chroot ########################################### [ 67%]
3:caching-nameserver ########################################### [100%]
root@localhost Server]#
2.DNS全局文件named.conf配置如下
[root@localhost Server]# cd /var/named/chroot/etc
[root@localhost etc]# cp -p named.caching-nameserver.conf named.conf
[root@localhost etc]# vim named.conf
options {
listen-on port 53 { any; };
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";
allow-query { any; };
allow-query-cache { any; };
};
logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
view localhost_resolver {
match-clients { any; };
match-destinations { any; };
recursion yes;
include "/etc/named.rfc1912.zones";
};
3. 配置文件配置如下
增加如下内容
zone "sina.com" IN {
type master;
file "sina.com.zone";
allow-update { none; };
};
zone "142.168.192.in-addr.arpa" IN {
type master;
file "142.168.192.local";
allow-update { none; };
};
4. 配置区域文件
[root@localhost etc]# cd ../var/named/
[root@localhost named]# cp -p localhost.zone sina.com.zone
[root@localhost named]# cp -p localhost.zone 142.168.192.local
[root@localhost named]# vim sina.com.zone
$TTL 86400
@ IN SOA ns.sina.com. root (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
IN NS ns.sina.com.
mail IN A 192.168.142.3
pop3 IN CNAME mail
smtp IN CNAME mail
@ IN MX 10 mail
[root@localhost named]# vim 142.168.192.local
$TTL 86400
@ IN SOA ns.sina.com. root (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
IN NS ns.sina.com.
3 IN PTR mail.sina.com.
二.Redhat2 dns 配置
redhat2上的配置基本上和redhat1上的一致,只需如下内容即可
在主配置文件named.conf中增加如下
zone "163.com" IN {
type master;
file "163.com.zone";
allow-update { none; };
};
zone "142.168.192.in-addr.arpa" IN {
type master;
file "142.168.192.local";
allow-update { none; };
};
在区域文件中配置如下163.com.zone
$TTL 86400
@ IN SOA ns.163.com. root (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
IN NS ns.163.com.
mail IN A 192.168.1.113
pop3 IN CNAME mail
smtp IN CNAME mail
@ IN MX 10 mail
142.168.192.local修改成如下
zone "142.168.192.in-addr.arpa" IN {
type master;
file "142.168.192.local";
allow-update { none; };
};
三. redhat1上配置sendmail服务器
安装软件
[root@localhost Server]# rpm -ivh sendmail-8.13.8-2.el5.i386.rpm sendmail-cf-8.13.8-2.el5.i386.rpm
[root@localhost Server]# rpm -ivh perl-DBI-1.52-2.el5.i386.rpm mysql-5.0.77-3.el5.i386.rpm dovecot-1.0.7-7.el5.i386.rpm (这个软件是接收邮件软件,支持pop3与imap)
[root@localhost Server]# cd /etc/mail
[root@localhost mail]# vim sendmail.mc
将大概116行的
DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl
修改为
DAEMON_OPTIONS(`Port=smtp,Addr=0.0.0.0, Name=MTA')dnl
在此文件中增加如下
[root@localhost mail]# vim local-host-names
# local-host-names - include all aliases for your machine here.
sina.com
启动服务器
[root@localhost mail]# service named restart
停止 named: [确定]
启动 named: [确定]
[root@localhost mail]# service dovecot start
启动 Dovecot Imap: [确定]
[root@localhost mail]# service sendmail restart
关闭 sm-client: [确定]
关闭 sendmail: [确定]
启动 sendmail: [确定]
启动 sm-client: [确定]
[root@localhost mail]#
在windows2003上进行测试
首先在服务器上创建一个用户user2
并且发送给user2一个邮件
[root@localhost named]# mail user2
Subject: good
good
.
Cc:
在windows2003上进行接收
测试成功
四. redhat2上配置sendmail服务器
redhat2上的配置与在redhat1上配置的基本一样,只有一处不同
[root@localhost mail]# vim local-host-names
# local-host-names - include all aliases for your machine here.
163.com
只要修改上面的一处即可
重启各服务器
[root@localhost mail]# service named restart
停止 named: [确定]
启动 named: [确定]
[root@localhost mail]# service dovecot start
启动 Dovecot Imap: [确定]
[root@localhost mail]# service sendmail restart
关闭 sm-client: [确定]
关闭 sendmail: [确定]
启动 sendmail: [确定]
启动 sm-client: [确定]
测试
在服务器新建用户user1
并且给user1发送一个文件
zone "0.0.127.in-addr.arpa" IN {
[root@host etc]# mail user1
Subject: hello
hello!
.
Cc:
在windows上创建code1用户并接收邮件
下面的是开始做中继配置,让redhat1上的帐户可以和redhat上的帐户进行邮件通信
5. 在redhat1上配置
配置nds的全局文件 ,让dns如果不能找到自己解析的地址,就转发到redhat2上继续解析
[root@localhost var]# cd /var/named/chroot/etc/
[root@localhost etc]# vim named.conf
在option添加如下一行,表明中继的ip地址
forwarders { 192.168.142.2; };
配置sendmail的配置文件,使本sendmail可以接收以及发送redhat2中类型的邮件
[root@localhost etc]# cd /etc/mail
[root@localhost mail]# vim access
在最下面添加如下两行
sina.com OK
163.com RELAY
重启named与sendmail服务器即可
6. 在redhat2下如下配置
配置dns要转发的服务器IP地址
[root@host etc]# cd /var/named/chroot/etc/
[root@host etc]# vim named.conf
在option中添加下句
forwarders { 192.168.142.3; };
配置sendmail文件,使本sendmail可以接收以及发送redhat1中类型的邮件
[root@host etc]# cd /etc/mail
[root@host mail]# vim access
添加如下内容
163.com OK
sina.com RELAY
重启named与sendmail服务器即可
6.测试
使用user1来给user2来发一个邮件,看user2是否能够接收
结果
再使用user2给user1发一个邮件
结果