-->
Page 101
Now, what if someone on a.whizzer.com wants to send mail to joe@gonzo.gov? Ns.whizzer.com has no information about hosts in the gonzo.gov domain, but it knows how to find this information. When a nameserver receives a request for a host in a domain for which it has no information, it asks the root nameservers for the names and IP addresses of servers authoritative for that domainin this case, gonzo.gov. The root nameserver gives the ns.whizzer.com name- server the names and IP addresses of hosts running nameservers with authority for gonzo.gov. The ns.whizzer.com nameserver inquires of them and forwards the reply back to a.whizzer.com.
From the preceding description, you can see that the DNS is a large, distributed database containing mappings between hostnames and IP addresses, but it contains other information as well. When a program like sendmail delivers mail, it must translate the recipient's hostname into an IP address. This bit of DNS data is known as an A (address) record, and it is the most fundamental data about a host. A second piece of host data is the mail exchanger (MX) record. An MX record for a host like a.whizzer.com lists one or more hosts that are willing to receive mail for it.
What's the point? Why shouldn't a.whizzer.com simply receive its own mail and be done with the process? Isn't a postmaster's life complicated enough without having to worry about mail exchangers? Well, although it's true that the postmaster's life is often overly complicated, MX records serve useful purposes:
Page 102
For the full details on configuring DNS for Linux, see Chapter 13.
When an SMTP client delivers mail to a host, it must do more than translate the hostname into an IP address. First, the client asks for MX records. If any exist, it sorts them according to the priority given in the record. For example, whizzer.com might have MX records listing the hosts mailhub.whizzer.com, walrus.whizzer.com, and mailer.gonzo.gov as the hosts willing to receive mail for it (and the "host" whizzer.com might not exist except as an MX record, meaning that no IP address might be available for it). Although any of these hosts will accept mail for whizzer.com, the MX priorities specify which of these hosts the SMTP client should try first, and properly behaved SMTP clients will do so. In this case, the system administrator has set up a primary mail relay mailhub.whizzer.com and an on-site backup walrus.whizzer.com, and has arranged with the system administrator at mailer.gonzo.gov for an off-site backup. The administrators have set the MX priorities so that SMTP clients will try the primary mail relay first, the on-site backup second, and the off-site backup third. This setup takes care of the problems with the vendor who doesn't ship your parts on time as well as the wayward backhoe operator who severs the fiber optic cable that provides your site's Internet connection.
After collecting and sorting the MX records, the SMTP client gathers the IP addresses for the MX hosts and attempts delivery to them in order of MX preference. You should keep this fact in mind when debugging mail problems. Just because a letter is addressed to joe@whizzer.com doesn't necessarily mean that a host named whizzer.com exists. Even if such a host does exist, it might not be the host that is supposed to receive the mail.
The distinction between header and envelope addresses is important because mail routers can process them differently. An example will help explain the difference between the two.
Suppose you have a paper memo that you want to send to your colleagues Mary and Bill at the Gonzo Corporation, and Ted and Ben at the Whizzer company. You give a copy of the memo to your trusty mail clerk Alphonse, who notes the multiple recipients. Because he's a clever fellow who wants to save your company 32 cents, he makes two copies of the memo and puts each in an envelope addressed to the respective companies (instead of sending a copy to each recipient). On the cover of the Gonzo envelope, he writes Mary and Bill, and on the cover of the Whizzer envelope, he writes Ted and Ben. When Alphonse's counterparts at Gonzo and Whizzer receive the envelopes, they make copies of the memo and send them to Mary, Bill,