Networking / Beginners

Mail Servers

The computer that people use for daily work is usually not the same system used for receiving email. Instead, domains usually provide centralized mail servers. Email is sent to a central mail server and then retrieved by individual users. If email is sent to user@workstation.domain then it could be directed to user@mail.domain instead.

Network addresses and hostnames do not provide the necessary routing information for identifying the correct mail server. Instead, DNS is used to provide mail server information. Just as DNS associates hostnames with network addresses, it also associates mail exchange server with network addresses, subnets, hostnames, and domains. This is done through the use of DNS mail exchange (MX) records. Each MX record specifies the hostname (or network address) of a mail server. Each mail server either knows how to deliver the email, or it knows how to forward the email.

Multiple MX records can be associated with a host. This provides redundancy for delivery in case one route is unavailable. To prioritize mailer routes, each MX record includes a priority. The MX priority is similar to the metric used in routing tables: lower-priority values should be tried first, and two MX records with the same priority are considered equivalent routes. MX information can be retrieved using host, nslookup, or dig. For example, host -t MX gmail.com retrieves the list of MX records for Google's Gmail service.

Using DNS for hosting MX records leads to many risks. A misconfigured (or intentionally compromised) DNS server can redirect email to alternate mail servers.

Additional Data

DNS is a viable option for associating any type of meta-information with hostnames or IP addresses. Besides MX records, DNS information may contain:

HINFO: The HINFO record provides text-based host information. Some domains use this to include company descriptions, computer make and models, or contact information.
NS: This field specifies the authoritative name server for hostname resolutions. Different hosts may have different NS records.
TXT: This is a generic text field associated with a particular host. The contents are arbitrary but usually limited to printable ASCII characters.

Although the DNS header supports 65,536 different types of associated information, only a few dozen are defined. Some DNS proposals have opted to overload existing types rather than define new types. Examples include SPF, DK, and OzymanDNS.

Types of DNS Associated Data from RFC883

enum TYPE
  {
  TYPE_A=1, /* host address */
  TYPE_NS, /* authoritative name server */
  TYPE_MD, /* mail destination (Obsolete - use MX) */
  TYPE_MF, /* mail forwarder (Obsolete - use MX) */
  TYPE_CNAME, /* canonical name for an alias */
  TYPE_SOA, /* start of a zone of authority */
  TYPE_MB, /* mailbox domain name (EXPERIMENTAL) */
  TYPE_MG, /* mail group member (EXPERIMENTAL) */
  TYPE_MR, /* mail rename domain name (EXPERIMENTAL) */
  TYPE_NULL, /* a NULL RR (EXPERIMENTAL) */
  TYPE_WKS, /* well known service description */
  TYPE_PTR, /* domain name pointer */
  TYPE_HINFO, /* host information */
  TYPE_MINFO, /* mailbox or mail list information */
  TYPE_MX, /* mail exchange */
  TYPE_TXT, /* text strings */
  TYPE_AAAA=0x1c, /* IPv6 address request - RFC1886 */
  /** QTYPE are a superset of TYPE **/
  QTYPE_AXFR=252, /* request for a transfer of an entire zone */
  QTYPE_MAILB=253, /* request for mailbox records (MB/MG/MR) */
  QTYPE_MAILA=254, /* request for mail agents (Obsolete by MX) */
  QTYPE_ALL=255 /* request for all records (symbol "*") */
  };
typedef enum TYPE TYPE;
[Previous] [Contents] [Next]