Chinaunix首页 | 论坛 | 博客
  • 博客访问: 484220
  • 博文数量: 67
  • 博客积分: 2952
  • 博客等级: 少校
  • 技术积分: 679
  • 用 户 组: 普通用户
  • 注册时间: 2006-01-24 10:50
文章分类

全部博文(67)

文章存档

2011年(9)

2010年(36)

2009年(8)

2008年(5)

2007年(5)

2006年(4)

我的朋友

分类:

2010-08-04 15:17:33

    实验室的mail都是通过一台mail relay的server转发出来,可是有个我们自己的域qademo.com没办法转出去,原因是dns里没有该域,sendmail找不到他的mx记录,所以没办法转出去。其实qademo.com是单独的一台mail server。我们最初的想法是给qademo.com架一个dns,配上mx记录,后来发现其实不用这么复杂。

方法一:只需要在hosts文件里加上qademo.com接收的mail server就行了。
/etc/hosts
192.168.111.120    qademo.com

方法二:mailertable
qademo.com    relay:[192.168.111.120]

注:
1.第一列为你要relay的特定domain,当然还可以是其它格式,比如.my.domain, 这表示my.domain下的所有机器。
2.第二列冒号前为relay的协议,可以选择smtp,esmpt,relay等等,他们由sendmail.cf里M开头的行定义。

# grep '^M' sendmail.cf|awk '{print $1}'

Msmtp,
Mesmtp,
Msmtp8,
Mdsmtp,
Mrelay,
Mprocmail,
Mlocal,
Mprog,


3.第二列冒号后面表示relay的地址,中括号表示不再读取dns的MX记录。

+--------------------+
| USING MAILERTABLES |
+--------------------+

To use FEATURE(`mailertable'), you will have to create an external
database containing the routing information for various domains.
For example, a mailertable file in text format might be:

    .my.domain        xnet:%1.my.domain
    uuhost1.my.domain    uucp-new:uuhost1
    .bitnet            smtp:relay.bit.net

This should normally be stored in /etc/mail/mailertable. The actual
database version of the mailertable is built using:

    makemap hash /etc/mail/mailertable < /etc/mail/mailertable

The semantics are simple. Any LHS entry that does not begin with
a dot matches the full host name indicated. LHS entries beginning
with a dot match anything ending with that domain name (including
the leading dot) -- that is, they can be thought of as having a
leading ".+" regular expression pattern for a non-empty sequence of
characters. Matching is done in order of most-to-least qualified
-- for example, even though ".my.domain" is listed first in the
above example, an entry of "uuhost1.my.domain" will match the second
entry since it is more explicit. Note: e-mail to "user@my.domain"

does not match any entry in the above table. You need to have
something like:

    my.domain        esmtp:host.my.domain

The RHS should always be a "mailer:host" pair. The mailer is the
configuration name of a mailer (that is, an M line in the
sendmail.cf file). The "host" will be the hostname passed to
that mailer. In domain-based matches (that is, those with leading
dots) the "%1" may be used to interpolate the wildcarded part of
the host name. For example, the first line above sends everything
addressed to "anything.my.domain" to that same host name, but using
the (presumably experimental) xnet mailer.

In some cases you may want to temporarily turn off MX records,
particularly on gateways. For example, you may want to MX
everything in a domain to one machine that then forwards it
directly. To do this, you might use the DNS configuration:

    *.domain.    IN    MX    0    relay.machine

and on relay.machine use the mailertable:

    .domain        smtp:[gateway.domain]

The [square brackets] turn off MX records for this host only.
If you didn'
t do this, the mailertable would use the MX record
again, which would give you an MX loop. Note that the use of
wildcard MX records is almost always a bad idea. Please avoid
using them if possible.



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