PostFix简单配置
RHEL5.3 基本网络配置
一、
1、RHEL5 U3:如图1
(如图1)
2、#hostname //查看当前主机的主机名:如图2
(如图2)
3、#vi /etc/sysconfig/network-scripts/ifcfg-eth0 编辑指定网络接口配置文件:如图3
(如图3)
4、#vi /etc/sysconfig/network 通过配置文件修改主机名:如图4
(如图4)
5、在终端字符界面修改其字体和中文字体大小:如图5
(如图5)
6、挂载光盘:如图6
(如图6)
7、查看OpenSSH是否安装:如图7
(如图7)
8、#vi /etc/hosts 设置本地DNS解析文件:如图8
(如图8)
9、#vi /etc/resolv.conf 指定当前主机的DNS服务器,最多可指定三个:如图9
(如图9)
10、关闭iptables防火墙:如图10
(如图10)
二、DNS简单配置
1、vim /etc/named.conf
2、vim /var/named/benet.com.zone
3、vim /var/named/1.168.192.in-addr.arpa.zone
4、nslookup查看
三、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
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: [确定]
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
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
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
2) 修改postfix主配置文件 main.cf ,现在我们要修改配置文件了, 第一和第二个是设置主机名和域名69行和77行(分别为69行:mail.benet.com 77行benet.com)
3) 修改93行 myorigin = $mydomain //去掉前面的#号
4)修改107行inet_interfaces=all //去掉前面的#,设置postfix监听的接口,这里使用监听所有接口。修改110行#inet_interfaces=localhost //前面加上#
5)修改155行mydestination=mail.benet.com,benet.com,localhost
//指定postfix接收邮件时收件人的域名所有可能引用的域名或着主机名都写上。
6)修改255行192.168.1.0/24 //可转发哪些网络的邮件,一般都只转发信任网络的邮件
7)修改287行relay_domains = $mydomain //去掉前面的#,防止垃圾邮件的策略
8)重新启动Postfix和vim /etc/mail/local-host-names
四、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%]
2、修改20行,编辑主配置文件Vim /etc/dovecot.conf(只要打开对imap imaps pop3 pop3s协议的支持就可以) protocols = imap imaps pop3 pop3s //前面的#去掉
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
4、测试相关端口25、110、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]#
5、OE测试
五、实现邮局aliases别名功能:(这个和Sendmail基本相通,都是用/etc/aliases文件)
3、运行newaliases命令,生成aliases库。
4、重新启动postfix服务。
5、通过客户端测试别名:用户收到邮件注意时间是否一样
六、access访问控制的实现及检测(基本和sendmail相同)
1、修改postfix主配置文件vim /etc/postfix/main.cf在最后增加如下内容:(开启access检测)
smtpd_clietn_restrictions=check_client_access hash:/etc/postfix/access
2、vim /etc/postfix/access(在最后一行添加) 我们禁止192.168.1.100 REJECT 使用postfix邮件服务
3、修改了access后,需要使用这个命令更新数据库。postmap /etc/postfix/access 然后重新启动postfix
4、OE测试
1)将客户端的IP改成192.168.1.100再测试能否发送
2)去掉限制#192.168.1.100 REJECT就可以正常发送邮件
配置文件在附件里面:
如有不懂的地方,请call我!qq:357714938 mail:hongwish8es@126.com