Chinaunix首页 | 论坛 | 博客
  • 博客访问: 88132
  • 博文数量: 20
  • 博客积分: 1926
  • 博客等级: 上尉
  • 技术积分: 210
  • 用 户 组: 普通用户
  • 注册时间: 2009-08-16 17:21
文章分类
文章存档

2011年(1)

2009年(19)

分类: LINUX

2009-11-02 00:20:17

SendmailSmarthost功能


Author: Jaylin Zhou

Date: 10/21/2009


一台DNS服务器

三台Sendmail服务器

两台Clients

DNS服务器:server.jaylin.com / server.xin.com

192.168.1.10 / 192.168.2.10

jaylin.comSendmail服务器:mail.jaylin.com

192.168.1.9

xin.comSendmail服务器:mail.xin.com

192.168.2.11

SmarthostSendmail服务器:smarthost.jaylin.com

192.168.1.6

jaylin.com域的客户端:client.jaylin.com

192.168.1.7

xin.com域的客户端:client.xin.com

192.168.2.8

 

DNS服务器的配置

# vi /etc/named.caching-nameserver.conf 

acl jaylin { 192.168.1.0/24; };

acl xin { 192.168.2.0/24; };

options {

        listen-on port 53 { 127.0.0.1; jaylin; xin; };

        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";

        // Those options should be used carefully because they disable port

        // randomization

        // query-source    port 53;

        // query-source-v6 port 53;

        allow-query     { localhost; jaylin; xin; };

};

logging {

        channel default_debug {

                file "data/named.run";

                severity dynamic;

        };

};

view localhost_resolver {

        match-clients      { localhost; jaylin; xin; };

        match-destinations { localhost; jaylin; xin; };

        recursion yes;

        include "/etc/named.rfc1912.zones";

};

 

# vi /etc/named.rfc1912.zones

zone "xin.com" IN {

        type master;

        file "xin.com.zone";

        allow-update { none; };

};

zone "2.168.192.in-addr.arpa" IN {

        type master;

        file "xin.com.local";

        allow-update { none; };

};

zone "jaylin.com" IN {

        type master;

        file "jaylin.com.zone";

        allow-update { none; };

};

zone "1.168.192.in-addr.arpa" IN {

        type master;

        file "jaylin.com.local";

        allow-update { none; };

};

 

# vi xin.com.zone 

$TTL    86400

@               IN SOA  server.xin.com. root@xin.com. (

                                        42              ; serial (d. adams)

                                        3H              ; refresh

                                        15M             ; retry

                                        1W              ; expiry

                                        1D )            ; minimum

                IN NS           server.xin.com.

                IN MX 5         mail.xin.com.

server          IN A            192.168.2.10

mail            IN A            192.168.2.11

client          IN A            192.168.2.8

 

# vi xin.com.local

$TTL    86400

@       IN      SOA    server.xin.com. root@xin.com.  (

                                      1997022700 ; Serial

                                      28800      ; Refresh

                                      14400      ; Retry

                                      3600000    ; Expire

                                      86400 )    ; Minimum

        IN      NS      server.xin.com.

10      IN      PTR     server.xin.com.

11      IN      PTR     mail.xin.com.

 

# vi jaylin.com.zone 

$TTL    86400

@               IN SOA  server.jaylin.com. root@jaylin.com. (

                                        42              ; serial (d. adams)

                                        3H              ; refresh

                                        15M             ; retry

                                        1W              ; expiry

                                        1D )            ; minimum

                IN NS           server.jaylin.com.

                IN MX 5         mail.jaylin.com.

                IN MX 6         smarthost.jaylin.com.

mail            IN A            192.168.1.9

client          IN A            192.168.1.7

smarthost       IN A            192.168.1.6

 

# vi jaylin.com.local 

$TTL    86400

@       IN      SOA    server.jaylin.com. root@jaylin.com.  (

                                      1997022700 ; Serial

                                      28800      ; Refresh

                                      14400      ; Retry

                                      3600000    ; Expire

                                      86400 )    ; Minimum

        IN      NS      server.jaylin.com.

10      IN      PTR     server.jaylin.com.

9       IN      PTR     mail.jaylin.com.

6       IN      PTR     smarthost.jaylin.com.

 

打开ip_forward功能。

 

jaylin.comSendmail服务器的配置

/etc/mail/sendmail.mc文件里修改下面两处地方:

DAEMON_OPTIONS(`Port=smtp,Addr=0.0.0.0, Name=MTA')

define(`SMART_HOST', `smarthost.jaylin.com')

SMART_HOST这个宏,指定了哪台服务器做Smarthost服务器,如果指定的Smarthost服务器和Sendmail服务器不在一个域里,要在Smarthost服务器的域名或IP的两侧加中括号,即:[smarthost.jaylin.com]

 

# vi /etc/mail/access

Connect:localhost.localdomain           RELAY

Connect:localhost                       RELAY

Connect:127.0.0.1                       RELAY

to:xin.com                              RELAY

to:jaylin.com                    OK

 

# vi /etc/mail/local-host-names

mail.jayln.com

jaylin.com

 

# vi /etc/resolv.conf 

nameserver 192.168.1.10

 

# vi /etc/dovecot.conf

protocols = imap imaps pop3 pop3s

 

加一条到192.168.2.0/24网段的路由

# route add -net 192.168.2.0/24 gw 192.168.1.10

 

启动sendmaildovecot服务。

 

xin.comSendmail服务器的配置

/etc/mail/sendmail.mc文件里修改下面两处地方:

DAEMON_OPTIONS(`Port=smtp,Addr=0.0.0.0, Name=MTA')

 

# vi /etc/mail/access

Connect:localhost.localdomain           RELAY

Connect:localhost                       RELAY

Connect:127.0.0.1                       RELAY

to:xin.com                              OK

to:jaylin.com                           RELAY

 

# vi /etc/mail/local-host-names

mail.xin.com

xin.com

 

# vi /etc/resolv.conf 

nameserver 192.168.2.10

 

# vi /etc/dovecot.conf

protocols = imap imaps pop3 pop3s

 

加一条到192.168.1.0/24网段的路由

# route add -net 192.168.1.0/24 gw 192.168.2.10

 

启动sendmaildovecot服务。

 

Smarthost服务器的配置

/etc/mail/sendmail.mc文件里修改下面两处地方:

DAEMON_OPTIONS(`Port=smtp,Addr=0.0.0.0, Name=MTA')

 

# vi /etc/mail/access

Connect:localhost.localdomain           RELAY

Connect:localhost                       RELAY

Connect:127.0.0.1                       RELAY

to:xin.com                              RELAY

Connect:192.168.1                       RELAY

 

# vi /etc/resolv.conf 

nameserver 192.168.1.10

 

加一条到192.168.2.0/24网段的路由

# route add -net 192.168.1.0/24 gw 192.168.2.10

启动sendmail服务。

 

两个客户端需要修改一下/etc/resolv.conf文件。

 

测试环境

client.jaylin.com上发送邮件:

# telnet mail.jaylin.com 25

Trying 192.168.1.9...

Connected to mail.jaylin.com (192.168.1.9).

Escape character is '^]'.

220 mail.jaylin.com ESMTP Sendmail 8.13.8/8.13.8; Wed, 21 Oct 2009 05:12:41 +0800

EHLO mail.jaylin.com

250-mail.jaylin.com Hello [192.168.1.7], pleased to meet you

250-ENHANCEDSTATUSCODES

250-PIPELINING

250-8BITMIME

250-SIZE

250-DSN

250-ETRN

250-DELIVERBY

250 HELP

MAIL FROM:jaylin@jaylin.com

250 2.1.0 jaylin@jaylin.com... Sender ok

RCPT TO:xin@xin.com

250 2.1.5 xin@xin.com... Recipient ok

DATA

354 Enter mail, end with "." on a line by itself

SUBJECT xinxin

lala~

.

250 2.0.0 n9KLCfJo004052 Message accepted for delivery

quit

221 2.0.0 mail.jaylin.com closing connection

Connection closed by foreign host.

client.xin.com上接收邮件:# telnet mail.xin.com 110

Trying 192.168.2.11...

Connected to mail.xin.com (192.168.2.11).

Escape character is '^]'.

+OK Dovecot ready.

User xin

+OK

Pass ******

+OK Logged in.

List

+OK 12 messages:

1 621

2 624

3 619

4 619

5 620

6 841

7 839

8 757

9 738

10 737

11 742

12 740

.

retr 12

+OK 740 octets

Return-Path: 

Received: from smarthost.jaylin.com (smarthost.jaylin.co [192.168.1.6] (may be forged))

        by mail.xin.com (8.13.8/8.13.8) with ESMTP id n9KLDC2H004460

        for ; Wed, 21 Oct 2009 05:13:12 +0800

Received: from mail.jaylin.com (mail.jaylin.com [192.168.1.9])

        by smarthost.jaylin.com (8.13.8/8.13.8) with ESMTP id n9KLD7VC006062

        for ; Wed, 21 Oct 2009 05:13:07 +0800

Received: from mail.jaylin.com ([192.168.1.7])

        by mail.jaylin.com (8.13.8/8.13.8) with ESMTP id n9KLCfJo004052

        for xin@xin.com; Wed, 21 Oct 2009 05:12:54 +0800

Date: Wed, 21 Oct 2009 05:12:41 +0800

From: jaylin@jaylin.com

Message-Id: <200910202112.n9KLCfJo004052@mail.jaylin.com>

SUBJECT xinxin

lala~

.

quit

+OK Logging out.

Connection closed by foreign host.

 

为了验证Smarthost生效了,我们查看一下三台Sendmail服务器的/var/log/maillog日志文件。

发送方mail.jaylin.com

Oct 21 05:13:02 mail sendmail[4052]: n9KLCfJo004052: from=jaylin@jaylin.com, size=21, class=0, nrcpts=1, msgid=<200910202112.n9KLCfJo004052@mail.jaylin.com>, proto=ESMTP, daemon=MTA, relay=[192.168.1.7]

Oct 21 05:13:02 mail sendmail[4054]: n9KLCfJo004052: to=xin@xin.com, ctladdr=jaylin@jaylin.com (501/501), delay=00:00:08, xdelay=00:00:00, mailer=relay, pri=120021, relay=smarthost.jaylin.com [192.168.1.6], dsn=2.0.0, stat=Sent (n9KLD7VC006062 Message accepted for delivery)

作为Smarthostsmarthost.jaylin.com

Oct 21 05:13:07 client1 sendmail[6062]: n9KLD7VC006062: from=, size=304, class=0, nrcpts=1, msgid=<200910202112.n9KLCfJo004052@mail.jaylin.com>, proto=ESMTP, daemon=MTA, relay=mail.jaylin.com [192.168.1.9]

Oct 21 05:13:07 client1 sendmail[6064]: n9KLD7VC006062: to=, delay=00:00:00, xdelay=00:00:00, mailer=esmtp, pri=120304, relay=mail.xin.com. [192.168.2.11], dsn=2.0.0, stat=Sent (n9KLDC2H004460 Message accepted for delivery)

接收方mail.xin.com

Oct 21 05:13:12 mail sendmail[4460]: n9KLDC2H004460: from=, size=489, class=0, nrcpts=1, msgid=<200910202112.n9KLCfJo004052@mail.jaylin.com>, proto=ESMTP, daemon=MTA, relay=smarthost.jaylin.co [192.168.1.6] (may be forged)

Oct 21 05:13:12 mail sendmail[4461]: n9KLDC2H004460: to=, delay=00:00:00, xdelay=00:00:00, mailer=local, pri=30702, dsn=2.0.0, stat=Sent

Oct 21 05:13:35 mail dovecot: pop3-login: Login: user=, method=PLAIN, rip=::ffff:192.168.2.8, lip=::ffff:192.168.2.11

Oct 21 05:13:41 mail dovecot: POP3(xin): Disconnected: Logged out top=0/0, retr=1/756, del=0/12, size=8497

阅读(2751) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~