Sendmail簡單配置(3)

Sendmail 簡單配置(3)
RHEL5.1 基本網絡配置
1、
1 、RHEL5 U1:如圖1
clip_p_w_picpath002
(如圖1)
2 、#hostname //查看當前主機的主機名:如圖2
clip_p_w_picpath003
(如圖2)
3 、#vi /etc/sysconfig/network-scripts/ifcfg-eth0 編輯指定網絡接口配置文件:如圖3
clip_p_w_picpath005
(如圖3)
4 、#vi /etc/sysconfig/network 經過配置文件修改主機名:如圖4
clip_p_w_picpath007
(如圖4)
5 、在終端字符界面修改其字體和中文字體大小:如圖5
clip_p_w_picpath009
(如圖5)
6 、掛載光盤:如圖6
clip_p_w_picpath011
(如圖6)
7 、查看OpenSSH是否安裝:如圖7
clip_p_w_picpath013
(如圖7)
8 #vi /etc/hosts 設置本地 DNS 解析文件: 如圖8
clip_p_w_picpath015
(如圖8)
9 #vi /etc/resolv.conf 指定當前主機的 DNS 服務器,最多可指定三個: 如圖9
clip_p_w_picpath017
(如圖9)
10 、關閉iptables防火牆:如圖10
clip_p_w_picpath018
clip_p_w_picpath020
clip_p_w_picpath022
clip_p_w_picpath024
(如圖10)
2、DNS簡單配置
1 、vim /etc/named.conf
clip_p_w_picpath026
2 、vim /var/named/benet.com.zone
clip_p_w_picpath028
3 、vim /var/named/1.168.192.in-addr.arpa.zone
clip_p_w_picpath030
4 、重啓named服務
[root@dns ~]# service named restart
中止 named: [失敗]
啓動 named: [肯定]
[root@dns ~]# chkconfig --list named
named 0:關閉 1:關閉 2:關閉 3:關閉 4:關閉 5:關閉 6:關閉
[root@dns ~]# chkconfig --level 2345 named on
[root@dns ~]# chkconfig --list named
named 0:關閉 1:關閉 2:啓用 3:啓用 4:啓用 5:啓用 6:關閉
5 、nslookup查看
clip_p_w_picpath031
3、sendmail簡單配置
1 修改 local-host-names 文件添加域名及主機名
vim /etc/mail/local-host-names
[root@dns Server]# m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
[root@dns Server]# vim /etc/mail/local-host-names
# local-host-names - include all aliases for your machine here.
benet.com.
mail.benet.com.
~
~
~
"/etc/mail/local-host-names" 3L, 91C 已寫入
[root@dns Server]#
clip_p_w_picpath033
2 、確保 sasl 庫已經安裝
[root@dns Server]# rpm -qa | grep cyrus-sasl
cyrus-sasl-lib-2.1.22-4
cyrus-sasl-2.1.22-4
cyrus-sasl-plain-2.1.22-4
cyrus-sasl-devel-2.1.22-4
[root@dns Server]# rpm -qa cyrus-sasl
cyrus-sasl-2.1.22-4
[root@dns Server]# rpm -qa cyrus-sasl-lib
cyrus-sasl-lib-2.1.22-4
clip_p_w_picpath034
3 、安裝sendmail
root@dns ~]# mount /dev/hdc /mnt/dvd/
mount: block device /dev/hdc is write-protected, mounting read-only
[root@dns ~]# cd /mnt/dvd/Server/
[root@dns Server]# rpm -qa | grep sendmail
sendmail-8.13.8-2.el5
[root@dns Server]# ls sendmail*
sendmail-8.13.8-2.el5.i386.rpm sendmail-devel-8.13.8-2.el5.i386.rpm
sendmail-cf-8.13.8-2.el5.i386.rpm sendmail-doc-8.13.8-2.el5.i386.rpm
[root@dns Server]# rpm -ivh --aid sendmail-cf-8.13.8-2.el5.i386.rpm
warning: sendmail-cf-8.13.8-2.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:sendmail-cf ########################################### [100%]
[root@dns Server]# rpm -ivh --aid sendmail-devel-8.13.8-2.el5.i386.rpm
warning: sendmail-devel-8.13.8-2.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:sendmail-devel ########################################### [100%]
[root@dns Server]# rpm -ivh --aid sendmail-doc-8.13.8-2.el5.i386.rpm
warning: sendmail-doc-8.13.8-2.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:sendmail-doc ########################################### [100%]
[root@dns Server]#
[root@dns Server]# rpm -qa | grep sendmail
sendmail-devel-8.13.8-2.el5
sendmail-doc-8.13.8-2.el5
sendmail-cf-8.13.8-2.el5
sendmail-8.13.8-2.el5
[root@dns Server]# rpm -qa | grep m4
m4-1.4.5-3.el5.1
clip_p_w_picpath036
clip_p_w_picpath037
4 、修改 開啓sendmai認證 vim /etc/mail/sendmail.mc
去掉如下三行的 dnl字段開啓sendmail認證功能
52行 TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
53行 define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
123行 DAEMON_OPTIONS(`Port=submission, Name=MSA, M=Ea')dnl
修改 52 行和 53
clip_p_w_picpath039
修改 123
clip_p_w_picpath041
5 、修改 116
116將smtp偵聽範圍從127.0.0.1改成0.0.0.0
clip_p_w_picpath043
6 、修改第 155
155行修改爲本身域: LOCAL_DOMAIN(`benet.com')dnl
clip_p_w_picpath045
7 、默認 175
clip_p_w_picpath047
8 設置用戶用戶郵件的大小限制( 187 行)
在sendmail.mc中沒有這個選項,這個要在sendmail.cf中設置
vim /etc/mail/sendmail.cf
默認不限制:
# maximum message size
#O MaxMessageSize=0
咱們能夠設置成郵件最大不超過20MB
# maximum message size
O MaxMessageSize=20971520
意思爲每次收發郵件最大爲20MB,任何超過這個值的郵件將被拒絕。
clip_p_w_picpath049
9 使用 m4 命令生成 sendmail.cf 文件
m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
clip_p_w_picpath051
10 、郵件用戶帳戶的設置
[root@dns Server]# groupadd gongchengbu
[root@dns Server]# adduser -g gongchengbu -s /sbin/nologin honglin1
[root@dns Server]# adduser -g gongchengbu -s /sbin/nologin honglin2
[root@dns Server]# passwd honglin1
Changing password for user honglin1.
New UNIX password:
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@dns Server]# passwd honglin2
Changing password for user honglin2.
New UNIX password:
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@dns Server]# useradd zhangsan
[root@dns Server]# passwd zhangsan
Changing password for user zhangsan.
New UNIX password:
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@dns Server]# useradd lisi
[root@dns Server]# passwd lisi
Changing password for user lisi.
New UNIX password:
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@dns Server]# useradd wangwu
[root@dns Server]# passwd wangwu
Changing password for user wangwu.
New UNIX password:
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
clip_p_w_picpath053
11 、設置郵件別名和郵件羣發功能
[root@dns Server]# ls /etc/aliases
/etc/aliases
[root@dns Server]# ls /etc/aliases*
/etc/aliases /etc/aliases.db
[root@dns Server]# vim /etc/aliases
ftp-admin: ftp
www: webmaster
webmaster: root
noc: root
security: root
hostmaster: root
info: postmaster
marketing: postmaster
sales: postmaster
support: postmaster
gongchengbu: honglin1,honglin2
# trap decode to catch security attacks
decode: root
# Person who should get root's mail
"/etc/aliases" 97L, 1546C 已寫入
[root@dns Server]#
clip_p_w_picpath054
12 、經過 newaliases 生成 aliases.db 文件
[root@dns Server]# newaliases
/etc/aliases: 77 aliases, longest 17 bytes, 793 bytes total
clip_p_w_picpath055
13 、修改 vim /etc/mail/access
clip_p_w_picpath057
14 、經過 「makemap hash access.db < access」 生成數據庫文件
[root@dns Server]# makemap hash /etc/mail/access.db &lt; /etc/mail/access
[root@dns Server]#
[root@dns Server]# service sendmail restart
關閉 sm-client: [肯定]
關閉 sendmail: [肯定]
啓動 sendmail: [肯定]
啓動 sm-client: [肯定]
clip_p_w_picpath058
4、配置磁盤配額
1 vim /etc/fstab
添加/var文件系統參數
LABEL=/var         /var             ext3    defaults,usrquota,grpquota        1 2
usrquota 爲用戶的配額參數, grpquota 爲組的配額參數
[root@dns Server]# vim /etc/fstab
LABEL=/ / ext3 defaults 1 1
LABEL=/tmp /tmp ext3 defaults 1 2
LABEL=/var /var ext3 defaults,usrquota,grpquota 1
2
LABEL=/usr /usr ext3 defaults 1 2
LABEL=/home /home ext3 defaults 1 2
LABEL=/boot /boot ext3 defaults 1 2
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
LABEL=SWAP-sda3 swap swap defaults 0 0
~
~
"/etc/fstab" 11L, 854C 已寫入
clip_p_w_picpath060
2 、建立配額文件
由於存放郵件信息的/var目錄在獨立的分區哈~因此咱們使用 quotachek命令在/var目錄下分別爲用戶和組建立配額文件
quotacheck -cugm /var
clip_p_w_picpath061
3 、設置磁盤配額
爲用戶和組設置詳細的配額限制,咱們可使用 edquota命令進行磁盤配額的設置哈~
edquota 命令格式:
edquota -u 用戶名
edquota -g 組名
好比爲用戶 zhangsan配置磁盤配額限制,執行 edquota命令,打開用戶配額配置文件
edquota -u zhangsan
clip_p_w_picpath063
4 、使磁盤配額生效
命令: quotaon -augv 目錄名
參數:
  -a   開啓在/ect/fstab文件裏,有加入quota設置的分區的空間限制。
  -g   開啓羣組的磁盤空間限制。
  -u   開啓用戶的磁盤空間限制。
  -v   顯示指令指令執行過程。
quotaon -av
clip_p_w_picpath064
五、 查看磁盤配額狀態
Repquota -a
clip_p_w_picpath065
6 注意:
若是企業員工較多,那麼像這樣一個個爲每一個員工單獨配置磁盤配額將會增長咱們管理的難度哈~這裏咱們能夠創建一個樣簡單的腳本,將全部用戶的磁盤空間科學硬限制爲200MB。
在/etc/mail/目錄下建立一個quota.sh磁盤配額腳本文件
vim /etc/mail/quota.sh
[root@dns ~]# vim /etc/mail/quota.sh
#!/bin/bash
for i in zhangsan lisi wangwu honglin1 honglin2
do
setquota -u $i 0 200000 0 0 /var
done
~
~
~
"/etc/mail/quota.sh" [新] 5L, 101C 已寫入
[root@dns ~]# . /etc/mail/quota.sh
clip_p_w_picpath067
七、 . /etc/mail/quota.sh執行此腳本並查看
clip_p_w_picpath069
八、執行 quotaoff -av後執行 quotaon -av使設置的磁盤配額生效
clip_p_w_picpath070
5、安裝 Dovecot 軟件包( POP3 IMAP
1 、安裝 dovecot
[root@dns Server]# rpm -ivh --aid mysql-5.0.45-7.el5.i386.rpm
warning: mysql-5.0.45-7.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
error: Failed dependencies:
perl(DBI) is needed by mysql-5.0.45-7.el5.i386
[root@dns Server]# rpm -ivh --aid perl-DBI-1.52-2.el5.i386.rpm
warning: perl-DBI-1.52-2.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:perl-DBI ########################################### [100%]
[root@dns Server]# rpm -ivh --aid mysql-5.0.45-7.el5.i386.rpm
warning: mysql-5.0.45-7.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:mysql ########################################### [100%]
[root@dns Server]# rpm -ivh --aid dovecot-1.0.7-7.el5.i386.rpm
warning: dovecot-1.0.7-7.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:dovecot ########################################### [100%]
clip_p_w_picpath072
2 、生成私鑰和自簽名證書
Mail服務器會使用私鑰加密郵件,客戶端在收取郵件時,則使用Mail服務器證書中的公鑰對郵件進行解密,這樣才能正常讀取郵件哈~, /etc/pki/tls/certs/Makefile文件保存着生成密鑰和證書的腳本設置,這裏使用make命令製做 dovecot.pem文件,其保存郵件服務器的私鑰和公鑰信息。
make -C /etc/pki/tls/certs/ dovecot.pem
生成證書時,按要求依次填寫國家、省份、城市等等信息
[root@dns Server]# make -C /etc/pki/tls/certs/ dovecot.pem
make: Entering directory `/etc/pki/tls/certs'
umask 77 ; \
PEM1=`/bin/mktemp /tmp/openssl.XXXXXX` ; \
PEM2=`/bin/mktemp /tmp/openssl.XXXXXX` ; \
/usr/bin/openssl req -newkey rsa:1024 -keyout $PEM1 -nodes -x509 -days 365 -out $PEM2 -set_serial 0 ; \
cat $PEM1 > dovecot.pem ; \
echo "" &gt;&gt; dovecot.pem ; \
cat $PEM2 &gt;&gt; dovecot.pem ; \
rm -f $PEM1 $PEM2
Generating a 1024 bit RSA private key
...................................++++++
.++++++
writing new private key to '/tmp/openssl.DW2402'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [GB]:CN
State or Province Name (full name) [Berkshire]:BeiJing
Locality Name (eg, city) [Newbury]:Chaoyang
Organization Name (eg, company) [My Company Ltd]:zhangsan
Organizational Unit Name (eg, section) []:MIS
Common Name (eg, your name or your server's hostname) []:mail.benet.com
Email Address []:zhangsan.benet.com
make: Leaving directory `/etc/pki/tls/certs'
clip_p_w_picpath074
3 、修改 dovecot.conf 配置文件
1 )、修改 17 行,去掉前面 #
clip_p_w_picpath076
2 )、修改 87-88 行,去掉前面 # ,並修改 88 行內容
clip_p_w_picpath078
3 )、重啓 sendmail dovecot saslauthd 服務
[root@dns Server]# service sendmail restart
關閉 sm-client: [肯定]
關閉 sendmail: [肯定]
啓動 sendmail: [肯定]
啓動 sm-client: [肯定]
[root@dns Server]# service dovecot restart
中止 Dovecot Imap: [失敗]
啓動 Dovecot Imap: [肯定]
[root@dns Server]# service saslauthd restart
中止 saslauthd: [失敗]
啓動 saslauthd: [肯定]
[root@dns Server]# chkconfig --list sendmail
sendmail 0:關閉 1:關閉 2:啓用 3:啓用 4:啓用 5:啓用 6:關閉
[root@dns Server]# chkconfig --list dovecot
dovecot 0:關閉 1:關閉 2:關閉 3:關閉 4:關閉 5:關閉 6:關閉
[root@dns Server]# chkconfig --level 2345 dovecot on
[root@dns Server]# chkconfig --list dovecot
dovecot 0:關閉 1:關閉 2:啓用 3:啓用 4:啓用 5:啓用 6:關閉
[root@dns Server]# chkconfig --list saslauthd
saslauthd 0:關閉 1:關閉 2:關閉 3:關閉 4:關閉 5:關閉 6:關閉
[root@dns Server]# chkconfig --level 2345 saslauthd on
[root@dns Server]# chkconfig --list saslauthd
saslauthd 0:關閉 1:關閉 2:啓用 3:啓用 4:啓用 5:啓用 6:關閉
clip_p_w_picpath080
4 )、查看端口狀態
[root@dns Server]# netstat -tupln
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:2208 0.0.0.0:* LISTEN 1893/hpiod
tcp 0 0 0.0.0.0:998 0.0.0.0:* LISTEN 1664/rpc.statd
tcp 0 0 0.0.0.0:587 0.0.0.0:* LISTEN 2448/sendmail: acce
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1629/portmap
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1938/cupsd
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 2448/sendmail: acce
tcp 0 0 127.0.0.1:2207 0.0.0.0:* LISTEN 1898/python
tcp 0 0 :::993 LISTEN 2479/dovecot
tcp 0 0 :::995 LISTEN 2479/dovecot
tcp 0 0 :::110 LISTEN 2479/dovecot
tcp 0 0 :::143 LISTEN 2479/dovecot
tcp 0 0 :::22 LISTEN 1922/sshd
udp 0 0 0.0.0.0:32768 0.0.0.0:* 2117/avahi-daemon:
udp 0 0 0.0.0.0:992 0.0.0.0:* 1664/rpc.statd
udp 0 0 0.0.0.0:995 0.0.0.0:* 1664/rpc.statd
udp 0 0 0.0.0.0:5353 0.0.0.0:* 2117/avahi-daemon:
udp 0 0 0.0.0.0:111 0.0.0.0:* 1629/portmap
udp 0 0 0.0.0.0:631 0.0.0.0:* 1938/cupsd
udp 0 0 :::32769 2117/avahi-daemon:
udp 0 0 :::5353 2117/avahi-daemon:
[root@dns Server]#
clip_p_w_picpath082
6、測試
1 、服務器狀態
eth1網卡192.168.10.200
clip_p_w_picpath084
clip_p_w_picpath085
2 、客戶端測試
1 )、 192.168.1.0/24 位測試
clip_p_w_picpath086
clip_p_w_picpath087
clip_p_w_picpath089
clip_p_w_picpath091
clip_p_w_picpath093
clip_p_w_picpath095
2 )、 192.168.1.0/24 192.168.10.0/24 網段測試
clip_p_w_picpath097
clip_p_w_picpath099
3 )、小於 20MB 附件測試
clip_p_w_picpath101
clip_p_w_picpath103
4 )、別名郵件測試
clip_p_w_picpath105
clip_p_w_picpath107
clip_p_w_picpath109
5 )、大於 20MB 附件測試
clip_p_w_picpath111
clip_p_w_picpath112
6)、repquota  –a 查看
requota
 
配置文件在附件裏面:
若有不懂的地方,請call我!qq:357714938 mail:hongwish8es@126.com
相關文章
相關標籤/搜索