21.3 Set Up MX RecordsAn MX record is simply the method used by DNS to route mail bound for one machine to another instead. An MX record is created by a single line in one of your named (8) files:
hostA IN MX 10 hostB
This line says that all mail destined for
An MX record may point to another host or to the original host:
hostA IN MX 0 hostA
This line says that mail for A host can have multiple MX records (one pointing to itself or not):
hostA IN MX 0 hostA IN MX 10 hostB
Here, Usually, MX records point to hosts inside the same domain. Therefore managing them does not require the cooperation of others. But it is legal for MX records to point to hosts in different domains:
hostA IN MX 0 hostA IN MX 10 host.other.domain.
Here, you must contact the administrator at Although MX records are usually straightforward, there can be a few problems associated with them. 21.3.1 MX Must Point to an A RecordThe A record for a host is a line that gives the host's IP address.
hostC IN A 123.45.67.8
Here, An MX record must point to a hostname that has an A record. To illustrate, consider the following:
hostA IN MX 10 hostB illegal IN MX 20 hostC hostB IN MX 10 hostC hostC IN A 123.45.67.8
Note that Although such a mistake is difficult to make when maintaining your own domain tables, it can easily happen to you if you rely on a name server in someone else's domain, as shown:
hostA IN MX 10 mail.other.domain.
The other administrator might, for example, retire the machine
21.3.2 MX to CNAME Causes Extra LookupsThe sendmail program is frequently more forgiving than other MTAs because it accepts an MX record that points to a CNAME record. The presumption is that, eventually, the CNAME will correctly point to an A record. But beware, this kind of indirection can cost additional DNS lookups. Consider this example of an exceptionally bad setup:
hostA IN MX 10 mailhub mailhub IN CNAME nfsmast nfsmast IN CNAME hostB hostB IN A 123.45.67.89
First,
sendmail
looks up The correct way to form the above DNS file entries is as follows:
hostA IN MX 10 hostB mailhub IN CNAME hostB nfsmast IN CNAME hostB hostB IN A 123.45.67.89 In general, try to construct DNS records in such a way that the fewest lookups are required to resolve any A or MX records. 21.3.3 MX Records Are Nonrecursive
Consider the following MX setup, which causes all mail for
hostA IN MX 10 hostB hostB IN MX 10 hostB IN MX 20 hostC
One might expect
sendmail
to be smart and deliver mail
for
hostA IN MX 10 hostB hostB IN MX 10 hostB IN MX 20 hostC hostC IN MX 10 hostA potential loop
If your intention is to have
hostA IN MX 10 hostB IN MX 20 hostC hostB IN MX 10 hostB IN MX 20 hostC
Another reason
sendmail
refuses to follow MX records beyond
the target host is that costs in such a situation are undefined.
Consider the example with the potential loop above. What is the cost
of 21.3.4 Wildcard MX RecordsWildcard MX records provide a shorthand for MX'ing many hosts with a single MX record:
*.dc.gov. IN MX 10 hostB
This says that any host in the domain
; domain is .dc.gov *.dc.gov. IN MX 10 hostB hostA IN MX 10 hostC hostB IN A 123.45.67.8
Here, mail to Care must be exercised in setting up wildcard MX records. It is easy to create ambiguous situations that DNS may not be be able to handle correctly. Consider the following, for example:
; domain is sub.dc.gov *.dc.gov. IN MX 10 hostB.dc.gov. *.sub.dc.gov. IN MX 10 hostC.dc.gov.
Here, an unqualified name such as just plain One compelling weakness of wildcard MX records is that they match any hostname at all, even for machines that don't exist:
; domain is sub.dc.gov *.dc.gov. IN MX 10 hostB.dc.gov.
Here, mail to
foo.dc.gov
will be forwarded to Wildcard MX records almost never have any appropriate use on the Internet. They are often misunderstood and are often used just to save the effort of typing hundreds of MX records. They do, however, have legitimate uses behind firewall machines and on non-Internet networks. 21.3.5 What? They Ignore MX Records?Many older MTAs on the network ignore MX records, and some Sun sites wrongly run the non-MX version of sendmail (that is, they should use /usr/lib/sendmail.mx ). Because of this, you will occasionally find some sites that insist on sending mail to a host even though that host has been explicitly MX'd to another. To illustrate why this is bad, consider a UUCP host that has only an MX record. It has no A record because it is not on the network:
uuhost IN MX 10 uucpserver
Here, mail to If you believe in DNS and disdain sites that don't, you can simply ignore the offending sites. In this case the mail will fail if your MX'd host doesn't run a sendmail daemon (or another MTA). This is not as nasty as it sounds. There is actually considerable support for this approach; failure to obey MX records is a clear violation of published network protocols. RFC1123, Host Requirements , section 5.3.5, notes that obeying MX records is mandatory. On the other hand, if you want to ensure that all mail is received, even on a workstation whose mail is MX'd elsewhere, you can run the sendmail daemon on every machine. 21.3.6 Caching MX RecordsAlthough you are not required to have MX records for all hosts, there is good reason to consider doing so. To illustrate, consider the following host that only has an A record:
hostB IN A 123.45.67.8 When sendmail first looks up this host, it asks the local name server for all records. Because there is only an A record, that is all it gets. But note that asking for all records caused the local name server to cache the information. The next time sendmail looks up this same host, the local name server will return the A record from its cache. This is faster and reduces Internet traffic. The cached information is "nonauthoritative" (because it is a copy) and includes no MX records (because there are none). When sendmail gets a nonauthoritative reply that lacks MX records, it is forced to do another DNS lookup. This time, it specifically asks for MX records. In this case there are none, so it gets none.
Because We strongly recommend that every host on the Internet have at least one MX record. As a minimum, it can simply point to itself with a 0 cost:
hostB IN A 123.45.67.8 IN MX 0 hostB
This will not change how mail is routed to 21.3.7 Ambiguous MX RecordsRFC974 leaves the treatment of ambiguous MX records to the implementor's discretion. This has generated much debate in sendmail circles. Consider the following:
foo IN MX 10 hostA foo IN MX 20 hostB mail from hostB to foo foo IN MX 30 hostC
When mail is sent from a host (
It is possible to configure
But what should happen if
no hostA foo IN MX 20 hostB mail from hostB to foo foo IN MX 30 hostC
Again, RFC974 says that when mail is being sent from a host (
This situation is not an idle exercise. Consider the MX record for
uuhost IN MX 10 uucpserver
Here, |
|