当前位置: 首页 > 图文教程 > 操作系统 > Unix/Linux > 中小型企业的Sendmail邮件服务器应用实例

Unix/Linux
linux系统中QQ的使用和配置
Linux操作系统下提高PHP性能的工具APC
linux命令行(文本模式)下配置网络
Linux系统下安装Intel千兆网卡驱动
Linux下如何禁ping
Linux下忘记root用户密码的解决办法
linux 系统下磁盘检测工具e2fsck的使用
Linux操作系统下修改IP、DNS和路由配置
Linux操作系统上SSH无法启动解决办法
修复grub引导菜单
Linux下防御arp攻击的方法
linux系统查看磁盘空间
RHEL 5系统下常见故障处理
Linux中安装Realplay 10.0 的方法
linux防火墙iptables详细教程
图形化方法VNC连接LINUX服务器
Squid使用方法详解
TurboLinux11添加新硬盘方法
Linux 系统下通过脚本实现远程自动备份
恢复已删除的Linux文件

Unix/Linux 中的 中小型企业的Sendmail邮件服务器应用实例


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2010-01-16   浏览: 156 ::
收藏到网摘: n/a

简介:本文旨在介绍如何利用Linux服务器上的sendmail构建中小型企业的邮件服务器。
我们假定该企业采用专线接入Internet,有两台Linux服务器(Redhat 6.1 )
一台作为防火墙直接接入Chinanet,是通向Internet的唯一出入口,同时也作为
DNS/SMTP 服务器,且申请了域名domain.com,由该防火墙服务器(DNS服务器)
对域domain.com进行解析。另一台邮件服务器是在内部网段运行,完全与外部
世界无关。作为内部局域网上用户的收/发邮件服务器。
地址:假定防火墙Linux服务器的永久外部地址为a.b.c.d(eth0),内部网卡地址
192.168.11.5(eth1),机器名为firewall.domain.com, 内部的邮件服务器地址为
192.168.11.1,机器名为mail.domain.com , 且注册域时填写的主机名为
dns.domain.com(a.b.c.d) .
思路:先配置DNS服务器,用来解析@domain.com的域名,并指明MX记录到内部邮件
主机mail.domain.com. 把这台防火墙仅作为mail relay主机,任何从外部
世界发往@domain.com域的邮件均由它处理且relay到内部邮件主机,仅接受
@domain.com后缀的邮件进入,这样阻止了spammer发送垃圾邮件。
在内部邮件服务器上,配置Sendmail的DS部分为firewall.domain.com,任何
发往非内部员工的邮件直接送往firewall.domain.com,且设置domain.com为
本地域,任何发往@domain.com域的邮件被内部别名处理并送往内部各用户的
邮件缓冲池中。
旅行用户的考虑:
若公司员工出差在外需从公司的服务器接收邮件,一种方法是直接拨当地ISP,
然后设置接收邮件服务器为mail.domain.com,但要求mail.domain.com在外地
被解析成防火墙的外部永久地址,这样再在防火墙上设置plug-gw代理,代理
任何到防火墙外部地址的110端口的请求到内部192.168.11.1的110端口。
另一种方法,也可以再建一服务器为Linux拨入服务器,直接拨到公司来接收
邮件。
重点:Sendmail的各项配置及相关设置
一:防火墙上的Sendmail配置:
我们采用Redhat Linux 6.1 加 Sendmail 8.9.3作为操作环境:
安装操作系统和防火墙的配置略,建议采用3c905b或者Intel pro100 的网卡,先配置DNS。
设置/etc/named.conf象这样:
============
zone "."{
type hint;
file "named.ca";
};
zone "0.0.127.in-addr.arpa"{
notify no;
type master;
file "127.0.0";
};
zone "11.168.192.in-addr.arpa"{
notify no;
type master;
file "192.168.11";
};
zone "domain.com" {
notify no;
type master;
file "domain.com";
};
文件 192.168.11象下面这样:
@ IN SOA dns.domain.com. root.mail.domain.com. (
1999092201 86400 3600 3600000 86400 )
NS dns.domain.com.
1 PTR mail.domain.com.
5 PTR firewall.domain.com.
文件 domain.com象下面这样:
@ IN SOA dns.domain.com. root.mail.domain.com. (
1999120401 86400 3600 3600000 86400 )
NS dns.domain.com.
A a.b.c.d
MX 10 mail.domain.com.
firewall A a.b.c.d
mail A a.b.c.d
dns A a.b.c.d
加下面的行到/etc/hosts
192.168.11.1 mail.domain.com mail
192.168.11.5 firewall.domain.com firewall
============
下面配置Sendmail,首先要先创建一个用来生成/etc/sendmail.cf的sendmail.mc文件,
在Redhat 安装的过程中有一个默认地redhat.mc在/usr/lib/sendmail-cf/cf目录下。
我们修改为如下:
===========
divert(-1)
dnl This is the macro config file used to generate the /etc/sendmail.cf
dnl file. If you modify thei file you will have to regenerate the
dnl /etc/sendmail.cf by running this macro config through the m4
dnl preprocessor:
dnl
dnl m4 /etc/sendmail.mc > /etc/sendmail.cf
dnl
dnl You will need to have the sendmail-cf package installed for this to
dnl work.
include(`../m4/cf.m4')
define(`confDEF_USER_ID',``8:12'')
OSTYPE(`linux')
undefine(`UUCP_RELAY')
undefine(`BITNET_RELAY')
define(`confAUTO_REBUILD')
define(`confTO_CONNECT', `1m')
define(`confTRY_NULL_MX_LIST',true)
define(`confDONT_PROBE_INTERFACES',true)
define(`PROCMAIL_MAILER_PATH',`/usr/bin/procmail')
define(`ALIAS_FILE',`/etc/mail/aliases')
FEATURE(`smrsh',`/usr/sbin/smrsh')
FEATURE(`mailertable',`hash -o /etc/mail/mailertable')
FEATURE(`virtusertable',`hash -o /etc/mail/virtusertable')
FEATURE(`domaintable',`hash -o /etc/mail/domaintable')
FEATURE(redirect)
FEATURE(always_add_domain)
FEATURE(use_cw_file)
FEATURE(local_procmail)
MAILER(procmail)
MAILER(smtp)
FEATURE(`access_db')
FEATURE(`blacklist_recipients')
dnl We strongly recommend to comment this one out if you want to protect
dnl yourself from spam. However, the laptop and users on computers that do
dnl not hav 24x7 DNS do need this.
dnl FEATURE(`accept_unresolvable_domains')
dnl FEATURE(`relay_based_on_MX')
=============
然后用m4 redhat.mc > sendmail.cf生成sendmail.cf放到/etc目录下。且做如下操作:
1. 更改/etc/sendmail.cf中Fw定义为Fw/etc/mail/sendmail.cw
并创建一个空文件sendmail.cw (#touch /etc/mail/sendmail.cw)
2. 更改/etc/mail/mailertable象下面这样:
domain.com relay:[192.168.11.1]
并运行makemap hash /etc/mail/mailertable.db