2

I'm just a bit confused about the correct DNS setup for hosting multiple domains on a single server with one ip.

For example the mail server (domain/reverse: example.com) should host 3 domains:

example.com
domain.com
test.com

So whats the correct dns setup?

example.com   mx   1 example.com
domain.com    mx   1 example.com
test.com      mx   1 example.com

or

example.com   mx   1 example.com
domain.com    mx   1 domain.com
test.com      mx   1 test.com

And whats about the mx priority? Only 1 entry for each host? I guess thats fine, because there is only one server and no extra failover server.

Xairoo
  • 165
  • 1
  • 4

2 Answers2

4

Choose a domain name for your mail server. The MX record should point to the FQDN (Fully Qualified Dommain Name) of the mail server, such as smtp.example.com. All domains should use this FQDN in their MX. Use a priority higher than 1 so that you can add servers with both higher and lower priority. Something like:

example.com.   mx   10 smtp.example.com.
domain.com.    mx   10 smtp.example.com.
test.com.      mx   10 smtp.example.com.

Consider adding an SPF record for the Host definition for the server should be something like the following:

mail.example.com.   A       192.0.2.5
                    TXT     "v=spf a -all"

The mail server should identify itself its FQDN mail.example.com when sending messages. This name is commonly included in the header when clients connect. The PTR record for the mail server's IP address should also return the FQDN of the mail server. This will enable reverse DNS lookup.

MX and SPF specifications for the domains should be something like the following. (This assumes a policy that all outgoing mail will be send via the MX. Additional authorized servers can be added as required.)

@       MX      10     smtp.example.com
        TXT     "v=spf mx -all"
BillThor
  • 27,737
  • 3
  • 37
  • 69
  • @Xairoo You can also use `mx` as hostname, that's totally up to you. The reverse hostname must match exactly, not only the domain part. @BillThor Shouldn't it be `v=spf mx -all`? – sebix Feb 18 '15 at 08:21
  • @BillThor thanks! @sebix I changed my whole mx/dns setup, works very well. Yeah, it should be `v=spf mx -all` (I use `~all`). Alternatively you could set the IPv4/v6 instead of the `mx` value: `v=spf1 ip4:6.79.15.238 -all` – Xairoo Feb 18 '15 at 11:52
  • @Xairoo Do you have any particular reason for using the softfail variant `~all`? The usage of ~all is discouraged, it is for debugging purpose only. – sebix Feb 18 '15 at 12:01
  • @sebix I did specify hard fail (-all) which I use everywhere. I did grab the wrong SPF specification from my web server, instead of the the correct one from my mail server. I've updated using the A record rather than the MX record as there is no MX for the mail server. The domain should use MX but I didn't include it, but have now. – BillThor Feb 18 '15 at 21:04
1

An MX record for a domain can "point" to any host, so having them all "point" to the same server is fine. As for the preference, you can set it to whatever you like. If you add servers in the future you can add them with a higher or lower preference, dependent upon your needs.

joeqwerty
  • 109,901
  • 6
  • 81
  • 172