PostFix簡單配置

PostFix 簡單配置
RHEL5.3 基本網絡配置
1、
1 、RHEL5 U3:如圖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 、nslookup查看
clip_p_w_picpath031
3、Postfix 簡單配置
1 、安裝Postfix
(1)相關軟件包:Postfix
(2)配置文件:/etc/postfix/*
(3)相關的端口: SMTP(25)
(4)系統收到郵件保存在/var/spool/mail/[linux用戶名]
(5)注意:安裝postfix-pflogsumm-2.3.3-2.1.el5_2.i386.rpm以前,須要安裝一下三個perl-Carp-Clan-5.3-1.2.1.noarch.rpm、 perl-Carp-Clan-5.3-1.2.1.noarch.rpm、 perl-Bit-Vector-6.4-2.2.2.1.i386.rpm
[root@dns Server]# ls postfix*
postfix-2.3.3-2.1.el5_2.i386.rpm postfix-pflogsumm-2.3.3-2.1.el5_2.i386.rpm
[root@dns Server]# rpm -ivh --aid postfix-2.3.3-2.1.el5_2.i386.rpm
warning: postfix-2.3.3-2.1.el5_2.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:postfix ########################################### [100%]
[root@dns Server]# rpm -ivh --aid perl-Carp-Clan-5.3-1.2.1.noarch.rpm
warning: perl-Carp-Clan-5.3-1.2.1.noarch.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:perl-Carp-Clan ########################################### [100%]
[root@dns Server]# rpm -ivh --aid perl-Bit-Vector-6.4-2.2.2.1.i386.rpm
warning: perl-Bit-Vector-6.4-2.2.2.1.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:perl-Bit-Vector ########################################### [100%]
[root@dns Server]# rpm -ivh --aid perl-Date-Calc-5.4-1.2.2.1.i386.rpm
warning: perl-Date-Calc-5.4-1.2.2.1.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:perl-Date-Calc ########################################### [100%]
[root@dns Server]# rpm -ivh --aid postfix-pflogsumm-2.3.3-2.1.el5_2.i386.rpm
warning: postfix-pflogsumm-2.3.3-2.1.el5_2.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:postfix-pflogsumm ########################################### [100%]
[root@dns Server]# rpm -qa | grep postfix
postfix-pflogsumm-2.3.3-2.1.el5_2
postfix-2.3.3-2.1.el5_2
clip_p_w_picpath033
2 、關閉sendmail並啓動postfix服務
[root@dns Server]# chkconfig sendmail off
[root@dns Server]# chkconfig --level 2345 sendmail off
[root@dns Server]# chkconfig --list sendmail
sendmail 0:關閉 1:關閉 2:關閉 3:關閉 4:關閉 5:關閉 6:關閉
[root@dns Server]# service sendmail stop
關閉 sm-client: [肯定]
關閉 sendmail: [肯定]
[root@dns Server]# alternatives --config mta
共有 2 個程序提供「mta」。
選擇 命令
-----------------------------------------------
*+ 1 /usr/sbin/sendmail.sendmail
2 /usr/sbin/sendmail.postfix
按 Enter 來保存當前選擇[+],或鍵入選擇號碼: 2
[root@dns Server]# echo "this is a test"|mail -s testmail root
[root@dns Server]# postdrop: warning: unable to look up public/pickup: No such file or directory
[root@dns Server]# chkconfig postfix on
[root@dns Server]# chkconfig --level 2345 postfix on
[root@dns Server]# chkconfig --list postfix
postfix 0:關閉 1:關閉 2:啓用 3:啓用 4:啓用 5:啓用 6:關閉
[root@dns Server]# service postfix restart
關閉 postfix: [失敗]
啓動 postfix: [肯定]
clip_p_w_picpath035
3 、給root發份郵件測試一下Postfix安裝是否成功
[root@dns Server]# echo "this is a test"|mail -s testmail root
[root@dns Server]# mail
Mail version 8.1 6/6/93. Type ? for help.
"/var/spool/mail/root": 3 messages 3 new
>N 1 logwatch@dns.benet.c Mon Sep 21 04:04 112/3524 "Logwatch for dns (Lin"
N 2 root@dns.localdomain Thu Oct 15 14:50 14/445 "testmail"
N 3 root@dns.localdomain Thu Oct 15 14:50 14/445 "testmail"
& 3
Message 3:
From root@dns.localdomain Thu Oct 15 14:50:33 2009
X-Original-To: root
Delivered-To: root@dns.localdomain
To: root@dns.localdomain
Subject: testmail
Date: Thu, 15 Oct 2009 14:50:33 +0800 (CST)
From: root@dns.localdomain (root)
this is a test
& quit
Saved 1 message in mbox
Held 2 messages in /var/spool/mail/root
You have mail in /var/spool/mail/root
clip_p_w_picpath037
4 、查看端口
[root@dns Server]# netstat -ntla
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 127.0.0.1:2208 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:688 0.0.0.0:* LISTEN
tcp 0 0 192.168.1.200:53 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:953 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:2207 0.0.0.0:* LISTEN
tcp 0 0 :::22 :::* LISTEN
tcp 0 0 ::1:953 :::* LISTEN
tcp 0 128 ::ffff:192.168.1.200:22 ::ffff:192.168.1.100:1410 ESTABLISHED
clip_p_w_picpath039
5 、配置postfix
(1) 主配置文件Vim /etc/postfix/main.cf的修改
1) 進入/etc/postfix目錄
[root@dns Server]# cd /etc/postfix/
[root@dns postfix]# ll
總計 296
-rw-r--r-- 1 root root 17832 2008-08-11 access
-rw-r--r-- 1 root root 3550 2008-08-11 bounce.cf.default
-rw-r--r-- 1 root root 11175 2008-08-11 canonical
-rw-r--r-- 1 root root 9920 2008-08-11 generic
-rw-r--r-- 1 root root 16838 2008-08-11 header_checks
-rw-r--r-- 1 root root 11942 2008-08-11 LICENSE
-rw-r--r-- 1 root root 26737 2008-08-11 main.cf
-rw-r--r-- 1 root root 17981 2008-08-11 main.cf.default
-rw-r--r-- 1 root root 958 2008-08-11 makedefs.out
-rw-r--r-- 1 root root 4137 2008-08-11 master.cf
-rw-r--r-- 1 root root 17639 2008-08-11 postfix-files
-rwxr-xr-x 1 root root 6366 2008-08-11 postfix-script
-rwxr-xr-x 1 root root 22564 2008-08-11 post-install
-rw-r--r-- 1 root root 6805 2008-08-11 relocated
-rw-r--r-- 1 root root 1629 2008-08-11 TLS_LICENSE
-rw-r--r-- 1 root root 12081 2008-08-11 transport
-rw-r--r-- 1 root root 11984 2008-08-11 virtual
clip_p_w_picpath040
2) 修改postfix主配置文件 main.cf ,如今咱們要修改配置文件了, 第一和第二個是設置主機名和域名69行和77行(分別爲69行:mail.benet.com 77行benet.com)
clip_p_w_picpath042
3) 修改93行 myorigin = $mydomain //去掉前面的#號
clip_p_w_picpath044
4 )修改107行inet_interfaces=all       //去掉前面的#,設置postfix監聽的接口,這裏使用監聽全部接口。修改110行#inet_interfaces=localhost  //前面加上#
clip_p_w_picpath046
5 )修改155行mydestination=mail.benet.com,benet.com,localhost
//指定postfix接收郵件時收件人的域名全部可能引用的域名或着主機名都寫上。
clip_p_w_picpath048
6) 修改255行192.168.1.0/24 //可轉發哪些網絡的郵件,通常都只轉發信任網絡的郵件
clip_p_w_picpath050
7 )修改287行 relay_domains = $mydomain // 去掉前面的#,防止垃圾郵件的策略
clip_p_w_picpath052
8 )從新啓動Postfix和vim /etc/mail/local-host-names
clip_p_w_picpath053
4、dovecot簡單配置
1)功能:主要提供imap imaps pop3 pop3s服務。其中imaps pop3s是使用SSL來加密驗證和數據安全的服務器
2)端口:110(pop3)  995(pop3s)  143(imap)  993(imaps)
3)相關配置文件:/etc/dovecot.conf
1 、Dovecot安裝(安裝以前先安裝這兩個perl-DBI-1.52-2.el5.i386.rpm、 mysql-5.0.45-7.el5.i386.rpm)
[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_picpath055
2 、修改20行,編輯主配置文件Vim /etc/dovecot.conf(只要打開對imap imaps pop3 pop3s協議的支持就能夠) protocols = imap imaps pop3 pop3s //前面的#去掉
clip_p_w_picpath057
3 、dovecot服務的啓動和查看端口
[root@dns Server]# chkconfig dovecot on
[root@dns Server]# service dovecot restart
中止 Dovecot Imap: [失敗]
啓動 Dovecot Imap: [肯定]
[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]#
[root@dns Server]# netstat -tulnp | grep 25
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 3089/master
[root@dns Server]# netstat -ntla
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 127.0.0.1:2208 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:688 0.0.0.0:* LISTEN
tcp 0 0 192.168.1.200:53 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:953 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:2207 0.0.0.0:* LISTEN
tcp 0 0 :::993 :::* LISTEN
tcp 0 0 :::995 :::* LISTEN
tcp 0 0 :::110 :::* LISTEN
tcp 0 0 :::143 :::* LISTEN
tcp 0 0 :::22 :::* LISTEN
tcp 0 0 ::1:953 :::* LISTEN
tcp 0 0 ::ffff:192.168.1.200:22 ::ffff:192.168.1.100:1662 ESTABLISHED
[root@dns Server]# netstat -an | grep 25
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN
unix 2 [ ACC ] STREAM LISTENING 7325 /tmp/.font-unix/fs7100
unix 3 [ ] STREAM CONNECTED 11325
[root@dns Server]# netstat -an | grep 110
tcp 0 0 :::110 :::* LISTEN
[root@dns Server]# netstat -an | grep 143
tcp 0 0 :::143 LISTEN unix 2 DGRAM 11435
clip_p_w_picpath059
4 、測試相關端口2五、1十、143並添加用戶
[root@dns Server]# telnet mail.benet.com 25
Trying 192.168.1.200...
Connected to mail.benet.com (192.168.1.200).
Escape character is '^]'.
220 dns.localdomain ESMTP Postfix
ehlo mail.benet.com
250-dns.localdomain
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
quit
221 2.0.0 Bye
Connection closed by foreign host.
[root@dns Server]# telnet mail.benet.com 110
Trying 192.168.1.200...
Connected to mail.benet.com (192.168.1.200).
Escape character is '^]'.
+OK Dovecot ready.
quit
+OK Logging out
Connection closed by foreign host.
[root@dns Server]#
[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]#
clip_p_w_picpath060
clip_p_w_picpath062
clip_p_w_picpath064
5 、OE測試
clip_p_w_picpath065
clip_p_w_picpath067
5、實現郵局aliases別名功能:(這個和Sendmail基本相通,都是用/etc/aliases文件)
1 、編輯/etc/aliases:
1)格式:別名: 真實帳戶1,真實帳戶2,……
2)vim /etc/aliases
增長:test:  zhangsan,lisi
當咱們給別名帳戶發送郵件時全部真實帳戶均可以收到,在咱們的例子中,當我給test@benet.com發送郵件時,zhangsan@benet.comlisi@benet.com均可以收到。(在最後一行96行添加test: zhangsan,lisi)
clip_p_w_picpath069
3
、運行newaliases命令,生成aliases庫。
clip_p_w_picpath070
4 、從新啓動postfix服務。
五、經過客戶端測試別名:用戶收到郵件注意時間是否同樣
clip_p_w_picpath071
clip_p_w_picpath073
clip_p_w_picpath075
clip_p_w_picpath077
6、access訪問控制的實現及檢測(基本和sendmail相同)
1 、修改postfix主配置文件vim /etc/postfix/main.cf在最後增長以下內容:(開啓access檢測)
smtpd_clietn_restrictions=check_client_access hash:/etc/postfix/access
clip_p_w_picpath079
2 、vim /etc/postfix/access(在最後一行添加) 咱們禁止192.168.1.100 REJECT 使用postfix郵件服務
clip_p_w_picpath081
3 修改了access後,須要使用這個命令更新數據庫。postmap /etc/postfix/access 而後從新啓動postfix
clip_p_w_picpath083
4 、OE測試
1 )將客戶端的IP改爲192.168.1.100再測試可否發送
clip_p_w_picpath084
clip_p_w_picpath086
2 )去掉限制#192.168.1.100 REJECT就能夠正常發送郵件
clip_p_w_picpath088
clip_p_w_picpath090
clip_p_w_picpath092
 
 
配置文件在附件裏面:
若有不懂的地方,請call我!qq:357714938 mail:hongwish8es@126.com
相關文章
相關標籤/搜索