全部博文(80)
分类: LINUX
2012-03-24 14:20:54
zone "." IN {
zone "example.com" IN {
type master;配置域名正向解析文件
cp /var/named/named.localhost /var/named/example.com.zone -p
chown named.namd /var/namd/example.com.zone
vim /var/named/example.com.zone
$TTL 1D
@ IN SOA @ root. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS @
A 192.168.0.44
server5 A 192.168.0.5
mail CNAME server5
server6 A 192.168.0.6
client CNAME server6
server7 A 192.168.0.7
smtp CNAME server7
example.com. IN MX 10 mail.example.com.
~
example.com的DNS的MX记录必须指向邮件服务器mail.example.com
****注意域后面的点****
启动DNS server
/etc/init.d/named start
若有没有报任何错,则文件无语法错误,可以用dig进行测试,若dig成功的解析出ip,dns配置成功
开始邮件服务器的搭建
mail server在192.168.0.5主机上配置
postfix ----> 邮件传输代理软件
安装接受邮件的软件dovecot,yum install dovecot postfix -y
postconf -e inet_interfaces = all
postconf -e mydestination = example.com
postconf -e myorigin = example.com
postconf -e relayhost = stmp.example.com
}重启服务
/etc/init.d/postfix restart
/etc/init.d/dovecot restart
mydestination指定mail server接收的邮件的域,必须是以***@example.com结尾的邮件接收,其余的全部拒绝接收(注意红的字体部分的域)
编辑/etc/postfix/main.cf文件通过postconf -e ##=$$,$$部分指定的内容将会覆盖或是改变文件里面##原有的内容
编辑文件/etc/postfix/main.cf
postconf -e inet_interfaces = localhost
postconf -e myorigin = example.com
postconf -e “local_transport = error:local delivery disabled ”
postconf -e relayhost = smtp.example.com
重启服务 /etc/init.d/postfix restart
smtp server在192.168.0.7主机上配置
yum install postfix -y
编辑文件/etc/postfix/main.cf
postconf -e inet_interfaces = all
postconf -e myorigin = example.com
postconf -e “local_transport = error:local delivery disabled”
重启服务 /etc/inti.d/postfix restart
开始收发邮件的测试
在client(server6)主机发送邮件,假设mail server有一个hazeline用户
client发送邮件:mail hazeline
[root@client ~]# mail hazeline
Subject: hello
helloworld
helloworld
EOT ----> ctrl+d
root@server6 ~]# tail /var/log/maillog
Mar 23 23:51:38 server6 postfix/pickup[2338]: 7FA85424D2: uid=0 from=
Mar 23 23:51:38 server6 postfix/cleanup[2377]: 7FA85424D2: messageid=<20120323155138.7FA85424D2@server6.example.com>
Mar 23 23:51:38 server6 postfix/qmgr[2069]: 7FA85424D2: from=
Mar 23 23:51:48 server6 postfix/smtp[2380]: 7FA85424D2: to=
Mar 23 23:51:48 server6 postfix/qmgr[2069]: 7FA85424D2: removed
在mail server(server5)
查收hazeline的邮件
[root@server5 ~]# cat /var/spool/mail/hazeline
From root@example.com Wed Mar 21 05:42:01 2012
Return-Path:
X-Original-To: hazeline@example.com
Delivered-To: hazeline@example.com
Received: from server7.example.com (unknown [192.168.0.7])
by server5.example.com (Postfix) with ESMTP id 30C2241CD5
for
Received: from server6.example.com (unknown [192.168.0.6])
by server7.example.com (Postfix) with ESMTP id 27CE8402C9
for
Received: by server6.example.com (Postfix, from userid 0)
id D087E424D2; Fri, 23 Mar 2012 23:42:03 +0800 (CST)
Date: Fri, 23 Mar 2012 23:42:03 +0800
To: ----> 接收邮件的用户
Subject: hello ----> 邮件标题
User-Agent: Heirloom mailx 12.4 7/29/08
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Message-Id: <20120323154203.D087E424D2@server6.example.com>
From: root@example.com (root)
helloworld
helloworld ----> 邮件内容
....GOOD LUCK!