1.安装所需要的包
/etc/init.d/sendmail stop(避免端口被占用,最好是把此包给卸了)
yum install
bind*(dns所需要的包)
Yum install dovecot*(POP3邮件接收时所需要的包)
Yum install postfix-pflogsumm-2.3.3-2(安装邮件服务器所需的包)
Yum install
cach*(dns模板的包,其主要的作用是帮你生成一些DNS所需要的配置文件,但如果你可以上网的话,这个包就不用装了,直接可以从网上更行配置文件)
2.配置DNS服务器
a, cd /var/named/chroot/etc/(注意这里的配置文件不是
named.conf 而是named.caching-nameserver.conf )
b,把上面的这个配置文件改成named.conf
mv named.caching-nameserver.conf named.conf
c.编辑配置文件
//
//
named.caching-nameserver.conf
//
// Provided by Red
Hat caching-nameserver package to configure the
// ISC BIND named(8)
DNS server as a caching only nameserver
// (as a localhost
DNS resolver only).
//
// See
/usr/share/doc/bind*/sample/ for example named configuration files.
//
// DO NOT EDIT THIS
FILE - use system-config-bind or an editor
// to create
named.conf - edits to this file will be lost on
// caching-nameserver
package upgrade.
//
options {
listen-on port 53 { 127.0.0.1; };
listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file
"/var/named/data/cache_dump.db";
statistics-file
"/var/named/data/named_stats.txt";
memstatistics-file
"/var/named/data/named_mem_stats.txt";
query-source port 53;
query-source-v6 port 53;
allow-query { localhost; };
};
logging {
channel default_debug {
file
"data/named.run";
severity dynamic;
};
};
view
localhost_resolver {
match-clients { localhost; };
match-destinations { localhost; };
recursion yes;
include
"/etc/named.rfc1912.zones";
};
以上是没配置前的
options {
listen-on port 53 {
10.1.1.151; };(本机的ip)
listen-on-v6 port 53 { ::1; };
directory "/var/named";(指定dns读取数据文件的位置)
dump-file
"/var/named/data/cache_dump.db";(缓存文件存放的位置)
statistics-file
"/var/named/data/named_stats.txt";(dns的统计文件)
memstatistics-file
"/var/named/data/named_mem_stats.txt";
query-source port 53;
query-source-v6 port 53;
allow-query { any; };(允许谁来访问。any就是表示任何人都可以来访问)
};
zone "bobo.com." IN {(其中 bobo.com是你自己定义的域名)
type master;
file
"dns.bobo.com";(域名的数据文件,此文件放在 /etc/named/ ,特别注意在此目录下要创建一个以
file内的内容命名的文件,文件内容参照第3步)
};
include
"/etc/rndc.key";
以上是改变后的
3.配置dns解析的数据文件
a.进入dns数据文件的目录
cd /var/named/
b.创建一个数据文件
vi dns.bobo.com(此处的文件明就是file中所指定的,请参照第二步)
$TTL 1
@ IN
SOA ns.bobo.com. root.ns.bobo.com (
2008102102;serval
28800;refresh
14400;retry
3600000;exprie
86400) ;minimum,seconds;
IN NS
ns.bobo.com.
ns IN A
10.1.1.151
www IN A
10.1.1.151
mail IN A
10.1.1.151
MX 10
mail.bobo.com.
4.配置邮件服务器
a.进入配置文件所在的目录
cd /etc/postfix/
b.修改配置文件
vi
main.cf
queue_directory =
/var/spool/postfix
command_directory =
/usr/sbin
daemon_directory =
/usr/libexec/postfix
mail_owner = postfix
myhostname = mail.bobo.com(设置邮件服务器的主机名)
mydomain = bobo.com
myorigin = $mydomain
inet_interfaces
= all(设置postfix服务监听的端口)
mydestination =
$mydomain
unknown_local_recipient_reject_code
= 550
mynetworks = 10.1.1.0/24(设置允许访问的网段)
relay_domains =
$mydomain
5.修改接受邮件的配置文件
a.进入配置文件所在的目录
cd
/etc
b.修改配置文件
vi dovecot.conf
# specify different
ports for IMAP/POP3. For example:
protocol imap {
listen = *
# ssl_listen = *
# ..
}
protocol pop3 {
listen = *
# ..
}
#listen = [::]
protocols =
imap imaps pop3 pop3s
protocol imap {
listen = *
}
protocol pop3 {
listen = *
}
6.修改本机的hosts文件
vi
/etc/hosts
在里面插入以下内容
10.1.1.151 ns
ns.bobo.com
7.重启服务
a
[root@lb etc]# /etc/init.d/named restart(重启dns服务)
停止 named:[确定]
启动 named:[确定]
b
[root@lb etc]#
/etc/init.d/postfix restart(重启邮件服务)
关闭 postfix:[确定]
启动 postfix: [确定]
c
[root@lb etc]#
/etc/init.d/dovecot restart(重启接受邮件的服务)
停止 Dovecot Imap:[确定]
启动 Dovecot Imap:[确定]
以下是邮件服务器配置文件的各项次数详解
配置postfix,其配置文件及相关的解释如下:
command_directory =
/usr/sbin
daemon_directory =
/usr/libexec/postfix
mail_spool_directory
= /var/spool/mail
#设置邮件及邮件队列的所有者为postfix
mail_owner = postfix
#设置邮件服务器的主机名
myhostname =
mail.some.com
#设置mydomain、myorigin和mydomain参数
mydomain = some.com
myorigin =$mydomain
mydestination =
$mydomain
#设置postfix服务监听的端口
inet_interfaces = all
#设置本地收件人的用户名查询手段,缺省是查询/etc/passwd文件
#和别名数据库
local_recipient_maps
= $alias_maps unix:passwd.byname
alias_maps =
hash:/etc/aliases
alias_database =
hash:/etc/aliases
#设置最终的本地投递代理程序,在这里我们使用流行的procmail
mailbox_command =
/usr/bin/procmail
#设置该值为$mydomain以便客户端的连接
relay_domains =
$mydomain
mynetworks =
202.200.180.0/24
#设置向用户显示的主机名和版本信息
smtpd_banner =
$myhostname ESMTP $mail_name
#对于并发进程的限制,保持系统缺省值就可以满足要求了。
local_destination_concurrency_limit
= 2
default_destination_concurrency_limit
= 10
#如果你不知道你在做什么,最好不要改变下面的设置
debug_peer_level = 2
debugger_command =
PATH=/usr/bin:/usr/X11R6/bin
xxgdb $daemon_directory/$process_name
$process_id & sleep 5
例子:
queue_directory =
/var/spool/postfix
command_directory =
/usr/sbin
daemon_directory =
/usr/libexec/postfix
mail_owner = postfix
myhostname =
mail.phpbj.com
mydomain = phpbj.com
myorigin = $mydomain
inet_interfaces = all
mydestination =
$mydomain
local_recipient_maps
= unix:passwd.byname $alias_maps
unknown_local_recipient_reject_code
= 550
mynetworks =
10.1.1.0/24
relay_domains =
$mydomain
alias_maps =
hash:/etc/aliases
alias_database =
hash:/etc/aliases
mail_spool_directory
= /var/spool/mail
mailbox_command =
/usr/bin/procmail
smtpd_banner =
$myhostname ESMTP $mail_name
debug_peer_level = 2
debugger_command =
PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
xxgdb $daemon_directory/$process_name
$process_id & sleep 5
sendmail_path =
/usr/sbin/sendmail.postfix
newaliases_path =
/usr/bin/newaliases.postfix
mailq_path =
/usr/bin/mailq.postfix
setgid_group =
postdrop
html_directory = no
manpage_directory =
/usr/share/man
sample_directory =
/usr/share/doc/postfix-2.3.3/samples
readme_directory =
/usr/share/doc/postfix-2.3.3/README_FILES
注意:紫色部分为dns主机定义区,红色部分为邮件服务器定义区
其中*表示监听所有的ip