文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>Sendmail的Smarthost功能

Sendmail的Smarthost功能

时间:2010-07-24  来源:linscora

一台DNS服务器

三台Sendmail服务器

两台Clients

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

192.168.1.10 / 192.168.2.10

jaylin.com的Sendmail服务器:mail.jaylin.com

192.168.1.9

xin.com的Sendmail服务器:mail.xin.com

192.168.2.11

做Smarthost的Sendmail服务器: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. [email protected]. (

                                        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. [email protected].  (

                                      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. [email protected]. (

                                        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. [email protected].  (

                                      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.com的Sendmail服务器的配置

在/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

 

启动sendmail和dovecot服务。

 

xin.com的Sendmail服务器的配置

在/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

 

启动sendmail和dovecot服务。

 

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:[email protected]

250 2.1.0 [email protected]... Sender ok

RCPT TO:[email protected]

250 2.1.5 [email protected]... 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: <[email protected]>

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 <[email protected]>; 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 <[email protected]>; 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 [email protected]; Wed, 21 Oct 2009 05:12:54 +0800

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

From: [email protected]

Message-Id: <[email protected]>

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: [email protected], size=21, class=0, nrcpts=1, msgid=<[email protected]>, proto=ESMTP, daemon=MTA, relay=[192.168.1.7]

Oct 21 05:13:02 mail sendmail[4054]: n9KLCfJo004052: [email protected][email protected] (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)

作为Smarthost的smarthost.jaylin.com:

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

Oct 21 05:13:07 client1 sendmail[6064]: n9KLD7VC006062: to=<[email protected]>, 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=<[email protected]>, size=489, class=0, nrcpts=1, msgid=<[email protected]>, 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=<[email protected]>, 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=<xin>, 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

相关阅读 更多 +
排行榜 更多 +
无限Fps

无限Fps

飞行射击 下载
幸存者时间僵尸

幸存者时间僵尸

飞行射击 下载
金属兄弟Metal Brother

金属兄弟Metal Brother

冒险解谜 下载