I have a subdomain of a site, lets say foo.example.com
which has an A record to the IP of another server, lets say example2.com
. Ideally, I would like to have the example2's server also take care of the MX record for the foo.example
subdomain, but I'm not sure how this would work.
I'm wondering what the options are for doing this, whether this will work:
example.com DNS:
foo A xx.xx.xx.xx
foo MX mx.example2.com
example2.com DNS:
mx MX mx.thirdserver.com
Or could I set up a new dns zone on the example2
server which would just handle the MX record for the foo.example.com
domain, where any mail sent to foo.example.com
would be handled by these mx records.
Or, alternately, should I solve this with a cname or dname record
Delegating the DNS zone for the subdomain is probably more effort than it's worth in this case.
Your first example is fine, with the exception that your MX record is badly formatted. You'll need a priority for the MX server, eg
However:
If you have an A record for a host (foo.example.com), and you address mail to [email protected],com, in the absence of any MX records delivery will be attempted to the A record. So, you don't technically need an MX record for this use case, assuming that the IP address of foo.example.com is the same as the intended MX.
I'm not sure that chaining the MX as you have will work (eg, as your example suggests). It may do, I've never tried it. I'd strongly suggest skipping the chaining that you have, and just have the MX record for foo.example.com point strait to mx.thirdserver.com instead.
EG, if you do want the MX to ultimately be mx.thirdserver.com, just do this instead: