domain-name-system – MX记录,更好地设置负载平衡和故障转移

前端之家收集整理的这篇文章主要介绍了domain-name-system – MX记录,更好地设置负载平衡和故障转移前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
以域example.com为例,它有两个邮件服务器mail1.example.com和mail2.example.com,两者都已配置,通常我会使用以下设置:
example.com.           1200    IN      MX      10 mail1.example.com.
example.com.           1200    IN      MX      10 mail2.example.com.
mail1.example.com.     1200    IN      A       172.16.10.1
mail2.example.com.     1200    IN      A       172.16.10.2

一位同事建议如下设置:

example.com.           1200    IN      MX      10 mail.example.com.
mail.example.com.      1200    IN      A       172.16.10.1
mail.example.com.      1200    IN      A       172.16.10.2

mail1.example.com.     1200    IN      A       172.16.10.1
mail2.example.com.     1200    IN      A       172.16.10.2

一个新的主机名有两个指向两个服务器的A记录,因为他声称某些客户端没有正确地执行具有相同优先级MX的循环,它应该是合法的设置,但它是否仍然正确支持故障转移,例如172.16.10.1失败,是172.16.10.2正在尝试交付?
或者更好的设置如下:

example.com.           1200    IN      MX      10 mail.example.com.
example.com.           1200    IN      MX      20 mail1.example.com.
example.com.           1200    IN      MX      20 mail2.example.com.
mail.example.com.      1200    IN      A       172.16.10.1
mail.example.com.      1200    IN      A       172.16.10.2

mail1.example.com.     1200    IN      A       172.16.10.1
mail2.example.com.     1200    IN      A       172.16.10.2

谢谢.

解决方法

指定MTA应如何处理MX记录的RFC是 RFC974,RFC1123 section 5.3.4,RFC2821 section 5RFC5321 section 5.

RFC974 status is now HISTORIC.根据它,预计MTA将查询与域相关联的MX记录列表,并“鼓励”按优先级升序尝试所有(或固定数量)SMTP服务器.如果有多个MX记录具有相同的首选项值,则MTA必须尝试将邮件传递到所有SMTP服务器,直到成功为止.尝试的顺序是MTA的选择,也就是说,RFC不会规定是否必须随机或按DNS服务器给出的顺序联系SMTP服务器.此外,RFC不规定如何处理引用多个A记录的MX寄存器.

(...) If the list of MX RRs is not empty,the mailer should try to deliver
the message to the MXs in order (lowest preference value tried
first). The mailer is required to attempt delivery to the lowest
valued MX. Implementors are encouraged to write mailers so that they
try the MXs in order until one of the MXs accepts the message,or all
the MXs have been tried. A somewhat less demanding system,in which
a fixed number of MXs is tried,is also reasonable. Note that
multiple MXs may have the same preference value. In this case,all
MXs at with a given value must be tried before any of a higher value
are tried. In addition,in the special case in which there are
several MXs with the lowest preference value,all of them should be
tried before a message is deemed undeliverable. (...)

RFC1123 status is INTERNET STANDARD.第5.3.4节旨在“细化”有关如何处理MX记录的RFC974程序.它现在要求MTA以优先级升序尝试所有SMTP服务器,直到成功为止.但是,它仍然允许对尝试次数进行可配置的限制.如果有多个具有相同优先级值的MX记录,则RFC建议(并且不要求)MTA随机选择一个记录.但是,如果MX记录引用多个A记录(IPv4地址),则RFC要求MTA按照DNS服务器给出的顺序联系所有这些地址,直到成功为止.

(...) When it succeeds,the mapping can result in a list of
alternative delivery addresses rather than a single address,because of (a) multiple MX records,(b) multihoming,or both.
To provide reliable mail transmission,the sender-SMTP MUST be
able to try (and retry) each of the addresses in this list in
order,until a delivery attempt succeeds. However,there MAY
also be a configurable limit on the number of alternate
addresses that can be tried. In any case,a host SHOULD try at
least two addresses.

The following information is to be used to rank the host
addresses:

(1) Multiple MX Records -- these contain a preference
indication that should be used in sorting. If there are
multiple destinations with the same preference and there
is no clear reason to favor one (e.g.,by address
preference),then the sender-SMTP SHOULD pick one at
random to spread the load across multiple mail exchanges
for a specific organization; note that this is a
refinement of the procedure in [DNS:3].

(2) Multihomed host -- The destination host (perhaps taken
from the preferred MX record) may be multihomed,in which
case the domain name resolver will return a list of
alternative IP addresses. It is the responsibility of the
domain name resolver interface (see Section 6.1.3.4 below)
to have ordered this list by decreasing preference,and
SMTP MUST try them in the order presented.

(...)

[DNS:3] "Mail Routing and the Domain System," C. Partridge,RFC-974,January 1986.

RFC2821 status is PROPOSED STANDARD.此RFC废弃RFC974,并且在MX记录处理范围内,它与RFC1123略有不同.虽然前者需要在具有相同优先级值的多个MX记录中随机选择一个SMTP服务器,但后者只需重新推荐它.

(...) Multiple MX records contain a preference indication that MUST be used
in sorting (see below). Lower numbers are more preferred than higher
ones. If there are multiple destinations with the same preference
and there is no clear reason to favor one (e.g.,by recognition of an
easily-reached address),then the sender-SMTP MUST randomize them to
spread the load across multiple mail exchangers for a specific
organization.

The destination host (perhaps taken from the preferred MX record) may
be multihomed,in which case the domain name resolver will return a
list of alternative IP addresses. It is the responsibility of the
domain name resolver interface to have ordered this list by
decreasing preference if necessary,and SMTP MUST try them in the
order presented. (...)

RFC5321 status is DRAFT STANDARD.此RFC废弃RFC2821,并且在DNS解析的上下文中,它基本上重写了相同的服务器查找过程,并提供了一个新的部分,略微讨论了引用IPv6地址的MX记录的处理.

(...) When a domain name associated with an MX RR is looked up and the
associated data field obtained,the data field of that response MUST
contain a domain name. That domain name,when queried,MUST return
at least one address record (e.g.,A or AAAA RR) that gives the IP
address of the SMTP server to which the message should be directed.

(...) When the lookup succeeds,because
of multiple MX records,multihoming,or both. To provide reliable
mail transmission,the SMTP client MUST be able to try (and retry)
each of the relevant addresses in this list in order,until a
delivery attempt succeeds.

(...)  MX records contain a preference indication that MUST be used in
sorting if more than one such record appears (see below). Lower
numbers are more preferred than higher ones. If there are multiple
destinations with the same preference and there is no clear reason to
favor one (e.g.,by recognition of an easily reached address),then
the sender-SMTP MUST randomize them to spread the load across
multiple mail exchangers for a specific organization.

The destination host (perhaps taken from the preferred MX record) may
be multihomed,and the SMTP sender MUST try them
in the order presented. (...)

我想现代邮件传输代理至少遵循RFC2821或RFC5321程序,因此所有三个DNS设置都提供故障转移功能.但是,只有第一个设置可以提供更好的负载平衡.如果尝试第二次或第三次设置,则必须确保DNS服务器以随机顺序提供响应.此外,DNS记录可能由MTA本身或递归DNS服务器缓存,因此无法保证随机性.我认为mail1.example.com将收到大部分消息.

指导我对第二和第三设置的意见的另一个原因是多个名称引用到一个IP地址.互联网中的邮件服务器通常拒绝来自映射IP地址=>的主机的消息. PTR => hostname => A => IP地址不匹配(Postfix限制reject_unknown_client_hostname也是如此),因此您必须特别注意设置PTR记录.

不按随机顺序尝试MX记录的客户端已经违反了RFC2821和RFC5321标准.所以,我认为不能保证这些客户端也会自动尝试辅助IP地址.因此,我更喜欢最简单的DNS配置:

example.com.           1200    IN      MX      10 mail1.example.com.
example.com.           1200    IN      MX      10 mail2.example.com.
mail1.example.com.     1200    IN      A       172.16.10.1
mail2.example.com.     1200    IN      A       172.16.10.2

编辑:添加了对RFC1123的引用.

原文链接:https://www.f2er.com/html/229579.html

猜你在找的HTML相关文章