歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux綜合 >> Linux資訊 >> 更多Linux >> 中小型企業的Sendmail郵件服務器應用實例

中小型企業的Sendmail郵件服務器應用實例

日期:2017/2/27 14:19:39   编辑:更多Linux
  簡介:本文旨在介紹如何利用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(`B99vNET_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



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



Copyright © Linux教程網 All Rights Reserved