Sunday, September 20, 2009

SENDMAIL Notes 6: Sendmail with DNS FQDN & MX records


    Remote mail involves the usage of SMTP thus sendmail needs the name resolution to route the mails. For this sendmail uses DNS or uses /etc/hosts.
Find the FQDN of a host

 # hostname -f

    If the FQDN (which can retrieve the ip to query) is used to send the mail, then sendmail bypasses the MX record.

Sendmail DNS Usage:
Using FQDN:
    Sendmail performs the DNS lookup for the defined host address and gets the IP address and then delivers the msg to the destination.Remote hosts either accepts the mail or Routes the mail using any local mailer or Relays to another destination upon the configuration.
For example:

#sendmail -v kiran@mail1.india.mydomain.com

In this above example sendmail will use the 'A' record for the given address. Because the exact address of the mail server is given here for the "domain mydomain.com"

Using MX:
    MX is a special type of DNS record called as Mail Exchanger Record.When mail server actualy query a Domain for direct mail, they query the dns server for the MX record and once found sendmail will attempt to direct the mail to destination according to the priority of MX record.
   
Normally an "A" record is enough to get the IP address of the host for sendmail to send the mail.But MX is used because to distinguish/identify the  mail servers in the given domain
For Example:-

#sendmail -v kiran@mydomain.com

    In this case sendmail has to get the ip address of the mail server for the domain "mydomain.com" to route the mail. So sendmail does a "MX" record query upon the given domain.
(So in nameserver the MX record entry for mail1.india is added to the domain mydomain.com; Make sure that we have a 'A' record created for the same MX record)
    This means any the mail comes to kiran@mydomain.com will be routed to mail1.india.mydomain.com to process with.

Backup MX & Priority in MX:

    mydomain.com.    14000    IN    MX    20    mail2.india.mydomain.com.
    mydomain.com.    14000    IN    MX    10    mail1.india.mydomain.com.

    In this entry in dns with respect to the MX record the host which primarily contacts the server which has priority 10. Incase of unavailable of server which has priority 10 then the MTA will contact the server which has priority 20.
If a backup MX server is running make sure that the user mail box is located in the backup mail server as well.

No comments:

Post a Comment

tag ur valuable ideas below