Add MX Record in Windows DNS Server

Spread the love




MX record is a special type of DNS record that serves for the sole purpose of email communication. MX itself stands for Mail Exchanger and is a prerequisite when configuring email server. In other words, if your organization hosts an email server, then your DNS server should have MX record pointing to that email server. Without MX record, your email server is basically unrecognized by the others and there’s no way for them to be able to email you. In this post, we’re going to cover about how to Add MX Record in Windows DNS Server.

Steps to Add MX Record in Windows DNS Server

Just like the other types of DNS record, administrator can choose to use either DNS Manager or PowerShell to add MX record in Windows DNS server. But before we get to it, there are few things you should know:

  • The first thing is that MX record must be created in a Forward Lookup zones and should be created under domain name that you are using as the email address suffix. For example, if you have a zone named mustbegeek.com and the email address suffix is “@something.mustbegeek.com” or simply just “@mustbegeek.com” then the MX record should be created under zone mustbegeek.com.
  • Secondly, the email server should have a valid A record or CNAME record existing in the DNS server. So before you add the MX record, you have to add A record for the mail server, or it will be even better if you add CNAME record to hide the original mail server hostname.
  • Lastly, the same MX record can be created repeatedly for pointing to different email servers. Each MX record will be given priority number and DNS server will lookup to the email server starting from the lowest number.

Now, see the scenario below to help you better understands the case:

You are domain administrator for mustbegeek.com and are required to setup MX record for the domain. AS-DCO001 is both the Domain Controller and DNS server for this network. The email address will be using “@mustbegeek.com” for the suffix address and must be utilizing two email servers in the network (AS-MBX001 as the primary email server and AS-MBX002 as the secondary).



Using DNS Manager to Add MX Record in Windows DNS Server

As the requirement in this scenario is to setup MX record for the domain mustbegeek.com, first you need to browse to the mentioned zone in the DNS Manager.

Add MX Record in Windows DNS Server - 1

Right click on the zone name and select New Mail Exchanger (MX)…

Add MX Record in Windows DNS Server - 2

The popup window below should appear.

Add MX Record in Windows DNS Server - 3

Now you need to fill in the details in the popup:

  • Host or child domain = Fill in this field according to the email address suffix that you want to use. Since the requirement is to use the email suffix “@mustbegeek.com” which is the parent domain itself, we’re going to leave this field blank. In other case you may want to fill in this field using a value, for example: “something”, if the email address suffix is “@something.mustbegeek.com
  • Fully qualified domain name (FQDN) of mail server = Fill in this field with the FQDN of the mail server or click Browse button and select the mail server A or CNAME record. For this scenario the FQDN for the first mail server is AS-MBX001.mustbegeek.com and for the second is AS-MBX002.mustbegeek.com.
  • Mail server priority = Fill in the priority number, default is 10 but you can use any number between 0 and 65535 to define the priority. In the scenario, we’re giving priority 10 to the primary server and 20 for the secondary.

Optionally you can tick the option to “Delete this record when it becomes stale to allow aging” on the MX record. Also, you can modify the TTL value if necessary.

The screenshots below shows the two MX records configuration for the scenario:

Add MX Record in Windows DNS Server - 4

Add MX Record in Windows DNS Server - 5

Using PowerShell to Add MX Record in Windows DNS Server

To add MX record, run PowerShell as administrator then use cmdlets below:

Add-DnsServerResourceRecordMX -Preference PREF_NUMBER -Name “MX_NAME” -MailExchange “HOST_FQDN” -ZoneName “ZONE_NAME” [-TimeToLive TTL_VALUE] [-AgeRecord]

Replace these parameters according to the requirement:

  • PREF_NUMBER = Replace with the priority number
  • MX_NAME = Replace with value according to the email suffix name. If you’re using parent domain as the suffix, replace this value with a dot (.).
  • HOST_FQDN = Replace with the FQDN of the mail server (must be valid A or CNAME record in the DNS)
  • ZONE_NAME = Replace with the zone name

Optional keyword

  • [-AgeRecord] = Use if you want to allow aging on the MX record
  • [-TimeToLive TTL_VALUE] = Use if you want to customize the TTL. Replace TTL_VALUE with value in HH:MM:SS format.

And here’s the PowerShell command for our scenario that matches the previous example:

Add MX Record in Windows DNS Server - 6

Understanding the Role of MX Record

When someone sends email to @mustbegeek.com, the sender email server will first lookup for the available MX record for domain mustbegeek.com.

Add MX Record in Windows DNS Server - 7

We have added two MX records as shown above. And these two records will point the sender of where to send the email packet. DNS server will resolve to the MX record with the lower priority number first. If for some reason the first email server is unavailable, then DNS will resolve it to the next MX record. With this way, others will be able to send email to mustbegeek.com domain.

Without having MX record, this whole process of sending email cannot be done. And this why it is important to learn to add MX record in Windows DNS server.




The following two tabs change content below.

Arranda Saputra

ITIL Certified, CCNA, CCDA, VCP6-DCV, MCSA Administering Windows Server 2012
I am IT practitioner in real life with specialization in network and server infrastructure. I have years of experience in design, analysis, operation, and optimization of infrastructure solutions for enterprise-scaled network. You can send me a message on LinkedIn or email to arranda.saputra@outlook.com for further inquiry regarding stuffs that I wrote or opportunity to collaborate in a project.

Latest posts by Arranda Saputra (see all)

scroll to top