中小型企业的Sendmail邮件服务器应用实例
技术  /  管理员 发布于 7年前   127
简介:本文旨在介绍如何利用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
122 在
学历:一种延缓就业设计,生活需求下的权衡之选中评论 工作几年后,报名考研了,到现在还没认真学习备考,迷茫中。作为一名北漂互联网打工人..123 在
Clash for Windows作者删库跑路了,github已404中评论 按理说只要你在国内,所有的流量进出都在监控范围内,不管你怎么隐藏也没用,想搞你分..原梓番博客 在
在Laravel框架中使用模型Model分表最简单的方法中评论 好久好久都没看友情链接申请了,今天刚看,已经添加。..博主 在
佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 @1111老铁这个不行了,可以看看近期评论的其他文章..1111 在
佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 网站不能打开,博主百忙中能否发个APP下载链接,佛跳墙或极光..
Copyright·© 2019 侯体宗版权所有·
粤ICP备20027696号