Last updated: 5 April 2021

DNS is quite flexible. If you want you can host your website on one server and your email on another. This article looks at three common DNS configurations. The DNS records mentioned in this article are explained in our article about Common DNS records.

Host your website and email on the same server

For this article I use the domain example.net. The domain is hosted on our Strawberry server, which has the IP address 84.18.206.207. By default, the DNS zone contains the following DNS records:

example.net.                 A         84.18.206.207
www                          CNAME     example.net.
webmail                      CNAME     example.net.
example.net.                 MX        example.net. (0)
example.net.                 MX        backup-dmx01.active-ns.com. (100)
example.net                  TXT       v=spf1 mx a include:spf.active-ns.com ~all

Here, everything points to 84.18.206.207, apart from the second (fall-back) mail server. Website traffic for example.net and www.example.net go to 84.18.206.207, and incoming emails are also be routed to example.net. The SPF record is our global SPF record.

Host your website elsewhere but keep email on our servers

You need to make two changes if you want to host your website elsewhere and keep your email on our server. The first change is easy enough: you need to change the A record so that it points to the new server. Next, you need to make sure that the MX record still points to our server.

In the below example the new A record for example.net is 98.76.54.32. The primary MX record can no longer point to example.net. I therefore added an A record for mail.example.net that points to 84.18.206.207 and pointed the MX record to mail.example.net.

example.net.                 A         98.76.54.32
www                          CNAME     example.net.
webmail                      CNAME     example.net.
mail                         A         84.18.206.207
example.net.                 MX        mail.example.net. (0)
example.net.                 MX        backup-dmx01.active-ns.com. (100)
example.net                  TXT       v=spf1 mx a include:spf.active-ns.com ~all

An alternative is to point the MX record to the server’s hostname. In this case the MX record can point to strawberry.active-ns.com. In other words, you just need to make sure that the MX record resolves to the server’s IP address (here 84.18.206.207).

Also, note that you don’t have to change the SPF record. The record tells receiving mail servers that example.net is allowed to send mail from both the domain’s A and MX record. The record is still correct, even though both the A and MX record have changed.

Host your email elsewhere but keep the website on our servers

It is of course also possible to host only email elsewhere. In that case you need update the MX records:

example.net.                 A         84.18.206.207
www                          CNAME     example.net.
example.net.                 MX        aspmx.l.google.com. (1)
example.net.                 MX        alt1.aspmx.l.google.com. (5)
example.net.                 MX        alt2.aspmx.l.google.com. (5)
example.net.                 MX        alt3.aspmx.l.google.com. (10)
example.net.                 MX        alt4.aspmx.l.google.com. (10)
example.net                  TXT       v=spf1 a include:_spf.google.com ~all

In this case I also updated the SPF record. Often you don’t need to do so, as the SPF record already allows mail from the MX record. However, it is always best to use the SPF record suggested by your email provider.

Host everything elsewhere

There is one other possible scenario: hosting both your website and email elsewhere. This can be useful if just want a friendly control panel to manage the DNS for your domain.

example.net.                 A         98.76.65.43
www                          CNAME     example.net.
example.net.                 MX        aspmx.l.google.com. (1)
example.net.                 MX        alt1.aspmx.l.google.com. (5)
example.net.                 MX        alt2.aspmx.l.google.com. (5)
example.net.                 MX        alt3.aspmx.l.google.com. (10)
example.net.                 MX        alt4.aspmx.l.google.com. (10)
example.net                  TXT       v=spf1 a include:_spf.google.com ~all

The above DNS records send website traffic to 98.76.54.32 and email traffic to G Suite.